目录中有单独的列(在回忆录中)

目录中有单独的列(在回忆录中)

我很好奇是否有办法在目录中再添加一列数字。我尝试排版的书有一列章节和节标题,一列对应的小节编号范围,以及一列对应的页码。因此,例如,对于第一章第一节,其中包含第一至第五小节,位于第 2 页,该行应为:

1.1 章节标题..... 1-5 ... 2

我查看了memoirtitletoc文档,但无济于事。输出应如下所示:

我正在尝试创建的目录示例:1)章节编号和名称、2)章节、3)页面的列

答案1

我们可以用 来做到这一点etoc,尽管它并不完全简单。

答案底部添加了一个修订版本:它稍微简化了编码,并努力使其更接近原始版本。请注意,此处的代码中的\bfseries不起作用\textsc

Font shape `OT1/cmr/bx/sc' undefined 
using `OT1/cmr/bx/n' instead

但是使用 T1 编码它可以工作,所以我在第二个提案中使用它。

\documentclass{memoir}

\renewcommand{\thechapter}{\Roman{chapter}}
\counterwithout{section}{chapter}

\usepackage{etoc}
\usepackage{color}

% \usepackage[linktoc=all]{hyperref} % try it, it works!
% \etoctoclines  % removed as it is unnecessary: styles for part, 
                 % chapter, and section are entirely re-defined below

\renewcommand\etoctoclineleaders{\hbox to .12\linewidth{\hss...\hss}}
\newif\iffirstextradone
\newif\ifsecondextradone

\etocsetstyle{part}
{}
{}
{\begin{center}\Large\bfseries PART \etocnumber
\ifsecondextradone\\\etocname.\fi\end{center}
\iffirstextradone\else
\mbox{}\hskip.72\linewidth\hbox to .23\linewidth
    {\textsc{\bfseries Sections.\hss Page.}}\par\fi
\firstextradonetrue}
{}

\etocsetstyle{chapter}
{}
{\par\noindent\etocifnumbered{\makebox[.1\linewidth][r]
    {\bfseries\etocnumber.}}{\hspace*{.1\linewidth}}}
{\hbox to .7\linewidth
    {\hspace{1em}\etocname\unskip\leaders\etoctoclineleaders\hss}%
\hbox to .15\linewidth{\hss\ifsecondextradone\etocifnumbered\etocpage%
{}\else\etocpage\fi}%
\hskip-.3\linewidth\leaders\etoctoclineleaders\hskip.2\linewidth
\hskip-.1\linewidth}
{}

\newbox\forsectionnumbers
\makeatletter
\etocsetstyle{section}
{\setbox\forsectionnumbers=\hbox to .1\linewidth
    \bgroup\hss\etocskipfirstprefix}
{\@gobble}
{\etocnumber---}
{\etocnumber\hss\egroup\colorbox{white}{\box\forsectionnumbers}\par
\ifsecondextradone\else
\begin{center}\bfseries Concord.\end{center}
\noindent \textsc{\bfseries Lesson.}\par\fi\secondextradonetrue
}
\makeatother

\begin{document}

\etocruledstyle[1]{\parbox{\linewidth}{\centering
\textsc{\Huge\MakeUppercase{Table of Contents}}\\
\rule{.2\linewidth}{2pt}}}

\tableofcontents*

\part{}

\chapter*{Introductory}
\addcontentsline{toc}{chapter}{Introductory}

\newcount\tempcount

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<8
\repeat

\chapter{Concord of Subject and Verb}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<17
\repeat

\chapter{Concord of Substantive and Adjective}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<22
\repeat

\chapter*{Concord of Relative and its Antecedent}
\addcontentsline{toc}{chapter}{Concord of Relative and its Antecedent}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<25
\repeat

\part{Government}

