1

community,

I have received great help many times before on this platform and I really do hope that you can help me yet again! I'm trying to customize my ToC in such a way that things like the List of Figures and List of Tables: 1. appear in the ToC 2. are written in cursive 3. are as sections as close together as subsections/are as subsections not indented

The first two points I could manage, but the last one just doesn't work:

\documentclass[paper=a4,12pt,numbers=endperiod]{scrartcl}
\usepackage{fontspec}
\setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\usepackage[autostyle=true]{csquotes}
\usepackage{yfonts}
\usepackage{xltxtra}
\usepackage{graphicx}
\usepackage{float}
\usepackage{caption}
\usepackage[english]{fancyref}
\usepackage{tocbasic}
\KOMAoptions{toc=sectionentrydotfill}

\begin{document}
\newpage
\thispagestyle{empty}
\tableofcontents
\newpage
\listof{table}{\textit{List of Tables}}
\addcontentsline{toc}{section}{\textit{List of Tables}}
\section*{\textit{List of Abbreviations}}
    \addcontentsline{toc}{section}{\textit{List of Abbreviations}}
\section{Test}
Text
\section{Test2}
Text2
\end{document}
\section*{\textit{Glossary}}
    \addcontentsline{toc}{section}{\textit{Glossary}}
 \section*{\textit{Declaration of Originality}}
    \addcontentsline{toc}{section}{\textit{Declaration of Originality}}

I have found a package that allows you to customize your ToC but I cannot really use it and it just produces errors all the time. I think it would be easiest to define a new section category (like 'nsection') that has a different baseline skip than the normal section (because I would very much like to keep that)

Thank you so much! If you need any more information, please let me know!

Edit: I have added more 'random' sections that are not their own function in LaTex in order to demonstrate that I want to be able to use 'nsection' for anything I want

3

Update (MWE in question and desired result are changed: usage of nsection not restricted to lists like LOF and LOT)

\documentclass[paper=a4,12pt,numbers=endperiod]{scrartcl}% loads and uses tocbasic!
\usepackage{xltxtra}% loads also fontspec
\setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\usepackage[autostyle=true]{csquotes}
\usepackage{yfonts}
\usepackage{graphicx}
%\usepackage{float}
\usepackage{caption}
\usepackage[english]{fancyref}

\KOMAoptions{
  toc=sectionentrydotfill,
  listof=totoc
}

\newkomafont{standardsection}{\Large}
\newkomafont{nsection}{\usekomafont{standardsection}\slshape}

\DeclareTOCStyleEntry[%
  level=\sectiontocdepth,%
  beforeskip=0pt plus .2pt,%
  indent=0pt,%
  numwidth=1.5em,%
  entryformat=\usekomafont{sectionentry}\textsl%
]{section}{nsection}

