非常抱歉,我必须寻求紧急帮助,因为我无法理解之前提出的个别问题。
我需要一个单独的附录列表,即除了项目之外,附录不会出现在目录中附录,可以使用以下方式手动创建
\addcontentsline{toc}{section}{Appendix}
附录本身的结构应该是这样的
Appendix A
A.1 Title
A.2 Title
..
Appendix B
B.1 Title
B.2 Title
..
Tocloft
提供了一种手动创建列表的方法,此示例取自文档:
\newcommand{\listanswername}{List of Answers}
\newlistof[chapter]{answer}{ans}{\listanswername}
\newcommand{\answer}[1]{%
\refstepcounter{answer}
\par\noindent\textbf{Answer \theanswer. #1}
\addcontentsline{ans}{answer}{\protect\numberline{\theanswer}#1}\par}
\listofanswer
创建添加项目的命令
\answer{Hard}
这导致
List of Answers
1 Hard ....... pageno
我遇到了几个问题:
- 十进制计数器代替字母计数器
- An 方案没有子环境
- 没有像“附录 A.1 Hard .... pageno”这样的前缀
所以我需要一个列表,例如
List of Appendices
Appendix A Code listings ................. 187
Appendix A.1 Stackexchange generator ........ 187
Appendix A.2 Stackexchange hack function .... 2179
Appendix B Misc ................ 2180
Appendix B.1 Overview Q&A Sites ........ 2181
Appendix B.2 User psychoanalysis .... 2378
我认为可以通过按照 tocloft 文档中介绍的方式添加第二个命令来解决这个问题,但由于我的论文状态很糟糕(当然,明天就要交了),我目前没有时间去解决这个问题。
因此,如果有人可以提供子命令和将枚举更改为文字的方法,我将不胜感激。再次抱歉,我现在的心态是,只有一个万无一失的傻瓜解决方案才能让我有所收获。
答案1
对于原始海报来说,这可能太晚了,但这就是我想到的。主要改编自 lockstep 的答案,但符合附录/子附录模型,并遵循要求的 ToC 样式:
\documentclass[toc=flat,numbers=noenddot]{scrartcl}
\usepackage{lipsum}
\usepackage{tocloft}
\newcommand{\listappendixname}{List of Appendices}
\newlistof{appendix}{app}{\listappendixname}
\setcounter{appdepth}{2}
\renewcommand{\theappendix}{\Alph{appendix}}
\renewcommand{\cftappendixpresnum}{Appendix\space}
\setlength{\cftbeforeappendixskip}{\baselineskip}
\setlength{\cftappendixnumwidth}{1in}
\newlistentry[appendix]{subappendix}{app}{1}
\renewcommand{\thesubappendix}{\theappendix.\arabic{subappendix}}
\renewcommand{\cftsubappendixpresnum}{Appendix\space}
\setlength{\cftsubappendixnumwidth}{1in}
\setlength{\cftsubappendixindent}{0em}
\newcommand{\myappendix}[1]{%
\refstepcounter{appendix}%
\section*{\theappendix\space #1}%
\addcontentsline{app}{appendix}{\protect\numberline{\theappendix}#1}%
\par
}
\newcommand{\subappendix}[1]{%
\refstepcounter{subappendix}%
\subsection*{\thesubappendix\space #1}%
\addcontentsline{app}{subappendix}{\protect\numberline{\thesubappendix}#1}%
}
\begin{document}
\tableofcontents
\section{Foo} \lipsum[1]
\subsection{Bar} \lipsum[2]
\section{Additional Foo} \lipsum[3]
\subsection{Additional Bar} \lipsum[4]
\listofappendix
\myappendix{Baz} \lipsum[5]
\subappendix{Qux} \lipsum[6]
\myappendix{Additional Baz} \lipsum[7]
\subappendix{Additional Qux} \lipsum[8]
\end{document}
答案2
我设法纠正了 tocloft 文档中的示例。
两个代码行实际上是错误的——
\newlistentry
缺少 的一个强制参数,以及 中的一个右括号\addcontentsline
。我已用“(!)”标记了这些更正。因为您使用的是没有的文档类
\chapter
,所以必须更改某些参数。
我还擅自更改了垂直和水平间距(标记为“可选”)。
\documentclass[toc=flat,numbers=noenddot]{scrartcl}
\usepackage{tocloft}
\newcommand{\listanswername}{List of Answers}
\newlistof[section]{answer}{ans}{\listanswername}% "section" instead of "chapter"
\cftsetindents{answer}{0em}{1.8em}% Optional
\newcommand{\answer}[1]{%
\refstepcounter{answer}%
\bigskip% Optional
\par\noindent
\textbf{Answer~\theanswer. #1}%
\addcontentsline{ans}{answer}{\protect\numberline{\theanswer}#1}%
\par
}
\newlistentry[answer]{subanswer}{ans}{2}% "{ans}" added (!); "2" instead of "1"
\cftsetindents{subanswer}{1.8em}{2.9em}% Optional
\renewcommand{\thesubanswer}{\theanswer.\alph{subanswer}}
\newcommand{\subanswer}[1]{%
\refstepcounter{subanswer}%
\smallskip% Opional
\par
\textbf{\thesubanswer) #1}%
\addcontentsline{ans}{subanswer}% "}"after "subanswer" added (!)
{\protect\numberline{\thesubanswer}#1}%
\quad\ignorespaces% Optional
}
\setcounter{ansdepth}{3}% "3" instead of "2"
\begin{document}
\section{foo}
Making a custom list with \texttt{tocloft}.
\answer{Harder} The \dots
\subanswer{Reformulate the problem } It assists \dots
\listofanswer
\end{document}
答案3
这是一个不涉及 tocloft 的解决方案。作者是 Markus Kohm;我取自这网站,做了微小修改并翻译了 Markus Kohm 的评论。
\documentclass[toc=flat,numbers=noenddot]{scrartcl}
% "toc=flat,numbers=noenddot" ADDED, "scrartcl" INSTEAD OF "scrbook"
\usepackage[english]{babel}% "english" INSTEAD OF "ngerman"
\usepackage{blindtext}
\makeatletter
\newcommand*{\maintoc}{% main table of contents
\begingroup
\@fileswfalse% don't open new ToC file
\renewcommand*{\appendixattoc}{% macro for separation of ToC contents
\value{tocdepth}=-10000 % set tocdepth to very small value locally
}%
\tableofcontents% output ToC
\endgroup
}
\newcommand*{\appendixtoc}{% table of contents for appendix
\begingroup
\edef\@alltocdepth{\the\value{tocdepth}}% save tocdepth
\setcounter{tocdepth}{-10000}% no ToC entries
\renewcommand*{\contentsname}{% change ToC name
List of Appendices}% "List of Appendices" INSTEAD OF "Verzeichnis der Anh\"ange"
\renewcommand*{\appendixattoc}{% macro for separation of ToC contents
\setcounter{tocdepth}{\@alltocdepth}% restore tocdepth
}%
\tableofcontents% output ToC
\setcounter{tocdepth}{\@alltocdepth}% restore tocdepth
\endgroup
}
\newcommand*{\appendixattoc}{% macro for separation of ToC contents
}
\g@addto@macro\appendix{% augment \appendix
% \if@openright\cleardoublepage\else\clearpage\fi% new page; DELETED
\clearpage% new page; ADDED
\addcontentsline{toc}{section}{\appendixname}% entry into main ToC;
% "section" INSTEAD OF "chapter"
\addtocontents{toc}{\protect\appendixattoc}% macro for separation into ToC file
\renewcommand*{\thesection}{Appendix~\Alph{section}}% ADDED
}
\makeatother
\begin{document}
\maintoc
\blinddocument
% \blinddocument% DELETED
\appendix
\appendixtoc
\blinddocument
% \blinddocument% DELETED
\end{document}
% Note that \maintoc only works if \appendixtoc is also present. Otherwise,
% the ToC will never be updated. If \appendixtoc is removed, one should use
% \tableofcontents instead of \maintoc.