我正在尝试构建一个与我们大学的 word 模板相当的 latex 模板。除了附录的问题外,我已经修复了所有问题。
我希望附录章节看起来像这样:
但当这样做时,附录的目录输入全都混乱了,像这样(看最后一行):
如果我删除 \thechapter 命令中罗马数字前面的“APPENDIX”,那么就可以了。但我需要它。
这是一个最小工作示例。我想保留章节打印在同一行而附录章节打印在两行的方式。
\documentclass[a4paper,11pt,oneside]{book}
\usepackage{tocloft}
\parskip 0.4em
\usepackage{etoc}
\setcounter{secnumdepth}{4}
\usepackage[toc,page]{appendix}
\usepackage{geometry}
\geometry{a4paper, textwidth=16cm, top=2.0cm, left=2.5cm, bottom=1.25cm, includehead, includefoot}
\usepackage{tocloft}
\usepackage{tocbibind}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[R]{\small{\thepage}}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.0pt}
\usepackage{titlesec}
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}{\thechapter~}{1em}{}
\titlespacing*{\chapter}{0pt}{-50pt}{40pt}
\begin{document}
\frontmatter
\begin{titlepage}
\begin{center}
\vspace{25em}
{\LARGE \textbf{Doctoral dissertation} \\}
\vspace{5em}
{\huge \textbf{Fancy title}\\}
\vspace{5em}
{\LARGE \textbf{Fancy name}\\}
\vfill {\Large \textbf{City, Month Year}}
\end{center}
\end{titlepage}
\tableofcontents
\mainmatter
\chapter{Chapter 1}
\section{lalal}
\section{lalal}
\chapter{Chapter 2}
\section{lalal}
\section{lalal}
\appendix
\renewcommand{\thechapter}{APPENDIX \Roman{chapter}}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\thechapter }{0pt}{\huge}
\chapter{Title of appendix I}
\end{document}
答案1
这用于在目录的中间\addtocontents
进行修改。\numberline
\documentclass[a4paper,11pt,oneside]{book}
%\usepackage{tocloft}
\parskip 0.4em
\usepackage{etoc}
\setcounter{secnumdepth}{4}
\usepackage[toc,page]{appendix}
\usepackage{geometry}
\geometry{a4paper, textwidth=16cm, top=2.0cm, left=2.5cm, bottom=1.25cm, includehead, includefoot}
%\usepackage{tocloft}
\usepackage{tocbibind}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[R]{\small{\thepage}}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.0pt}
\usepackage{titlesec}
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}{\thechapter~}{1em}{}
\titlespacing*{\chapter}{0pt}{-50pt}{40pt}
\makeatletter
\def\bignumberline#1{\advance\@tempdima by 7em
\hb@xt@\@tempdima{#1\hfil}}
\makeatother
\begin{document}
\frontmatter
\begin{titlepage}
\begin{center}
\vspace{25em}
{\LARGE \textbf{Doctoral dissertation} \\}
\vspace{5em}
{\huge \textbf{Fancy title}\\}
\vspace{5em}
{\LARGE \textbf{Fancy name}\\}
\vfill {\Large \textbf{City, Month Year}}
\end{center}
\end{titlepage}
\tableofcontents
\mainmatter
\chapter{Chapter 1}
\section{lalal}
\section{lalal}
\chapter{Chapter 2}
\section{lalal}
\section{lalal}
\appendix
\addtocontents{toc}{\string\let\string\numberline=\string\bignumberline}
\renewcommand{\thechapter}{APPENDIX \Roman{chapter}}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\thechapter }{0pt}{\huge}
\chapter{Title of appendix I}
\end{document}