2

Using the scrreprt document class, I get a table of contents that uses non serif fonts for everything, except for sections: enter image description here

Now I've been asked to change this to non serif for the sections as well. tex --version says TeX 3.14159265 (TeX Live 2015/Debian) on my machine, but from what I've seen on my search for a solution, this actually appears to be the intended default behavior, so it should be reproducible on other machines using this MWE:

\documentclass[toc=chapterentrywithdots]{scrreprt}
\begin{document}
    \tableofcontents
    \chapter{Testing Text Chapter 1}
        Testing Text Chapter 1
        \section{Testing Text Section 1}
            Testing Text Section 1
        \section{Testing Text Section 2}
            Testing Text Section 2
\end{document}

The more common question regarding this topic appears to be how to change the font to non serif only or serif only for the whole document, but this is not what I want to achieve. Currently, I have non serif headers and serif text throughout my complete document, and it should stay this way. Only the sections in the table of contents should be non serif, preferably using a clean solution instead of a dirty hack.

4

With an older KOMA-Script version - like that one in TL 2015 - you can use

\AfterTOCHead[toc]{\sffamily\renewcommand\familydefault{\sfdefault}}

This works with uptodate KOMA-Script versions, too. But note, it changes also the font family for ToC entries of subsections, subsubsections etc.

Example:

\documentclass[toc=chapterentrywithdots]{scrreprt}

\AfterTOCHead[toc]% without the optional argument, it also affects LoF and LoT
  {\sffamily\renewcommand\familydefault{\sfdefault}}

\begin{document}
    \tableofcontents
    \chapter{Testing Text Chapter 1}
        Testing Text Chapter 1 \KOMAScriptVersion
        \section{Testing Text Section 1}
            Testing Text Section 1
        \section{Testing Text Section 2}
            Testing Text Section 2
\end{document}

Result:

enter image description here


Only with uptodate KOMA-Script versions (not with TL 2015!) you can use

\RedeclareSectionCommand[%
  tocentryformat=\sffamily,%
  tocpagenumberformat=\sffamily
]{section}

or if there are subsections too

\RedeclareSectionCommands[% note the "s" at the end
  tocentryformat=\sffamily,%
  tocpagenumberformat=\sffamily% 
]{section,subsection}

Or you could use

\DeclareTOCStyleEntry[% note the "s" at the end
  entryformat=\sffamily,%
  pagenumberformat=\sffamily% 
]{default}{section}

This can also be used for figure and table entries in LOF and LOT, respectively:

\DeclareTOCStyleEntry[% note the "s" at the end
  entryformat=\sffamily,%
  pagenumberformat=\sffamily% 
]{default}{figure}
1

I don't know if this is the easiest way, but here this works:

\documentclass[toc=chapterentrywithdots]{scrreprt}
\begin{document}

\RedeclareSectionCommand[%
tocentryformat=\sffamily%
]{section}

    \tableofcontents
    \chapter{Testing Text Chapter 1}
        Testing Text Chapter 1
        \section{Testing Text Section 1}
            Testing Text Section 1
        \section{Testing Text Section 2}
            Testing Text Section 2
\end{document}

pic of toc with sectionentry in sansserif

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.