新列表中的间距

新列表中的间距

我正在尝试为 制作一个漂亮的目录 (toc) {book}。我的书中有一个表格列表和一个新列表,它们都出现在目录中。

当列表中的项目编号多于一位数字时,需要调整间距以防止项目部分编号碰到项目名称。

我在序言中使用\setlength{\cftsecnumwidth}{3em}/\setlength{\cfttabnumwidth}{3em}来更改章节 / 表格列表的间距,效果很好。

有/无调整

但我仍然需要调整新列表的间距

我努力了

\setlength{\cftscinumwidth}{3em} 在新列表中调整间距,但\cftscinumwidth定义不太明确,所以这不起作用。

我如何控制新列表中的间距?

代码

\documentclass{book}
\usepackage{float}
\usepackage{tocloft}
\setlength{\cftsecnumwidth}{3em} % sets space in section numbering
\setlength{\cfttabnumwidth}{3em} % sets space in table numbering 
% \setlength{\cftscinumwidth}{3em} % ERROR % sets space in scientists numbering 

\newlistof{scientists}{sci} {\listscientisttitle} 
\newcommand \listscientisttitle {List of Scientists}
\newcommand \scientistlist [1]  {%
  \refstepcounter{scientists}
  \addcontentsline{sci}{scientists}
  {\protect\numberline{\thechapter.\thescientists} #1}%
}
\newcommand \scientist [1] {\scientistlist{#1}{\underline{Scientist}: #1}}

\begin{document}
\frontmatter
\tableofcontents

\listoftables
\addcontentsline{toc}{chapter}{\listtablename}

\listofscientists
\addcontentsline{toc}{chapter}{\listscientisttitle}

\mainmatter
\chapter{some chapter}
\setcounter{section}{332}
\section{some section}
\paragraph{some paragraph}~\\
\setcounter{table}{332}
\begin{table}[H]
  \centering
  \caption{some table}
  \begin{tabular}{|c|c|c|}
    \hline 9 & 44 & 55 \\ \hline
  \end{tabular}   
\end{table}                     
\setcounter{scientists}{332}
\scientist{Mr Black (200--280)}
\end{document}

答案1

    \documentclass{book}
%   Packages        %
    \usepackage{float}                  %  Tables
    \usepackage{tocloft}                    %  Table of Contents
        \setlength{\cftsecnumwidth}{3em}            %%  sets space in section numbering
        \setlength{\cfttabnumwidth}{3em}            %%  sets space in table numbering
%   New Commands
\newlistof{scientists}{sci} {\listscientisttitle}
\newcommand \listscientisttitle     {List of Scientists}
\newcommand \scientistlist  [1] {\refstepcounter{scientists}
                            \addcontentsline{sci}{scientists}{\protect\numberline{\thechapter.\thescientists}#1}}
\newcommand \scientist      [1] {\scientistlist{#1}{\underline{Scientist}: #1}}
  \setlength{\cftscientistsnumwidth}{3em}    % Length must be defined before it can be set - it isn't defined until you've created the new list
  \setlength{\cftscientistsindent}{\cfttabindent}
\begin{document}
\frontmatter{}      %%              FRONT MATTER                %%
    \tableofcontents{}
        \listoftables{}     \addcontentsline{toc}{chapter}{\listtablename}
        \listofscientists{} \addcontentsline{toc}{chapter}{\listscientisttitle}

\mainmatter{}       %%              MAIN MATTER                 %%
\chapter{some chapter}
\setcounter{section}{332}   \section{some section}
%                         \paragraph{some paragraph}~\\
\setcounter{table}{332} \begin{table}[H]\centering  \caption{some table}
                        \begin{tabular}{|c|c|c|}
                            \hline      9   &   44  &   55      \\
                            \hline
                        \end{tabular}
                    \end{table}
\setcounter{scientists}{332}
\scientist{Mr Black (200--280)}
\end{document}

黑色的空间

相关内容