
TOC의 하위 섹션 수준에서 부록 섹션(B.1, B.2)을 표시하는 방법을 알고 싶습니다.
MWE:
% % % % % % % % % % % % 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
나는 여러분에게 새로운 접근 방식을 제안합니다. ToC 항목을 변경하는 대신 이제 부록의 섹션 단위에 대한 제목 형식을 변경하는 것이 더 쉽습니다. 다음 예에서는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}