\chapter{The Accusative Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<30
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<37
\repeat

\chapter{Verbs governing two Accusatives}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<41
\repeat

\chapter{The Causal}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<49
\repeat

\chapter{The Instrumental Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<54
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<59
\repeat

\chapter{The Dative Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<65
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<71
\repeat

\chapter{The Ablative Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<75
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<86
\repeat

\chapter{The Locative Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<92
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<100
\repeat

\end{document}

不幸的是,\etocnumber宏不是可以应用\arabic或 的东西\Roman。因此,必须确保数字以所需的格式注册在 .toc 文件中。更新\thechapter即可。

我还利用了这里非常方便的memoir命令\counterwithout来按需要对各个部分进行编号(我必须查阅手册,memoir因为我不熟悉该类)。

最后,我不得不使用一些\addcontentsline命令手动将未编号的章节放入 toc 文件中。

设置etoc部分、章节和节的样式有点微妙,我使用了一两个技巧来获得所需的外观。


更新:关于代码的一些解释。

指定etoc一个样式,用于在目录中实际显示的每个节级,即此处的部分、章节、节。该命令\etoctoclines将使用包预定义的样式,但此处我们需要重新定义所有样式(部分、章节和节)。即使这里没有明确要求重新定义所有样式,但通常这也是必要的,因为预定义样式(例如,期望以“垂直模式”启动)会限制重新定义的内容。因此,通常必须重新定义所有使用的样式(可以按照手册中的说明自定义预定义样式,而不是重新定义)。

因此,对于每个部分、章节或节,都会执行\etocsetstyle{part or chapter or section}{A}{B}{C}{D}where BC,并且在开始时执行一次 A ,在结束时执行一次 D 。这意味着章节中的第一节(如果中间没有章节,则为部分中的第一节)执行 A 和 B 和 C ,章节中的最后一节执行 B 和 C 和 D ,其余的执行 B 和 C 。

B 和 C 部分应该由\etocname\etocnumber和组成\etocpage。当存在 hyperref 时,它们都是超链接(对于页码,如果linktoc=all是 hyperref 选项)。将 B 和 C 分开的原因是有时人们希望跳过第一部分的 B。对于这一部分,使用命令 结束\etocskipfirstprefixA。

这里,部分线样式 B 用于做一个小把戏:它被设置为gobbleC,但正如我们使用的,\etocskipfirstprefix结果是除了第一个之外,所有部分编号确实都被吞噬了。然后最后一节的 D 放入缺失的(被吞噬的)最终节编号。A 打开了一个框,然后由 D 关闭,并由 D 打印。这是使用颜色框擦除之前由章节样式打印的点...

部分和章节的代码使用了一些技巧来向目录添加“额外的装饰”,中断其正常流程以设置LessonsSectionsPage标题。

章节行样式中\unskipafter的原因是使用了包,并且和中的每个 都以 结尾。有时必须取消其效果,在 leader 之前似乎就是这种情况。\etocnameetocxspace\etocname\etocnumber\etocpage\xspace


上面我讨论了“行样式”,现在讨论的是目录的标题及其全局样式:它是打印在一列还是两列中?它是否将其名称添加到 .toc 文件中?等等...

这里我使用了(我没多想,其他一些包命令可能也适用)命令\etocruledstyle,并带有参数[1]来表示我们在一列上(默认为两列)。使用该命令的原因是它将参数居中,而不是因为其名称中的“规则”:通常该命令在每侧放置两个水平规则,但这里使用最大宽度的 parbox 我们取消了这些规则。然后明确将规则添加到 parbox 的定义中。

总的来说,代码使用了很多TeX看起来的东西,原因很简单,我从来不记得LaTeX盒子和规则的命令,而且当我尝试使用它们时我经常遇到问题,所以我总是回到\hbox过去\rule......

很好的目录

\documentclass[letterpaper]{memoir}
\usepackage[T1]{fontenc}
%\usepackage{layout}
% I am just ignorant of the memoir commands to set up
% the page parameters. I just want my text centered on the page.
\setlength{\textwidth}{5.5in}
\setlength{\oddsidemargin}{.5in}
\setlength{\evensidemargin}{.5in}

\renewcommand{\thechapter}{\Roman{chapter}}
\counterwithout{section}{chapter}

\usepackage{etoc}
\usepackage{color}
% \usepackage[linktoc=all]{hyperref}

\newif\ifextraidone
\newif\ifextraiidone

\etocsetstyle{part}
{}
{}
{\begin{center}\Large\bfseries PART \etocnumber
\ifextraiidone\\\etocname.\fi\end{center}
\ifextraidone\else
\noindent\hskip.7\linewidth
    \hbox to .2\linewidth
    {\hss\small\textsc{\bfseries Sections.\ Page.}}\par\fi
\extraidonetrue
}
{}

\newcommand\mytocleaders{\hbox to .125\linewidth{...\hss}}
\etocsetstyle{chapter}
{}
{\par\noindent\etocifnumbered
    {\makebox[.15\linewidth][r]{\bfseries\etocnumber.}}
    {\hspace*{.15\linewidth}}}
{\hbox to .65\linewidth
    {\hspace{1em}\etocname\unskip\leaders\mytocleaders\hss}%
 \hskip-.1\linewidth
 \hbox to .2\linewidth{\hspace{1.5em}...\hss
                \etocifnumbered
                    {\etocpage}
                    {\ifextraiidone\else\etocpage\fi}}%
 \hskip-.2\linewidth
}
{}

\newbox\forsectionnumbers
\makeatletter
\etocsetstyle{section}
{\setbox\forsectionnumbers=\hbox to .1\linewidth
    \bgroup\hss\etocskipfirstprefix}
{\@gobble}
{\etocnumber---}
{\etocnumber\egroup
% for reasons I do not quite understand, in some pdf viewers the dots
% do not completely disappear if here \fboxsep0pt is used.
    \fboxsep1pt\colorbox{white}{\box\forsectionnumbers}\par
    \ifextraiidone\else
        \begin{center}\bfseries Concord.\end{center}
        \noindent\makebox[.15\linewidth][r]{\textsc{\bfseries Lesson.}}\par
    \fi\extraiidonetrue
}
\makeatother

\begin{document}%\layout

\renewcommand{\etocinnertopsep}{0pt}

\etocruledstyle[1]{%
    \parbox{\linewidth}{%
        \centering
        \textsc{\bfseries\LARGE\MakeUppercase{Table of Contents}}\\
        \rule{.2\linewidth}{2pt}}%
}

\tableofcontents*

\part{}

\chapter*{Introductory}
\addcontentsline{toc}{chapter}{Introductory}

\newcount\tempcount

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<8
\repeat

\chapter{Concord of Subject and Verb}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<17
\repeat

\chapter{Concord of Substantive and Adjective}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<22
\repeat

\chapter*{Concord of Relative and its Antecedent}
\addcontentsline{toc}{chapter}{Concord of Relative and its Antecedent}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<25
\repeat

\part{Government}

\chapter{The Accusative Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<30
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<37
\repeat

\chapter{Verbs governing two Accusatives}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<41
\repeat

\chapter{The Causal}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<49
\repeat

\chapter{The Instrumental Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<54
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<59
\repeat

\chapter{The Dative Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<65
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<71
\repeat

\chapter{The Ablative Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<75
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<86
\repeat

\chapter{The Locative Case}

\chapter*{General uses}
\addcontentsline{toc}{chapter}{General Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<92
\repeat

\chapter*{Particular uses}
\addcontentsline{toc}{chapter}{Particular Uses}

\loop\advance\tempcount by 1
\section{This is}
section \the\tempcount
\ifnum\tempcount<100
\repeat

\end{document}

注意:通过在之前的内容上放置彩色框来擦除之前内容的技巧并不完美;它似乎取决于所使用的 PDF 查看器。在 Acrobat 中,可以,但在 mac os 上,使用 Skim 时,点会保留下来,尽管很模糊。可能是一些透明度问题,我想我在其他地方看到过对此的讨论。

实际上使用\fboxsep1pt而不是\fboxsep0pt之前 \colorbox可以解决这个问题。我不确定我是否理解为什么它不能与 一起使用\fboxsep0pt

无论如何,结果是未经修剪的,与 OP 的原文相比:

精细调整目录

相关内容