I'm using KOMA-Script with pdflatex (might want to switch to lualatex eventually) to typeset my thesis and want to use EBGaramond as a font. To this end I am loading the ebgaramond-maths package, which in turn loads the ebgaramond package. The latter offers various styles of the font, including different number figures. I really like the default old-style figures in the body text, but I don't think they lend themselves too well for headings. So I want to change the number style only in the headings and TOC. The ebgaramond README gives us the following ways to choose a style:

To use, add \usepackage{ebgaramond} to the preamble of your document. Options include:

  • oldstyle,osf old-style figures
  • lining,nf,lf lining figures

[…] Commands \oldstylenums{...} and \liningnums{...} are defined to allow for local use of old-style figures or liningfigures, respectively.

Changing the style globally is not an option, so we're left with using \liningnums{}. How do I use it correctly with KOMA-Script?

I've tried various methods, to no success:

  1. The first intuition would be to use \addtokomafont

(\rmfamily because I want serif style headings). This works for \chapters but not \sections in the MWE, but it doesn't work in my actual document and throws

! Paragraph ended before \text@command was complete.

I don't know what's messing with it here, but it's also discouraged by the KOMA-Script documentation (section 3.6):

Sometimes, although this is not recommended, the font setting of an element is used for settings that are not actually related to the font. […] However, you should not take these commands as legitimizing the insertion of arbitrary commands in an element’s font setting. To do so can lead quickly to errors (see section 21.5, page 476).

  1. According to this related answer, one should change \chapterlinesformat and the like
% ...

But this doesn't work either. When I only set \chapterlinesformat it works for \chapters but messes with the font styles. In the TOC, the \chapter font is set to sans-serif Computer Modern, while \section and \subsection is left at serif Garamond. In the main document however it's exactly opposite: \chapter has the correct lining figures and is correctly typeset in Garamond, but now the \section and \subsection are in sans-serif Computer Modern. If dare to add the sectionlinesformat line, I get the error

! You can't use `\glueexpr' in horizontal mode.

How do I correctly tell KOMA-Script to use liningnums{} for headings in the body text and TOC? No hacks please, I want a clean KOMA-Scriptonic solution.

Minimal (not)Working Example:




You can switch the font family to the lining font:

\AfterTOCHead{\renewcommand\rmdefault{EBGaramond-LF}\normalfont} %for the toc

    \chapter{Chapter 89}
    \section{Section 89}

enter image description here

| improve this answer | |
  • perfect and even cleaner than I thought. Thanks! – Philipp Stephan Mar 11 at 16:46
  • unfortunately, the table of contents has the chapters now typeset in Computer Modern Sans and the sections in Garmond but with old style figures... – Philipp Stephan Mar 12 at 14:29
  • KOMA has suitable command to setup the fonts in the table of contents in a similar way. – Ulrike Fischer Mar 12 at 14:33
  • I'm sorry, somehow the \selectfont got lost. The font choice works in the TOC as well, but sections still have old-style figures. When I try to \addtokomafont{sectionentry}{\fontfamily{EBGaramond-LF}\selectfont}, pdflatex tells me "font of element 'sectionenrty' can't be extended" and the KOMA-Script manual says "sectionentry" is only available in scrartcl (p63) – Philipp Stephan Mar 12 at 14:43
  • I added an edit for the toc. One could also redefine the single entries, but simply switching \normalfont is easier. – Ulrike Fischer Mar 12 at 15:01

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.