更改目录外观

更改目录外观

考虑正常的目录:

在此处输入图片描述

来自这样的事情:

\documentclass{memoir}

\begin{document}
    \tableofcontents*
    \newpage
    \chapter{A chapter}
    \section{A section}
    \section{A longer named section}
    \newpage
    \chapter{Another chapter}
    \section{A section}
    \section{Yet another section}
    \section{And a really long section named which probably is so very long that
            some people might think is too long}
\end{document}

我能得到一些更像下面这样的东西吗?

                        Contents

           1  A chapter                 3          
               1.1            A section 3
               1.2       A longer named 3
                                section  

           2  Another chapter           5
               2.1            A section 5
               2.2  Yet another section 5
               2.3    And a really long 5
                    section named which 
                    probably is so very 
                         long that some 
                     people might think 
                         it is too long  

因此,名称不再用点填充,而是直接显示在页码的右侧。

答案1

如果有小节等,则必须通过适当的附加定义来完成。此外,为了与 兼容,需要比 更新或更旧memoir的版本。etoc1.07k

TOC 与 etoc

\documentclass{memoir}
% goal:

%                         Contents

%            1  A chapter                 3          
%                1.1            A section 3
%                1.2       A longer named 3
%                                 section  

%            2  Another chapter           5
%                2.1            A section 5
%                2.2  Yet another section 5
%                2.3    And a really long 5
%                     section named which 
%                     probably is so very 
%                          long that some 
%                      people might think 
%                          it is too long  

\usepackage{etoc}[2014/04/22]% 1.07l (or < 1.07k) needed for memoir compatibility

% these things being used either in bold or medium series contexts, better not
% to use em or ex for them.
\newcommand{\marginC}{15pt}% reserved space for chapter numbers
\newcommand{\marginS}{20pt}% reserved space for section numbers
\newcommand{\marginP}{15pt}% reserved space for page numbers

\newlength{\oldleftskip}

\etocsettocstyle{\leftskip .2\linewidth% to be customized
                 \rightskip.2\linewidth
                 \parindent   0pt\relax
                 \parfillskip 0pt plus 1fil\relax
         \markboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}% 
                 \noindent\hfil\Large\bfseries\contentsname\par
                 %
                 \normalsize\mdseries\bigskip
                         \advance\leftskip  \marginC\relax
                         \advance\rightskip \marginP\relax
                }{}

\etocsetstyle{chapter}
             {}
             {\parfillskip-\marginP\relax
              \bfseries
              \noindent\llap{\makebox[\marginC][l]{\etocnumber}}%
              \etocname\nobreak\hfill\makebox[\marginP][r]{\etocpage}\par 
              \smallskip}
             {}{}

\etocsetstyle{section}
             {\mdseries}
             {\leavevmode
                 \oldleftskip\leftskip
                 \parfillskip-\marginP\relax
              \makebox[\marginS][l]{\etocnumber}%
              \hfill\makebox[\marginP][r]{\etocpage}\par\nobreak
               \vspace{-\baselineskip}
              \leftskip \the\dimexpr\oldleftskip+\marginS\relax plus 1fil\relax
              \parfillskip 0pt\relax
              \etocname\par
              \leftskip\oldleftskip}
             {}{\medskip}



\begin{document}
    \tableofcontents*
    \newpage
    \chapter{A chapter}
    \section{And a really long named section which probably is so very long that
            some people might think is too long}
    \section{A section}
    \section{A longer named section}
    \newpage
    \chapter{Another chapter which has a long, very very long name}
    \section{A section}
    \section{Yet another section}
    \section{And a really long named section which probably is so very long that 
      some people might think is too long}
\end{document}

相关内容