定制目录

定制目录

我需要以一种非常具体的格式来格式化文章汇编的目录:

About this volume
Author 1
    Preface........................first page-last page

Articles

Author 2
    Title 2........................first page-last page
Author 3
    Title 3........................first page-last page
Author 4
    Title 4........................first page-last page

除了页码方面的细微差别外,它看起来应该像这样(德语)示例:

有谁知道如何做、使用什么包或者一些编码示例?

答案1

这是一个小例子,其中作者位于目录中并且有第一页到最后一页。

\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage[ngerman]{babel}

\makeatletter
\providecommand*{\addchap}[1]{% define if, if you are not using a KOMA-Script class
  \chapter*{#1}\markboth{#1}{}%
}

% document commands

\newenvironment{authorsection}[2][]{% optional arg = author; mandatory arg = title
  \cleardoublepage
  \addtocontents{toc}{\protect\startauthorsection{#1}{#2}{\thepage}}%
  \addchap{#2}% Don't use a number
}{%
  \addtocontents{toc}{\protect\finishauthorsection{\thepage}}%
}

\newcommand*{\addtocpart}[1]{% add something like a part but only start a new
                             % (odd) page and set up a toc-entry without page
                             % number
  \cleardoublepage
  \addtocontents{toc}{\protect\tocpart{#1}}%
}

\setcounter{tocdepth}{0}% only chapters at the table of contents
\setcounter{secnumdepth}{-1}% No chapter, section etc. numbers

% toc commands

\newcommand*{\aname}{}% needed to store author until end
\newcommand*{\stitle}{}% needed to store title until end
\newcommand*{\fpage}{}% needed to store page until end
\newcommand{\startauthorsection}[3]{% #1 = author, #2 = title, #3 = page
  \def\aname{#1}%
  \def\stitle{#2}%
  \def\fpage{#3}%
  \begingroup
    \let\l@chapter\@gobbletwo% deactivate chapter entries
}
\renewcommand*{\l@chapter}{%
  \addvspace{\baselineskip}%
  \@dottedtocline{0}{0pt}{1.5em}% use chapter entries with dots
}%
\newcommand*{\finishauthorsection}[1]{% #1 = page
  \endgroup% reactivate normal chapter entries
  \l@chapter{% make a chapter entry
    \normalfont% but with normal font
    \ifx\aname\@empty\unskip\else\mbox{\itshape\aname}\\\fi% show the author if there's any
    \stitle% show the title
  }{\fpage--#1}% and the page range
}

\newcommand*{\tocpart}[1]{%
  \addvspace{2\baselineskip}
  \setlength{\parindent}{0pt}
  \textbf{#1}\par
  \smallskip
}

% neeed more space for page numbers at toc:
\renewcommand*{\@pnumwidth}{3em}
\renewcommand*{\@tocrmarg}{4em}

\makeatother

\begin{document}
\tableofcontents

\addtocpart{Zu diesem Heft}

\begin{authorsection}[Rüdiger Lux]{Vorwort}
\lipsum
\end{authorsection}

\addtocpart{Beiträge}

\begin{authorsection}[Hans Seidel]{20 Jahre Forschungsstelle Judentum 1988--2008}
  \lipsum
\end{authorsection}

\begin{authorsection}[Harald Samuel]{Leipzig -- Jerusalem -- Rom\protect\\
Mit Hebräisch spielend unterwegs}
  \lipsum
  \section{Überschrift innerhalb der Geschichte}
  \lipsum
\end{authorsection}

\end{document}

我用过KOMA 脚本类,因为据我所知大多数德国人喜欢使用它们。但您可以用标准类替换它。虽然您评论说您正在使用\chapter,但我使用的是书籍类。您可以将其更改为报告类。但是如果您将其更改为文章类,则必须替换例如\addchapby \addsec\chapter*by \section*\sectionby \subsection\l@chapterby \l@section

答案2

如果你有兴趣更改目录,你可能会对titletoc包。您可以通过 向目录添加任意内容(如“Beiträge”)\addtocontents{toc}{ <something> },例如

\addtocontents{toc}{\bigskip \textbf{Beiträge} \par \smallskip }

. 可以使用

\addcontentsline{toc}{chapter}{Beitr{\"{a}}ge}

(其中chapter是相应级别,其他级别例如partsection)。

\dotfill \pageref{ first page of chapter label } -- \pageref{ last page of chapter label }

(其中,在第一章处放置一个标签,在每一章的末尾放置另一个标签)将创建条目的“...... 7-12”部分,以防您按照 创建所有内容\addcontentsline,但您可能希望一个包自动执行此操作(抱歉,我不知道有任何人这样做)。

相关内容