I want to customize my table of contents and lists of figures and tables using tocbasic
. I originally did these customizations with tocloft
. I managed to get almost everything done. However there are 2 issues remaining:
- Creating standalone styles instead of using the options to
tocline
- It seems the
dynnumwidth
andnumsep
options don't have any effect
I'd like to create a standalone style for each of chapter, section, subsection, subsubsection, figure, and table. I know there is \CloneTOCEntryStyle{tocline}{chapter}
but I don't think it is possible to clone it with the options set.
Below is a complete MWE.
\documentclass[fontsize=11pt]{scrreprt}
\usepackage[left=25mm,right=25mm,top=8.4mm,bottom=10.7mm%
,includeheadfoot,headsep=15.4mm,marginparwidth=18mm,marginparsep=4mm]%
{geometry}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\usepackage{blindtext}
\makeatletter
\newcommand*{\skillmon@chapter@dotfill}{%
\def\@dotsep{0.072}\TOCLineLeaderFill[\textbf{.}]%
}
\newcommand*{\skillmon@section@dotfill}{%
\def\@dotsep{0.072}\TOCLineLeaderFill%
}
\DeclareTOCStyleEntry[%
,beforeskip=1.15em plus 1pt%
,dynnumwidth=true% commenting out this doesn't change anything
,numsep=5pt% changing this to e.g. -5pt doesn't change anything
,linefill=\skillmon@chapter@dotfill%
,entryformat=\textbf%
,indent=0pt%
,level=0%
,pagenumberbox=\relax%
]{tocline}{chapter}
\DeclareTOCStyleEntry[%
,beforeskip=0pt plus .2pt%
,dynnumwidth=true%
,numsep=5pt%
,linefill=\skillmon@section@dotfill%
,indent=1.3em%
,pagenumberbox=\relax%
]{tocline}{section}
\DeclareTOCStyleEntry[%
,beforeskip=0pt plus .2pt%
,dynnumwidth=true%
,numsep=5pt%
,linefill=\skillmon@section@dotfill%
,indent=3.38em%
,pagenumberbox=\relax%
]{tocline}{subsection}
\DeclareTOCStyleEntry[%
,beforeskip=0pt plus .2pt%
,dynnumwidth=true%
,numsep=5pt%
,linefill=\skillmon@section@dotfill%
,indent=6.38em%
,pagenumberbox=\relax%
]{tocline}{subsubsection}
\DeclareTOCStyleEntry[%
,beforeskip=0pt plus .2pt%
,dynnumwidth=true%
,numsep=5pt%
,linefill=\skillmon@section@dotfill%
,indent=1.5em%
,pagenumberbox=\relax%
]{tocline}{table}
\DeclareTOCStyleEntry[%
,beforeskip=0pt plus .2pt%
,dynnumwidth=true%
,numsep=5pt%
,linefill=\skillmon@section@dotfill%
,indent=1.5em%
,pagenumberbox=\relax%
]{tocline}{figure}
\makeatother
\begin{document}
\tableofcontents
\listoftables
\listoffigures
\blinddocument
\addxcontentsline{lot}{table}[1.1]{example of table}
\addxcontentsline{lot}{table}[1.2]{example of table}
\addxcontentsline{lof}{figure}[1.1]{example of figure}
\addxcontentsline{lof}{figure}[1.2]{example of figure}
\blinddocument
\addxcontentsline{lot}{table}[2.1]{example of table}
\addxcontentsline{lot}{table}[2.2]{example of table}
\addxcontentsline{lof}{figure}[2.1]{example of figure}
\addxcontentsline{lof}{figure}[2.2]{example of figure}
\blinddocument
\addxcontentsline{lot}{table}[3.1]{example of table}
\addxcontentsline{lot}{table}[3.2]{example of table}
\addxcontentsline{lof}{figure}[3.1]{example of figure}
\addxcontentsline{lof}{figure}[3.2]{example of figure}
\end{document}
Best Answer
With
dynnumwidth=true
the value ofnumwidth
is not completly ignored (unlike the documentation). Instead it works as minimum width of the entry numbers includingnumsep
. That means the used width for the entry numbers is at leastnumwidth
, but it will be adjusted if there are numbers which need space wider thannumwidth
. So the effect ofdynumwidth=true
and/or changes ofnumsep
is only visible, if the needed space is wider thannumwidth
. I think the documentation fortocdynnumwidth
have to be changed (or it is a bug oftocbasic
).If you add
numwidth=0pt
to the settings for each TOC style entry, thendynnumwidth
andnumsep
have an effect even if there are only short entry numbers.Now the value of
\skillmon@numsep
sets the minimum space between the numbers and the titles in ToC. In the example it is set to0pt
.Run three times to get
Note that this example will also work if you replace
scrreprt
by the standard classreport
. But then you have to load packagescrtocbasic
explicitly.You are using the KOMA-Script class
scrreprt
. So it is possible to set the options for the toc entries also in the optional argument of\RedeclareSectionCommand
,\RedeclareSectionCommands
etc. But note there you have to add the prefixtoc
to each of these options.Example:
I have removed the options with values equal to the defaults. Run three times to get the same result as above.
Because
\CloneTOCEntryStyle
is mentioned in the question:scrreprt
uses\CloneTOCEntryStyle
to clonetocline
to the styleschapter
andsection
and\TOCEntryStyleStartInitCode
to declare the initial settings for some of the options of the new styles. Then stylesection
is cloned to styledefault
.So you could also do something like (warning: the example below uses undocumented internal commands, so it can break in the future)