\newcommand*\usensection{% define switch to nsection
  \addtocontents{toc}{\protect\addvspace{1em plus 1pt}}% additional space in TOC before the first nsection entry
  \setkomafont{section}{\usekomafont{nsection}}%
  \renewcommand\addsectiontocentry[2]{\addtocentrydefault{nsection}{##1}{##2}}%
}
\newcommand*\usestandardsection{% define switch to standard section
  \setkomafont{section}{\usekomafont{standardsection}}%
  \renewcommand\addsectiontocentry[2]{\addtocentrydefault{section}{##1}{##2}}%
}

\AfterTOCHead[toc]{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC[toc]{\clearpage}

\begin{document}
\tableofcontents

\usensection% switch to nsection
\listoftables
\listoffigures
\addsec{List of Abbreviations}

\usestandardsection% switch to standard section
\section{Test}
Text
\section{Test2}
Text2

\usensection% switch to nsection
\addsec{Glossary}
\addsec{Declaration of Originality}

\end{document}

Result:

enter image description here


Original answer (nsection only needed for lists like LOF and LOT)

Here is a suggestion using a new declared TOCStyleEntry nsection for the entries of LOF and LOT in TOC. Therefore \addsectiontocentry is redefined locally.

Note that KOMA-Script class srcartcl already loads package tocbasic. So do not load it again.

\documentclass[paper=a4,12pt,numbers=endperiod]{scrartcl}% loads and uses tocbasic!
\usepackage{xltxtra}% loads also fontspec
\setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\usepackage[autostyle=true]{csquotes}
\usepackage{yfonts}
\usepackage{graphicx}
%\usepackage{float}
\usepackage{caption}
\usepackage[english]{fancyref}

\KOMAoptions{
  toc=sectionentrydotfill,
  listof=totoc
}

\DeclareTOCStyleEntry[%
  level=\sectiontocdepth,%
  beforeskip=0pt plus .2pt,%
  indent=0pt,%
  numwidth=1.5em,%
  entryformat=\usekomafont{sectionentry}\textsl%
]{section}{nsection}
\BeforeTOCHead{%
  \addtokomafont{section}{\slshape}%
  \renewcommand\addsectiontocentry[2]{\addtocentrydefault{nsection}{#1}{#2}}%
}

\AfterTOCHead[toc]{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC[toc]{\clearpage}

\begin{document}
\tableofcontents
\listoftables
\listoffigures
\section{Test}
Text
\section{Test2}
Text2
\end{document}

Result:

enter image description here


If the changes should be restricted to lists with owner=float (LOT, LOF, etc), you can use:

\makeatletter
\doforeachtocfile[float]{% do for all lists with owner=float like LOF and LOT
  \BeforeTOCHead[\@currext]{%
    \addtokomafont{section}{\slshape}%
    \renewcommand\addsectiontocentry[2]{\addtocentrydefault{nsection}{##1}{##2}}%
  }%
}
\makeatother

enter image description here

Code:

\documentclass[paper=a4,12pt,numbers=endperiod]{scrartcl}% loads and uses tocbasic!
\usepackage{xltxtra}% loads also fontspec
\setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\usepackage[autostyle=true]{csquotes}
\usepackage{yfonts}
\usepackage{graphicx}
%\usepackage{float}
\usepackage{caption}
\usepackage[english]{fancyref}

\KOMAoptions{
  toc=sectionentrydotfill,
  listof=totoc
}

\DeclareTOCStyleEntry[%
  level=\sectiontocdepth,%
  beforeskip=0pt plus .2pt,%
  indent=0pt,%
  numwidth=1.5em,%
  entryformat=\usekomafont{sectionentry}\textsl%
]{section}{nsection}
\makeatletter
\doforeachtocfile[float]{% do for all lists with owner=float like LOF and LOT
  \BeforeTOCHead[\@currext]{%
    \addtokomafont{section}{\slshape}%
    \renewcommand\addsectiontocentry[2]{\addtocentrydefault{nsection}{##1}{##2}}%
  }%
}
\makeatother

\AfterTOCHead[toc]{\thispagestyle{empty}\pagestyle{empty}}
\AfterStartingTOC[toc]{\clearpage}

\begin{document}
\tableofcontents
\listoftables
\listoffigures
\section{Test}
Text
\section{Test2}
Text2
\end{document}

Note that you will get the same result with

\BeforeTOCHead[lof]{%
  \addtokomafont{section}{\slshape}%
  \renewcommand\addsectiontocentry[2]{\addtocentrydefault{nsection}{#1}{#2}}%
}
\BeforeTOCHead[lot]{%
  \addtokomafont{section}{\slshape}%
  \renewcommand\addsectiontocentry[2]{\addtocentrydefault{nsection}{#1}{#2}}%
}
| improve this answer | |
  • I was trying to find a solution without using the KOMA macros in KOMA (terrible work), so nice to see what KOMA offers! \BeforeTOCHead patches just locally the listof commands, right? It is changing the toc title font ('Contents') as well. Purely educational and before I start digging myself, maybe you know how to check for a certain listof to not change the toc title font? Or how should one solve that with KOMA? – nox Jun 29 '18 at 9:55
  • Yes, BeforeTOCHead[<extension>]{\addtokomafont{section}{\slshape}} changes the font settings for the section titles locally. The optional argument <extension> can be used to do this for single lists or for lists of a special owner. See my answer. And thanks for the hint: I had overlooked that the font of the TOC title should not change. – esdd Jun 29 '18 at 10:21
  • thank you so much! this is all I ever wanted (and more!^^) – LajosH Jun 29 '18 at 11:50
  • @esdd I have edited my original post and added more 'general' sections as well because I want to be able to use 'nsection' for any section I want, regardless of that section's status as a proper LaTeX function. Unfortunately, I haven't made that clear enough in the beginning! – LajosH Jun 30 '18 at 12:26
  • @LajosH See my updated answer. But note that it is usually better to ask a follow-up question. – esdd Jun 30 '18 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.