标题说明了一切。
我有点困惑为什么会发生这种情况,而且我不知道哪里出了问题。(不要介意第二个附录 B,我已将其更改为 C)但是,附录 A 是一个带有 chapter* 的 subfile.tex。
这是 document.tex (主要)
\providecommand{\main}{.}
\documentclass[12pt,a4paper]{scrreprt}
\usepackage[english]{babel}
\usepackage{enumitem}
%\usepackage[utf8]{inputenc}% only needed for older TeX distributions
\usepackage[automark,headsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\ofoot[\pagemark]{\pagemark} % \ofoot = outer footer, change to \ifoot for
inner footer \cfoot for center footer
\pagestyle{scrheadings}
\usepackage[titles]{tocloft}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % Fill dots also
for chapter leaders
\renewcommand{\cftdot}{.} % Define the symbol used for dots; can use -
or asterisk* or @
\renewcommand{\contentsname}{Table of Content}
\usepackage{subfiles} % For using 'standalone' or individual files, so each
can be compiled and seen individually.
\newcommand{\onlyinsubfile}[1]{#1}
\newcommand{\notinsubfile}[1]{}
\usepackage[nottoc,numbib]{tocbibind} % add list of tables, list of figures
and bibliography to TOC (numbered)
\begin{document}
\tableofcontents
\clearpage
\bibliographystyle{plain}
\bibliography{./library}
\cleardoublepage
\subfile{\main/app/app1}\label{sec:app1} % Appendix A
\addcontentsline{toc}{chapter}{\numberline{}Appendix A}
\end{document}
这是 app1.tex:
\providecommand{\main}{..}
\documentclass[\main/document.tex]{subfiles}
\begin{document}
\onlyinsubfile
\notinsubfile
\chapter*{\center{ {\large Appendix} {\Huge I}}}
\cleardoublepage
%------------------------------------------
\section{Stereotaxic surgery, drug delivery and head holder implantation}
\end{document}
如果你需要更多来自 main.tex 的内容请告诉我,不过它非常非常长
答案1
在您的代码中,\addcontentsline
放置在包含附录章节内容的子文件之后。因此,它出现在其章节条目下方,且页码错误。这是因为\numberline{}
条目在目录中缩进。最后但并非最不重要的是,\chapter*
它不会更改章节号。因此,章节编号仍包含最后一个章节编号,在您的示例中,即参考书目的章节编号。
您应该删除包tocbibind
并设置类选项listof=totoc
,bibliography=numbered
也许index=totoc
。
不要将包tocloft
与 KOMA-Script 类一起使用。使用 KOMA-Script 类选项,toc=chapterentrywithdots
您将获得章节条目的点。
可以通过 来更改目录的标题\renewcaptionname{english}{\contentsname}{Table of Content}
。
以下是针对附录章节的一个可能的建议:
\documentclass[
12pt,
%a4paper,% default
toc=chapterentrywithdots,% dots between the chapter entry and its page number in TOC
listof=totoc,% TOC entries for LOF, LOT etc.
index=totoc,% TOC entry for index
bibliography=numbered,% numbered with entry in TOC
numbers=noenddot% no dot at the end of sectioning numbers etc.
]{scrreprt}
\usepackage[english]{babel}
\usepackage{enumitem}
\usepackage[utf8]{inputenc}
\usepackage[automark,headsepline]{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\clearpairofpagestyles
\ofoot*{\pagemark} % short version of \ofoot[\pagemark]{\pagemark}
\renewcaptionname{english}{\contentsname}{Table of Content}% change the TOC title
\DeclareNewSectionCommand[
style=part,
level=\chapternumdepth,
tocstyle=chapter,
tocindent=0pt,
tocnumwidth=1.5em,
tocdynnumwidth,
tocentryformat=\usekomafont{chapterentry},
tocentrynumberformat=\appendixname~
]{appchap}
\makeatletter
\let\c@appchap\c@chapter% use the same counter for both chapter and appchap
\def\theappchap{\thechapter}
\def\cl@appchap{\cl@chapter}% use the same reset list
\makeatother
\renewcommand*{\appchapformat}{{\large\appendixname}~\theappchap}
\newcommand*\appendixchapter{\appchap{\mbox{}}}
\usepackage{blindtext}% only for dummy text in the MWE
\begin{document}
\tableofcontents
\blinddocument
\appendix
\appendixchapter
\section{Stereotaxic surgery, drug delivery and head holder implantation}
\Blindtext[2]
\section{Next Section}
\Blindtext
\appendixchapter
\section{Section in the second appendix chapter}
\Blindtext
\end{document}
结果:
使用包时,subfiles
您必须确保命令\appendix
仅执行一次!因此您可以使用这个\onlyinsubfile
技巧。
例子:
文件document.tex
:
\providecommand\main{.}
\documentclass[
12pt,
toc=chapterentrywithdots,
listof=totoc,
index=totoc,
bibliography=numbered,
numbers=noenddot
]{scrreprt}
\usepackage[english]{babel}
\usepackage{enumitem}
%\usepackage[utf8]{inputenc}% only needed for older TeX distributions
\usepackage{subfiles}
\newcommand{\onlyinsubfile}[1]{#1}% <- added
\usepackage[automark,headsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\ofoot*{\pagemark}
\renewcaptionname{english}{\contentsname}{Table of Content}
\DeclareNewSectionCommand[
style=part,
level=\chapternumdepth,
tocstyle=chapter,
tocindent=0pt,
tocnumwidth=1.5em,
tocdynnumwidth,
tocentryformat=\usekomafont{chapterentry},
tocentrynumberformat=\appendixname~
]{appchap}
\makeatletter
\let\c@appchap\c@chapter
\def\theappchap{\thechapter}
\def\cl@appchap{\cl@chapter}
\makeatother
\renewcommand*{\appchapformat}{{\large\appendixname}~\theappchap}
\newcommand*\appendixchapter{\appchap{\mbox{}}}
\usepackage{blindtext}
\begin{document}
\renewcommand\onlyinsubfile[1]{}% <- added
\tableofcontents
\blinddocument
\appendix
\subfile{\main/app/app1}
\subfile{\main/app/app2}
\end{document}
app1.tex
文件夹中的文件app
:
\providecommand\main{..}
\documentclass[\main/document.tex]{subfiles}
\begin{document}
\onlyinsubfile{\appendix}% <- ensures that this does not go to the main file
\appendixchapter
\section{Stereotaxic surgery, drug delivery and head holder implantation}
\Blindtext[2]
\section{Next Section}
\Blindtext
\end{document}
app2.tex
文件夹中的文件app
:
\providecommand\main{..}
\documentclass[\main/document.tex]{subfiles}
\begin{document}
\onlyinsubfile{\appendix}% <- ensures that this does not go to the main file
\appendixchapter
\section{Section in the second appendix chapter}
\Blindtext
\end{document}
主文件的结果document.tex
和上面相同。