2017-01-03 6 views
0

私は番号付きと番号なしの両方の章を持つ文書を持っています。目次でそれらを互いに区別するために、番号を付されていない章をイタリック体で表示したいと思います。私のMWEは章のタイトルで動作します - どのように対応するページ番号をイタリック体でフォーマットできますか?TOCで番号の付いていない章をフォーマットする

また、パート1のエントリを中央に置くことは可能ですか?

\documentclass[a4paper, 12pt]{report} 

\usepackage[titles]{tocloft} 

\begin{document} 
\tableofcontents 

\part{Part 1} 

\chapter{Numbered chapter} 

\chapter*{Unnumbered chapter} 
\addcontentsline{toc}{chapter}{\textit{Unnumbered chapter}} 

\end{document} 

答えて

1

あなたは自然に\addtocontents{toc}を使用して手動で\addcontentslineによって行われているものを書くことができます。彼らは通常、新しいページで設定し、それゆえされているので

enter image description here

\documentclass{report} 

\usepackage[titles]{tocloft} 

\begin{document} 

\tableofcontents 

\chapter{Numbered chapter} 

\chapter*{Unnumbered chapter} 
\addtocontents{toc} 
    {\protect\contentsline{chapter}{\textit{Unnumbered chapter}}{\textit{\thepage}}} 

\end{document} 

上記は\chapterのために働く必要があります\thepageが正しい値になります。ただし、hyperrefでは動作しません。また

、目次エントリの新しいタイプを定義するには、chapterstarと呼ばれる:

\documentclass{report} 

\usepackage[titles]{tocloft} 
\usepackage{etoolbox} 

\makeatletter 
\let\[email protected]\[email protected] 
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>} 
\patchcmd{\[email protected]}{\cftchapfont}{\cftchapstarfont}{}{}% Insert starred chapter font 
\patchcmd{\[email protected]}{#2}{\cftchapstarpagefont #2}{}{}% Insert starred chapter page number font 
\makeatother 

\newcommand{\cftchapstarfont}{\cftchapfont\itshape} 
\newcommand{\cftchapstarpagefont}{\cftchappagefont\itshape} 

\begin{document} 

\tableofcontents 

\chapter{Numbered chapter} 

\chapter*{Unnumbered chapter} 
\addcontentsline{toc}{chapterstar}{Unnumbered chapter} 

\end{document} 

上記溶液はhyperrefと連携し、より一般的です。

関連する問題