我想将我的目录配置成这样的书籍文档:章节标题(黑色)之前的页码(红色)。
例如:
3 Down the Rabbit Hole
7 The Pool of Tears
15 The Caucus Race and a Long Tale
对于订单的配置,我已经看到了这个答案,它适用于回忆录文档,但不适用于书籍文档:
https://tex.stackexchange.com/posts/55669/revisions
本次修订的代码:
\documentclass{memoir}
% redefinition for the ToC title
\renewcommand\printtoctitle[1]{\HUGE\sffamily#1}
% redefinitions for chapter entries
\renewcommand\chapternumberline[1]{}
\renewcommand\cftchapterfont{\sffamily}
\renewcommand\cftchapterpagefont{\huge\sffamily}
\makeatletter
\newcommand\l@mychap[3]{%
\vskip2ex%
\par\noindent
\parbox{2.5em}{%
\hfill{\cftchapterpagefont#2}%
}\hspace*{3em}%
\parbox{\dimexpr\textwidth-5.5em-15pt\relax}{%
\cftchapterfont#1%
}\par%
}
\renewcommand*\l@chapter[2]{%
\l@mychap{#1}{#2}{\chaptername}%
}
\makeatother
\begin{document}
\tableofcontents*
\chapter{Down the Rabbit Hole}
\chapter{The Pool of Tears}
\chapter{The Caucus Race and a Long Tale}
\setcounter{page}{14}% just for the example
\end{document}
如何才能获得与乳胶书籍文档相同的结果?
我可以将目录中的页码声明为红色吗?
答案1
这是你的输出memoir
:
book
以下是建议的最小示例的输出:
\documentclass{book}
\usepackage{tocloft,xcolor}
% redefinition for the ToC title
\renewcommand{\cfttoctitlefont}{\Huge\sffamily}
% redefinitions for chapter entries
\renewcommand{\cftchappresnum}[1]{\makebox[\cftchapnumwidth][r]{%
\cftchappagefont
\raisebox{-.2\height}[0pt][0pt]{\color{red}\chappagenum}\quad}}
\renewcommand\cftchapfont{\sffamily}
\renewcommand\cftchappagefont{\huge\sffamily}
\setlength{\cftchapnumwidth}{5.5em}
\setlength{\cftbeforechapskip}{3ex}% Adjust to suit your needs
\cftsetpnumwidth{0pt}% Not really needed...
\makeatletter
\newcommand{\chappagenum}{}
\let\oldl@chapter\l@chapter
\renewcommand{\l@chapter}[2]{%
\renewcommand{\chappagenum}{#2}%
\oldl@chapter{#1}{}%
}
\makeatother
\begin{document}
\tableofcontents
\chapter{Down the Rabbit Hole}
\chapter{The Pool of Tears}
\chapter{The Caucus Race and a Long Tale}
\setcounter{page}{14}% just for the example
\end{document}
tocloft
用于操作与 ToC 相关的条目,因为它具有与memoir
提供的非常相似的用户界面。