1

The part title in my case does not need a part number. I use already an \DeclareTOCStyleEntryand would like to remove the part number. using\nullfont` does the trick, but the result is indented. To counteract with a negative indent seems not a good solution. What is better?

p.s. why does \gobble not work?

\documentclass{scrbook}
\KOMAoptions{paper=      
    128.5mm:198.4mm, %(5,06" x 7,91")  %ziel
    DIV=9,  %ziel kleines buch 
    fontsize=12pt,
}

%%%% Sprache
\usepackage[german]{babel}  %scheint 

%%%%% table of content
\setcounter{tocdepth}{0} %   1 gibt parts und chapter und sections

\DeclareTOCStyleEntry[
    indent=-2em,
    entryformat=\mdseries\Large,
    entrynumberformat=\nullfont, % \gobble,
    pagenumberformat=\normalfont\normalsize, 
    onstarthigherlevel=\vskip   ]{tocline}{part}
\DeclareTOCStyleEntry[
    indent=2em,
    pagenumberformat=\normalfont,
    beforeskip=1pt plus .2pt,
    entryformat=\normalfont
    ]{tocline}{chapter}

\begin{document}
    \frontmatter
        \tableofcontents
    \mainmatter
        \part{ Philosophie}
        \chapter{  \textit{Vom Schreiben}}
        \chapter{Zwei}
\end{document}

2 Answers 2

1

If you don't want to have parts without numbers but with an entry in the toc you should use the \addpart directive instead of \part or \part*.

Indenting the toc entries is indeed bad typography.

Ragarding gobble. gobble is the name of a specific style of toc entries. In your example you choose the tocline style. But there are even more styles available as the reference manual of koma will tell you. Keep in mind that not all options that are set with DeclareTOCStyleEntry are available for every style. This is also described in the manual.

In the following example a few settings are combined to get a clean looking table of contents.

enter image  here

\documentclass[10pt]{scrbook}

\KOMAoptions{paper=      
    128.5mm:198.4mm, %(5,06" x 7,91")  %ziel
    DIV=9,  %ziel kleines buch 
    fontsize=11pt,
}

%%%% Sprache
\usepackage[german]{babel}  %scheint 
\usepackage{eqparbox}

\setkomafont{chapterentry}{\small}

%%%%% table of content
\setcounter{tocdepth}{0} %   1 gibt parts und chapter und sections

\DeclareTOCStyleEntry[
    % bad typography
    % indent           = -2em,
    entryformat       = {\sffamily\bfseries Part\hskip 2.5ex},
    beforeskip        = 2.25em plus 1pt,
    %entrynumberformat = \nullfont,
    %pagenumberformat  = \normalfont,
    pagenumberbox     = \phantom,
    %
    % onstartentry and onstarthigherlevel are not defined for
    % for 'tocline'
    %
    %onstarthigherlevel = \vskip,
    %onstartentry = Teil
]{tocline}{part}

\DeclareTOCStyleEntry[
    % bad typography
    % indent          = 2em,
    % pagenumberformat = \normalfont,
    beforeskip       = 1em plus 1pt,
    %entryformat      = \normalfont,
    linefill         = \dotfill
]{tocline}{chapter}

\renewcommand*\partpagestyle{empty}

\begin{document}

\frontmatter
\begingroup
    \setkomafont{chapter}{\large\bfseries\sffamily}
    \setkomafont{chapterentry}{\sffamily}
    %\setkomafont{disposition}{\sffamily\itshape}
    \tableofcontents
\endgroup
\mainmatter
\addpart{Philosophie}
\chapter{Vom Schreiben}
\chapter{Zwei}
\addpart{Kilosophie}
\chapter{Vom Schreiben}
\chapter{Zwei}

\end{document}
5
  • Thank you for your clean solution. Why do you use a `\begingroup in the document? I would have prefered all the settings in the preamble. Other question: what is the reason to express the skip as 1em plus 1pt?
    – user855443
    Apr 19, 2020 at 16:08
  • onstarthigherlevel is defined for tocline. But it does nothing for part entries because there is no lower level (level < -1) than the TOC level of part. So a part entry can not be a on a higher level than the last entry before. onstartentry is not defined for tocline, but it was not in the original MWE.
    – esdd
    Apr 19, 2020 at 16:32
  • @user855443 All changes that take place between \begingroup and \endgroup are contained in this scope. So if i want to change the chapter font only in the table of contents i can set the font inside a group. The changes are automatically forgotten if tex steps outside the group. If you want to move the code to the preamble you can create a corresponding command. Apr 19, 2020 at 17:43
  • @user855443 The expression 1em plus 1pt consists of the ideal spacing (1em) and the flexible part (plus 1pt) called glue. With the additional specification of glue you tell latex that you don't mind if the actual spacing is 1em + 1pt and not exactly 1pt. This in turn gives latex more flexibility in typesetting your page. Apr 19, 2020 at 17:55
  • beforeskip=1em plus 1pt is the initial setting for chapter entries. Different font settings for the TOC header can be done in the preamble using \BeforeTOCHead[toc]{\setkomafont{chapter}{<font commands>}}. Without the optional argument [toc] it would be also used for lists under control of package tocbasic (eg. LoF and LoT).
    – esdd
    Apr 20, 2020 at 6:48
1

KOMA-Script does not provide \gobble - so it is undefined in your MWE.

Do you really want to remove the part number only in TOC, but not in the document? Then you can define a new command that takes one argument and does nothing:

\newcommand*\hideentrynumber[1]{}

Use this macro as value for option entrynumberformat

entrynumberformat=\hideentrynumber.

To remove the space reserved for the part number, you have to set the number width to 0pt:

numwidth=0pt

Example:

\documentclass{scrbook}
\KOMAoptions{
  paper=128.5mm:198.4mm,
  fontsize=12pt,
  DIV=9% last option -> recalculates typearea
}
\usepackage[german]{babel}% wirklich die alte Rechtschreibung?

\setcounter{tocdepth}{\chaptertocdepth}% only parts and chapters in ToC

\newcommand*\hideentrynumber[1]{}
\DeclareTOCStyleEntry[
    entryformat=\mdseries\Large,
    entrynumberformat=\hideentrynumber,
    numwidth=0pt,
    pagenumberformat=\normalfont\normalsize
  ]{tocline}{part}
\DeclareTOCStyleEntry[
    indent=1em,% decreased to 1em, but: do you really want to indent chapter entries?
    pagenumberformat=\normalfont,
    beforeskip=1pt plus .2pt,
    entryformat=\normalfont
    ]{tocline}{chapter}

\begin{document}
\layout
\frontmatter
\tableofcontents
\mainmatter
\part{Philosophie}
\chapter{\textit{Vom Schreiben}}
\chapter{Next Chapter}
\part{Next Part}
\chapter{Foo}
\chapter{Bar}
\end{document}

enter image description here

Additional remark: I have removed onstarthigherlevel=\vskip because there was no dimension given for the skip. But even if there would be something like onstarthigherlevel=\vskip 1em, if would do nothing: KOMA-Script does not provide a lower level than part, ie the level of part is -1 and there are no ToC levels ≤-2. Maybe you want to change the beforeskip for the part entry? Default is 2.25em plus 1pt.

1
  • Thank you for your clean solution and the comments. Indeed, I wonder if I want to remove the part numbers or not. Perhaps I change to bigger and gray, to reflect how they appear on the parts titel pages.
    – user855443
    Apr 19, 2020 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .