我按照这个论坛上的说明操作了(链接在这里) 添加单独的附录列表,这是我所在大学的要求。该列表应放在缩写列表之后,如下图所示:
为了实现这一点,我添加了以下宏:
\newcounter{dlf}
\newcommand\test{%
\stepcounter{dlf}
\chapter{Test chapter \thedlf}
\section{test section \thedlf}}
\cftinsertcode{preapp}{\setcounter{tocdepth}{-10}}
\newcommand\apptoc{
\begingroup
\cftinsertcode{prenorm}{\setcounter{tocdepth}{-10}}
\cftinsertcode{preapp}{\setcounter{tocdepth}{3}}
\renewcommand\contentsname{List of Appendices}
\tableofcontents*
\endgroup
}
然后我在缩写部分之后插入了以下代码:
\apptoc
\addcontentsline{toc}{chapter}{List of Appendices}
\cftinserthook{toc}{prenorm}
然后,最后,我在 \begin{appendices} 之后添加了
\appendix
\appendixpage
\cftinserthook{toc}{preapp}
它运行得很好,但现在目录和索引都消失了。它们被放在附录列表的末尾。(见下图)问题是:我如何将它们放回目录?
这是一个 MWE:
\documentclass[12pt,letterpaper,oneside,final]{memoir}
\usepackage[no-math]{fontspec}
\usepackage{xltxtra}
\usepackage{xkeyval}
\usepackage{polyglossia}
\usepackage{type1cm}
\usepackage{graphicx}
\usepackage[rightcaption]{sidecap}
\usepackage{float}
\usepackage{url}
\usepackage[normalem]{ulem}
\usepackage{siunitx}
\usepackage{textcomp}
\usepackage{makeidx}
\setdefaultlanguage[variant=american]{english}
\setotherlanguage[variant=ancient,numerals=arabic]{greek}
\setotherlanguage[spelling=new]{german}
\setotherlanguages{french,italian,spanish}
\usepackage{csquotes}
\usepackage{etoolbox,keyval,ifthen}
\usepackage[backend=biber]{biblatex-chicago}
\usepackage{booktabs}
\usepackage{array}
\usepackage[series={},nocritical,noend,noeledsec,nofamiliar,noledgroup]{reledmac}
\usepackage{reledpar}
\setlength{\columnrulewidth}{0.4pt}
%\DeclareAutoCiteCommand{plain}{\cite}{\cites}
\DeclareAutoCiteCommand{plain}{\textcite}{\textcites}
\DeclareAutoCiteCommand{inline}{\textcite}{\textcites}
\DeclareAutoCiteCommand{footnote}[l]{\footcite}{\footcites}
%\DeclareAutoCiteCommand{footnote}[f]{\smartcite}{\smartcites}
\bibliography{masterbib}
\usepackage[final]{hyperref}%?%hyperfootnotes=false
\hypersetup{bookmarks=false, % show bookmarks bar?
unicode=true, % non-Latin characters in Acrobat’s bookmarks
pdftoolbar=true, % show Acrobat’s toolbar?
pdfmenubar=true, % show Acrobat’s menu?
pdffitwindow=false, % window fit to page when opened
pdfstartview={FitH}, % fits the width of the page to the window
pdftitle={},
pdfauthor={}, % author
pdfsubject={Ph.D. Dissertation}, % subject of the document
pdfcreator={}, % creator of the document
pdfproducer={}, % producer of the document
pdfkeywords={}, % list of keywords
pdfnewwindow=true, % links in new window
colorlinks=true, % false: boxed links; true: colored links
linkcolor=black, % color of internal links
citecolor=black, % color of links to bibliography
filecolor=black, % color of file links
urlcolor=black % color of external links
}
\usepackage{microtype}
\usepackage{xecolor}
\definergbcolor{blue}{0000FF}
\definergbcolor{red}{FF0000} %\textxecolor{colorname}{text}
\XeTeXdashbreakstate=1
%\usepackage{indentfirst}
\usepackage{outline}
%\usepackage{verbatim}
\usepackage{enumerate}
\usepackage{longtable}
\usepackage{ccicons}
\usepackage{bookmark}
\usepackage{etoolbox}
\usepackage{lscape}
\epigraphfontsize{\small\itshape}
\setlength\epigraphwidth{8cm}
\setlength\epigraphrule{0pt}
%!%%%%%%%%%%%%%%%%%%%%%for non-italicized headings%%%%%
% http://tex.stackexchange.com/questions/32655/remove-italic-from-memoir-headings-pagestyle
\makeevenhead{headings}{\leftmark}{}{}
\makeoddhead{headings}{\rightmark}{}{}
\makeevenfoot{headings}{}{\thepage}{}
\makeoddfoot{headings}{}{\thepage}{}
%!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%!%%%%%%%%%%%%%%%%%%%%%for margins, l=1.5; rest=1.0, maybe add 0.1in%%%%%
\setstocksize{11in}{8.5in}
\settrimmedsize{11.0in}{8.5in}{*} %\settrimmedsize{ height }{ width }{ ratio }
\settypeblocksize{7.75in}{5.8in}{*} %\settypeblocksize{ height }{ width }{ ratio } %note: 7.25h gives margins of 1.5 on top/bottom w/ ubratio of 1
\setlrmargins{1.5in}{*}{*} %\setlrmargins{ spine }{ edge }{ ratio } %spine = left, edge = right; only answer one or two of these values
%\setlrmarginsandblock{1.5in}{1.0in}{*} %\setlrmarginsandblock{ spine }{ edge }{ ratio } %
%\setulmargins{*}{*}{*} %\setulmargins{ upper }{ lower }{ ratio }
%\setulmarginsandblock{0.5in}{*}{*} %\setulmarginsandblock{ upper }{ lower }{ ratio }
%\setheadfoot{*}{*} %\setheadfoot{ headheight }{ footskip }
%\setheaderspaces{1.0in}{*}{*} %\setheaderspaces{ headdrop }{ headsep }{ ratio }
%\checkandfixthelayout[lines]
\flushbottom
%!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\apptocmd{\sloppy}{\hbadness 10000\relax}{}{}
\setsecnumdepth{subparagraph}
\makeatletter
\renewcommand\@makefntext{\hspace*{2em}\@thefnmark. }
\newenvironment*{singlespcquote}
{\quote\SingleSpacing}
{\endquote}
\SetBlockThreshold{0}
\SetBlockEnvironment{singlespcquote}
\SetCiteCommand{\parencite} %default is \cite
\makeindex
%%%%%%%%%%%%List of Appendices Macro%%%%%%%%%%%%
\newcounter{dlf}
\newcommand\test{%
\stepcounter{dlf}
\chapter{Test chapter \thedlf}
\section{test section \thedlf}}
\cftinsertcode{preapp}{\setcounter{tocdepth}{-10}}
\newcommand\apptoc{
\begingroup
\cftinsertcode{prenorm}{\setcounter{tocdepth}{-10}}
\cftinsertcode{preapp}{\setcounter{tocdepth}{3}}
\renewcommand\contentsname{List of Appendices}
\tableofcontents*
\endgroup
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{kantlipsum}
\begin{document}
%\fussy
%\hyphenpenalty=5000 %1000 default=?
%\tolerance=1000 %1000 %200= default
%\setlength{\emergencystretch}{3em}
%\midsloppy
\fussy
\vbadness=10000 % badness above which bad vboxes are shown. (Default = 10000?)
\frontmatter
\hyphenation{}
\DoubleSpacing
\begin{center}
\thispagestyle{empty}
Title of the Dissertatio
\vspace{20mm}
by\\
\vspace{10mm}
xxxxxx xxxxxx\\
\vspace{10mm}
A dissertation submitted in partial fulfillment\\
of the requirements for the degree of\\
Doctor of Philosophy\\
Department ...\\
New York University\\
September, 2017
\end{center}
\vspace{35mm}
\begin{flushright}
{\rule[0pt]{45mm}{0.1mm}}\\ %rule[raise-height]{width}{height} * raise-height specifies how high to raise the rule (optional) * width specifies the length of the rule (mandatory) * height specifies the height of the rule (mandatory)
Prof. xxxxx
\end{flushright}
\newpage
\thispagestyle{empty}
\begin{center} © xxxxxxx \\ All Rights Reserved, 2017\end{center}
\newpage
\thispagestyle{empty}
\chapter{Dedication}
dedication
\DoubleSpacing
\newpage
\chapter{Acknowledgments}
acknowledgments
\newpage
\chapter{Abstract}
\DoubleSpacing
abstract
\newpage
\renewcommand*{\cftappendixname}{Appendix\space}
\renewcommand*{\contentsname}{Table of Contents}
\setcounter{tocdepth}{2}% chapters and above
%this removes TOC listing from TOC
\begin{KeepFromToc}
\tableofcontents
\end{KeepFromToc}
\clearpage
\newpage
\clearpage
\listoffigures
\chapter{List of Abbreviations}
\SingleSpacing
\begin{longtable}{ll}
\emph{ASFi} & Archivio di Stato di Firenze\\
\emph{ASMn} & Archivio di Stato di Mantova\\
\emph{ASPi} & Archivio di Stato di Pisa\\
\emph{ASVe}& Archivio di Stato di Venezia\\
\emph{ASVr}& Archivio di Stato di Verona\\
\emph{AG} & Archivio Gonzaga\\
\emph{AN} & Archivio Notarile\\
\emph{PM} & Principato Mediceo\\
\emph{BUPi} & Biblioteca Universitaria di Pisa\\
\emph{BCTr} & Biblioteca Comunale di Trento\\
\emph{BUBo} & Biblioteca Universitaria di Bologna\\
\emph{BNM} & Biblioteca Nazionale Marciana\\
\emph{BNCFi} & Biblioteca Nazionale Centrale di Firenze\\
\emph{BnF} & Bibliothèque nationale de France\\
\emph{BNE} & Biblioteca Nacional de España\\
\emph{BSB} & Bayerische Staatsbibliothek\\
\emph{BAV} & Biblioteca dell'Accademia Virgiliana\\
\emph{IdF} & Institut de France\\
\emph{RVF} & Rerum Vulgarium Fragmenta \\
\end{longtable}
\clearpage
\apptoc
\addcontentsline{toc}{chapter}{List of Appendices}
\cftinserthook{toc}{prenorm}
\DoubleSpacing
\mainmatter
\clearpage
\cleardoublepage
\phantomsection
\chapter[Introduction]{Introduction}
\kant[1-2]
\chapter{Chapter1}
\index{chapter one}chapter one
\kant[1-2]
\chapter{Chapter 2}
\index{chapter two}chapter two
\kant[1-2]
\chapter{Chapter 3}
\kant[1-2]
\chapter{Chapter 4}
\kant[1-2]
\chapter[Conclusion]{Conclusion}
%%%%%%%% Appendices %%%%%%%%%%%%%
\begin{appendices}
\appendix
\appendixpage
\cftinserthook{toc}{preapp}
\chapter{Appendix a}
\kant[1-2]
\section{more Kant}
\kant[1-2]
\section{even more kant}
\kant{1-2}
\chapter{Appendix b}
\kant[1-2]
\chapter{Appendix c}
\kant[1-2]
\chapter{Appendix d}
\kant[1-2]
\end{appendices}
\newpage
\clearpage
\backmatter
\begin{OnehalfSpace}
\setlength{\bibitemsep}{\onelineskip}
\chapter{Bibliography}
\kant
\printindex
\end{OnehalfSpace}
\end{document}
答案1
此方法.toc
通过启动新的 ToC 来使用“假”文件句柄.app
。
首先解释一下OP代码出了什么问题:
从 OP 代码有效地.toc
过早关闭了文件,并添加了以下内容,如参考书目目录条目或索引目录条目到附录目录 - 没有机会将它们转移到真正的.toc
.
现在这是另一种方法:
在启动之前\appendices
调用\listofappendices
将其名称插入到通用目录的宏,但使用文件.app
而不是.toc
。
从这个位置开始,所有条目都应转到文件.app
而不是.toc
,因此\let\tf@toc\tf@app
使用,即文件句柄被更改。
在 时\endappendices
,原始文件句柄将被恢复,以便任何其他内容都将恢复为原始内容.toc
。
该解决方案与我在此处给出的另一个答案类似:如何获得附录图的单独列表?
\documentclass{memoir}
\usepackage{kantlipsum}
\makeatletter
\g@addto@macro{\appendices}{%
\listofappendices% Use the
\write\@auxout{%
\string\let\string\latex@tf@toc\string\tf@toc% Store the original `\tf@lof` file handle
\string\let\string\tf@toc\string\tf@app%
}%
}
\g@addto@macro{\endappendices}{%
\write\@auxout{%
\string\let\string\tf@toc\string\latex@tf@toc% Rename the file handle
}%
}
\newcommand{\listofappendices}{\bgroup%
\renewcommand\contentsname{List of Appendices}
\let\@startoc@temp\@starttoc \def\@starttoc##1{\@startoc@temp{app}}%
\clearpage
\tableofcontents \egroup
}
\makeatother
\begin{document}
\tableofcontents*
\chapter{foo}
\chapter{foobar}
\begin{appendices}
\appendix
\appendixpage
\chapter{Appendix a}
\kant[1-2]
\section{more Kant}
\kant[1-2]
\section{even more kant}
\kant{1-2}
\chapter{Appendix b}
\kant[1-2]
\chapter{Appendix c}
\kant[1-2]
\chapter{Appendix d}
\kant[1-2]
\end{appendices}
\chapter{fooother}
\end{document}
更新
\documentclass{memoir}
\usepackage{kantlipsum}
\makeatletter
\g@addto@macro{\appendices}{%
\appendix
\appendixpage
\write\@auxout{%
\string\let\string\latex@tf@toc\string\tf@toc% Store the original `\tf@lof` file handle
\string\let\string\tf@toc\string\tf@app%
}%
}
\g@addto@macro{\endappendices}{%
\write\@auxout{%
\string\let\string\tf@toc\string\latex@tf@toc% Rename the file handle
}%
}
\newcommand{\appendicesname}{Appendices}
\newcommand{\listofappendices}{\bgroup%
\renewcommand\contentsname{List of Appendices}
\let\@startoc@temp\@starttoc%
\def\@starttoc##1{\@startoc@temp{app}}%
\clearpage
\tableofcontents* \egroup
}
\makeatother
\makeindex
\usepackage{hyperref}
\begin{document}
\tableofcontents*
\listofappendices%
\chapter[Introduction]{Introduction}
\kant[1-2]
\chapter{Chapter1}
\index{chapter one}chapter one
\kant[1-2]
\chapter{Chapter 2}
\index{chapter two}chapter two
\kant[1-2]
\chapter{Chapter 3}
\kant[1-2]
\chapter{Chapter 4}
\kant[1-2]
\chapter[Conclusion]{Conclusion}
\begin{appendices}
\chapter{Appendix a}
\kant[1-2]
\section{more Kant}
\kant[1-2]
\section{even more kant}
\kant{1-2}
\chapter{Appendix b}
\kant[1-2]
\chapter{Appendix c}
\kant[1-2]
\chapter{Appendix d}
\kant[1-2]
\end{appendices}
\printindex
\end{document}