![使用带有附录的 etoc 包——如何让目录中显示“附录”而不是“章节”?](https://linux22.com/image/479094/%E4%BD%BF%E7%94%A8%E5%B8%A6%E6%9C%89%E9%99%84%E5%BD%95%E7%9A%84%20etoc%20%E5%8C%85%E2%80%94%E2%80%94%E5%A6%82%E4%BD%95%E8%AE%A9%E7%9B%AE%E5%BD%95%E4%B8%AD%E6%98%BE%E7%A4%BA%E2%80%9C%E9%99%84%E5%BD%95%E2%80%9D%E8%80%8C%E4%B8%8D%E6%98%AF%E2%80%9C%E7%AB%A0%E8%8A%82%E2%80%9D%EF%BC%9F.png)
我目前正在努力使我撰写的毕业论文符合我应该遵守的格式要求。我最后纠结的是附录必须称为附录,而不是目录中的章节。这稍微复杂了一点,因为我还使用该verse
软件包排版了两首诗,除了后面的正常附录外,每首诗都应算作附录。
我正在使用该titlesec
包从文档内容中去除多余的格式(粗体、字体大小更改等),并etoc
使用该包删除目录中的额外格式。
我尝试使用该appendix
包来处理附录(例如,使章节被称为附录并用 \Alpha 编号,但在其他所有意图和目的上,其格式与普通章节相同),但etoc
似乎效果不佳。我尝试使用\@chapapp
,它appendix
应该重新定义为\appendixname
,但当我在章节调用中使用它时,这种变化似乎没有任何区别\etocsetstyle
。 :/
也许使用另一个包中的“部分附录”功能titlesec
(或者任何附带的 TOC 包的名称)可能允许我使用etoc
's\etocsetstyle
来重新定义样式以表示“APPPENDIX”而不是“CHAPTER”?
我很确定肯定有人以前遇到过这种情况,因为我认为很少有人喜欢将附录标识为目录中的章节。此时,任何帮助都将不胜感激。我正在通过 Windows 上的 latexmk 调用 LuaLaTeX,以防万一这可能相关(尽管我怀疑在这个特定情况下是否相关)。
以下是基本的 MWE:
\documentclass{report}
\usepackage[lmargin=1.5in,rmargin=1in,tmargin=1in,bmargin=1in,nohead,twoside=false]{geometry}
\usepackage{lipsum}
\usepackage{fmtcount}
\usepackage{setspace}
\usepackage{verse}
\usepackage[backend=biber,%
%backref=true,%
style=mla-new,autocite=footnote,firstlonghand=false,annotation=false,mladraft=true,hyperref=true]{biblatex}
\usepackage{makeidx}
\usepackage{varioref}% Load before hyperref
\usepackage[pdfpagelabels,linktoc=all]{hyperref}
\usepackage[nomain,translate=babel]{glossaries}
\usepackage{cleveref}
%\usepackage{etoc}% Moved below
\usepackage[indentafter,explicit,nobottomtitles*]{titlesec}
%\usepackage[page,toc,title,titletoc]{appendix}
%\usepackage[title]{appendix}
\usepackage{appendix}
\newdimen\myparindent
\myparindent=18pt\relax
\titleformat{\chapter}[block]{%
\begingroup\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}{CHAPTER \NUMBERstringnum{\value{chapter}}\\\hfill\\#1\\}%
{0pt}{\end{centering}\endgroup\doublespacing\vspace{\baselineskip}}
\titlespacing{\chapter}{0pt}{0pt}{0pt}[0pt]
\titleformat{\section}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}\hfill}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\section}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsection}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\subsection}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsubsection}[runin]{}{\thesubsubsection}{0pt}{\bgroup\normalfont\textit{#1.}\egroup}
\titlespacing{\subsubsection}{\myparindent}{0pt}{1.3\fontdimen2\font plus1.3\fontdimen3\font minus1.3\fontdimen4\font}
\titleformat{\part}[block]{%
\begin{minipage}[c][9in]{6in}%
\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}%
{\MakeUppercase{#1}}%
{0pt}%
{\\\end{centering}\end{minipage}}
\titlespacing{\block}{0pt}{0pt}{0pt}[0pt]
\titleformat{\chapter}[block]{%
\begingroup\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}{CHAPTER \NUMBERstringnum{\value{chapter}}\\\hfill\\#1\\
}{0pt}{\end{centering}\endgroup\doublespacing\vspace{\baselineskip}}
\titlespacing{\chapter}{0pt}{0pt}{0pt}[0pt]
\titleformat{\section}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}\hfill}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\section}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsection}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\subsection}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsubsection}[runin]{}{\thesubsubsection}{0pt}{\bgroup\normalfont\textit{#1.}\egroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{etoc}
\etocstandardlines % `line entries' as without \usepackage{etoc}
\etocstandarddisplaystyle % `toc display' as without \usepackage{etoc}
\etocsetnexttocdepth{subsection}
\etocnopar% same as \etocinline; switched back off by \etocdisplay
\etocsettocstyle{\vspace*{0.5in}% 1.5in from top edge of page
\begin{centering}\MakeUppercase{\contentsname}\\\end{centering}%
\ifvmode\message{YES IN VMODE}\else\message{NO NOT IN VMODE}\fi
}% Leave/exit/end in vertical mode, p.65
{\vspace{2\baselineskip}}
\makeatletter
\newcommand*{\Dots}{%
\nobreak\leaders\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}%
\hfill\nobreak
}%
\newcommand*{\DotsAndPage}{%
\hskip 2mm\Dots\hskip2mm%
\makebox[\width][r]{\normalsize\etocpage}\par}%
%
\etocsetstyle{part}% hlevelnamei
{\parindent 0pt% hstarti
\singlespacing
\nobreak
}%
{\pagebreak[3]\vspace{\baselineskip}}% hprefixi
{% hcontentsi
\normalfont\rmfamily\scshape
\rlap{\vbox to 0pt{\hrule width\textwidth height 0pt depth 1.75pt}}%
\etocname\par}%
{}% hfinishi
\etocsetstyle{chapter}%
{\leftskip 0pt\rightskip .75cm \parfillskip-\rightskip% hstarti
\singlespacing
\nobreak%\vspace{\baselineskip}%\medskip
\etocskipfirstprefix
}%
{\leftskip 0pt\rightskip .75cm \parfillskip-\rightskip% hprefixi
\pagebreak[1]}%\smallskip}%
{\normalfont\normalsize\rmfamily % hcontentsi
\if@newlist (Please run TeX again)\else\etoclink{%
\etocifnumbered{CHAPTER~%
\noexpand\protect
\noexpand\NUMBERstringnum{\protect\etocthenumber}%
\char`:{}\quad\protect}{}\etocthename}\DotsAndPage\fi}%
{\parfillskip 0pt plus 1fil\relax}% hfinishi
\etocsetstyle{section}%
{\leftskip1cm\rightskip .75cm \parfillskip-\rightskip
\singlespacing
\nobreak}%\vspace{\baselineskip}}%\smallskip}%
{}%{\par\vspace{\baselineskip}}% hprefixi
{\normalfont\normalsize\rmfamily% hcontentsi
\etocname\hskip 2mm\Dots\hskip 2mm%
\makebox[\width][r]{\normalsize \etocnumber, p.{} \etocpage}\par}%
{\par\vspace{\baselineskip}}%\medskip}% hfinishi
\etocsetstyle{subsection}%
{\leftskip2cm\rightskip .75cm\parfillskip-\rightskip
\parfillskip 0pt plus 1fil\relax% hstarti
\singlespacing
\nobreak\etocskipfirstprefix}%\vspace{\baselineskip}}%\smallskip}%
{\par\vspace{\baselineskip}}% hprefixi
{\normalfont\normalsize\rmfamily\itshape% hcontentsi
\etocname\hskip 2mm\Dots\hskip 2mm%
\makebox[\width][r]{\normalfont\normalsize\etocnumber, p.{} \etocpage}\par}%
{\par\vspace{\baselineskip}}%\medskip}% hfinishi
\def\mytocpage{%
\begingroup
\tableofcontents
\endgroup
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\dummypoem{%
\poemtitle[(short form of title)]{A Placeholder Rhyme}
\settowidth{\versewidth}{I sort of hate my life right now}%
\begin{verse}[\versewidth]
\begin{altverse}
I sort of hate my life right now;\\
I haven't slept in days.\\
I'm two weeks past my deadlines,\\
so I might not graduate.\\!
\end{altverse}
\end{verse}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\poemtoc}{chapter}
\begin{document}
\mytocpage
\part{(name of p1)}
\lipsum[1]\par
\chapter{(name of p1c1)}
\lipsum[2]\par
\section{(name of p1c1s1)}
\lipsum[3]\par
\subsection{(name of p1c1ss1)}
\lipsum[4]\par
\subsubsection{(name of p1c1ss1sss1)}
\lipsum[5]\par
\appendix % and/or
\part{APPENDICES}% and/or
\begin{appendices}% see `appendix` package options that I commented out
\chapter{(name of appendix a)}
\section{a.s1}
\lipsum[1]\par
\subsection{a.s2}
\lipsum[2]\par
\end{appendices}
\end{document}
注意:我以前用过附录和目录,但不是在使用etoc
TeX 时用过的。我知道如何以正常方式使用。
答案1
我将 CHAPTER 替换为 ,\protect\MakeUppercase\chaptername
然后将其更改\chaptername
为 附录\addtocontents
。更改仅限于目录。
\documentclass{report}
\usepackage[lmargin=1.5in,rmargin=1in,tmargin=1in,bmargin=1in,nohead,twoside=false]{geometry}
\usepackage{lipsum}
\usepackage{fmtcount}
\usepackage{setspace}
\usepackage{verse}
\usepackage[backend=biber,%
%backref=true,%
style=mla-new,autocite=footnote,firstlonghand=false,annotation=false,mladraft=true,hyperref=true]{biblatex}
\usepackage{makeidx}
\usepackage{varioref}% Load before hyperref
\usepackage[pdfpagelabels,linktoc=all]{hyperref}
\usepackage[nomain,translate=babel]{glossaries}
\usepackage{cleveref}
%\usepackage{etoc}% Moved below
\usepackage[indentafter,explicit,nobottomtitles*]{titlesec}
%\usepackage[page,toc,title,titletoc]{appendix}
%\usepackage[title]{appendix}
\usepackage{appendix}
\newdimen\myparindent
\myparindent=18pt\relax
\titleformat{\chapter}[block]{%
\begingroup\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}{CHAPTER \NUMBERstringnum{\value{chapter}}\\\hfill\\#1\\}%
{0pt}{\end{centering}\endgroup\doublespacing\vspace{\baselineskip}}
\titlespacing{\chapter}{0pt}{0pt}{0pt}[0pt]
\titleformat{\section}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}\hfill}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\section}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsection}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\subsection}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsubsection}[runin]{}{\thesubsubsection}{0pt}{\bgroup\normalfont\textit{#1.}\egroup}
\titlespacing{\subsubsection}{\myparindent}{0pt}{1.3\fontdimen2\font plus1.3\fontdimen3\font minus1.3\fontdimen4\font}
\titleformat{\part}[block]{%
\begin{minipage}[c][9in]{6in}%
\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}%
{\MakeUppercase{#1}}%
{0pt}%
{\\\end{centering}\end{minipage}}
\titlespacing{\block}{0pt}{0pt}{0pt}[0pt]
\titleformat{\chapter}[block]{%
\begingroup\normalfont\parskip=0pt%
\rmfamily\singlespacing\begin{centering}%
}{CHAPTER \NUMBERstringnum{\value{chapter}}\\\hfill\\#1\\
}{0pt}{\end{centering}\endgroup\doublespacing\vspace{\baselineskip}}
\titlespacing{\chapter}{0pt}{0pt}{0pt}[0pt]
\titleformat{\section}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}\hfill}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\section}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsection}[block]{\begingroup\normalfont\rmfamily\singlespacing\parskip=0pt\vspace{2\baselineskip}}{\itshape #1}{0pt}{\hfill\vspace{\baselineskip}\endgroup\parindent=\myparindent}
\titlespacing{\subsection}{0pt}{0pt}{0pt}[0pt]
\titleformat{\subsubsection}[runin]{}{\thesubsubsection}{0pt}{\bgroup\normalfont\textit{#1.}\egroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{etoc}
\etocstandardlines % `line entries' as without \usepackage{etoc}
\etocstandarddisplaystyle % `toc display' as without \usepackage{etoc}
\etocsetnexttocdepth{subsection}
\etocnopar% same as \etocinline; switched back off by \etocdisplay
\etocsettocstyle{\vspace*{0.5in}% 1.5in from top edge of page
\begin{centering}\MakeUppercase{\contentsname}\\\end{centering}%
\ifvmode\message{YES IN VMODE}\else\message{NO NOT IN VMODE}\fi
}% Leave/exit/end in vertical mode, p.65
{\vspace{2\baselineskip}}
\makeatletter
\newcommand*{\Dots}{%
\nobreak\leaders\hbox{\bfseries\normalsize\hbox to .75ex {\hss.\hss}}%
\hfill\nobreak
}%
\newcommand*{\DotsAndPage}{%
\hskip 2mm\Dots\hskip2mm%
\makebox[\width][r]{\normalsize\etocpage}\par}%
%
\etocsetstyle{part}% hlevelnamei
{\parindent 0pt% hstarti
\singlespacing
\nobreak
}%
{\pagebreak[3]\vspace{\baselineskip}}% hprefixi
{% hcontentsi
\normalfont\rmfamily\scshape
\rlap{\vbox to 0pt{\hrule width\textwidth height 0pt depth 1.75pt}}%
\etocname\par}%
{}% hfinishi
\etocsetstyle{chapter}%
{\leftskip 0pt\rightskip .75cm \parfillskip-\rightskip% hstarti
\singlespacing
\nobreak%\vspace{\baselineskip}%\medskip
\etocskipfirstprefix
}%
{\leftskip 0pt\rightskip .75cm \parfillskip-\rightskip% hprefixi
\pagebreak[1]}%\smallskip}%
{\normalfont\normalsize\rmfamily % hcontentsi
\if@newlist (Please run TeX again)\else\etoclink{%
\etocifnumbered{\protect\MakeUppercase{\chaptername}~%
\noexpand\protect
\noexpand\NUMBERstringnum{\protect\etocthenumber}%
\char`:{}\quad\protect}{}\etocthename}\DotsAndPage\fi}%
{\parfillskip 0pt plus 1fil\relax}% hfinishi
\etocsetstyle{section}%
{\leftskip1cm\rightskip .75cm \parfillskip-\rightskip
\singlespacing
\nobreak}%\vspace{\baselineskip}}%\smallskip}%
{}%{\par\vspace{\baselineskip}}% hprefixi
{\normalfont\normalsize\rmfamily% hcontentsi
\etocname\hskip 2mm\Dots\hskip 2mm%
\makebox[\width][r]{\normalsize \etocnumber, p.{} \etocpage}\par}%
{\par\vspace{\baselineskip}}%\medskip}% hfinishi
\etocsetstyle{subsection}%
{\leftskip2cm\rightskip .75cm\parfillskip-\rightskip
\parfillskip 0pt plus 1fil\relax% hstarti
\singlespacing
\nobreak\etocskipfirstprefix}%\vspace{\baselineskip}}%\smallskip}%
{\par\vspace{\baselineskip}}% hprefixi
{\normalfont\normalsize\rmfamily\itshape% hcontentsi
\etocname\hskip 2mm\Dots\hskip 2mm%
\makebox[\width][r]{\normalfont\normalsize\etocnumber, p.{} \etocpage}\par}%
{\par\vspace{\baselineskip}}%\medskip}% hfinishi
\def\mytocpage{%
\begingroup
\tableofcontents
\endgroup
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\dummypoem{%
\poemtitle[(short form of title)]{A Placeholder Rhyme}
\settowidth{\versewidth}{I sort of hate my life right now}%
\begin{verse}[\versewidth]
\begin{altverse}
I sort of hate my life right now;\\
I haven't slept in days.\\
I'm two weeks past my deadlines,\\
so I might not graduate.\\!
\end{altverse}
\end{verse}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\poemtoc}{chapter}
\begin{document}
\mytocpage
\part{(name of p1)}
\lipsum[1]\par
\chapter{(name of p1c1)}
\lipsum[2]\par
\section{(name of p1c1s1)}
\lipsum[3]\par
\subsection{(name of p1c1ss1)}
\lipsum[4]\par
\subsubsection{(name of p1c1ss1sss1)}
\lipsum[5]\par
\appendix % and/or
\addtocontents{toc}{\string\def\string\chaptername{Appendix}}
\part{APPENDICES}% and/or
\begin{appendices}% see `appendix` package options that I commented out
\chapter{(name of appendix a)}
\section{a.s1}
\lipsum[1]\par
\subsection{a.s2}
\lipsum[2]\par
\end{appendices}
\end{document}