我想知道如何在目录中以小节级别显示附录部分(B.1、B.2)。
梅威瑟:
% % % % % % % % % % % % Packages % % % % % % % % % % % % % % %
\documentclass[11pt,a4paper]{report}
\usepackage[english]{babel} % english language
\usepackage[latin1]{inputenc} % accents in source
\usepackage[T1]{fontenc} % accents in DVI
\usepackage{vmargin} % redefine the margins
\setmarginsrb{2.5cm}{1.5cm}{2.5cm}{1cm}{0cm}{0cm}{0cm}{1cm}
\usepackage{appendix}
\usepackage[
hyperindex=true, % add links in the index
bookmarks=true, % show bookmarks bar when displaying the document}{hyperref}
]{hyperref}
\hypersetup{
colorlinks=true, % colored links
breaklinks=true, % allows return line in too long links
urlcolor= blue, % links color
linkcolor= blue, % internal links color
citecolor= blue, % green by defaut, color of citation links (bibliography)
bookmarksopen=true,
}
% code to show appendices' chapters at section level on TOC
\makeatletter
\newcommand\chapassect{%
\def\@chapter[##1]##2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{section}%
{\protect\numberline{\thechapter}##1}%
\else
\addcontentsline{toc}{section}{##1}%
\fi
\chaptermark{##1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{##2}]%
\else
\@makechapterhead{##2}%
\@afterheading
\fi}%
}
\makeatother
% % % % % % % % % % RAPPORT % % % % % % % % % % % % %
\renewcommand\setthesection{\Alph{section}}
\begin{document}
% table of contents
\tableofcontents
\newpage
% end table of contents
% chapter 1:
\chapter{Introduction}
\section{Problem overview}
\section{Application description}
\section{Work Goals}
\newpage
% end chapter 1
% appendices
\appendix
\clearpage % or \cleardoublepage
\appendixpage
\addappheadtotoc
% code to show appendices at section level in TOC
\chapassect
\begin{appendices}
\chapter{Installation requirements}
\chapter{Performance evaluation I appendix}
\section{Strahov}
\section{University laboratory}
\end{appendices}
% end appendices
\end{document}
请注意,我正在使用最后一段代码在目录中按节级别显示附录(A,B)。
答案1
我建议你采用一种新方法:现在,无需更改目录条目,只需更改附录中各部分单元的标题格式即可。在下面的例子中,我使用了titlesec
包定义一个\changesections
命令,使章节标题看起来像常规章节的标题,同样,小节标题看起来也像常规章节的标题:
\documentclass[11pt,a4paper]{report}
\usepackage{appendix}
\usepackage{titlesec}
\usepackage{chngcntr}
\usepackage[
hyperindex=true, % add links in the index
bookmarks=true, % show bookmarks bar when displaying the document}{hyperref}
]{hyperref}
\hypersetup{
colorlinks=true, % colored links
breaklinks=true, % allows return line in too long links
urlcolor= blue, % links color
linkcolor= blue, % internal links color
citecolor= blue, % green by defaut, color of citation links (bibliography)
bookmarksopen=true,
}
% code to make appendices' sections look like chapters and subsections like sections
% in the body of the document
\makeatletter
\newcommand\changesections{%
\renewcommand\thesection{\Alph{section}}
\counterwithin{figure}{section}
\counterwithin{table}{section}
\renewcommand\thefigure{\thesection.\arabic{figure}}
\titleclass{\section}{top}
\newcommand\sectionbreak{\cleardoublepage}
\titleformat{\section}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thesection}{20pt}{\Huge}
\titlespacing*{\section}
{0pt}{50pt}{40pt}
\titleformat{\subsection}
{\normalfont\Large\bfseries}{\thesubsection}{1em}{}
\titlespacing*{\subsection}
{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
}
\makeatother
\begin{document}
% table of contents
\tableofcontents
\newpage
% end table of contents
% chapter 1:
\chapter{Introduction}
\section{Problem overview}
\begin{figure}
\caption{test}
\end{figure}
\section{Application description}
\begin{figure}
\caption{test}
\end{figure}
\section{Work Goals}
\newpage
% end chapter 1
% appendices
\appendix
\clearpage % or \cleardoublepage
\appendixpage
\addappheadtotoc
\begin{appendices}
\changesections% change formatting for the sectional units
\section{Installation requirements}
\begin{figure}
\caption{test}
\end{figure}
\section{Performance evaluation I appendix}
\begin{figure}
\caption{test}
\end{figure}
\subsection{Strahov}
\subsection{University laboratory}
\end{appendices}
% end appendices
\end{document}