目錄中小節層級的附錄部分

目錄中小節層級的附錄部分

我想知道如何在目錄中的小節層級顯示附錄的部分(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}

在此輸入影像描述

相關內容