3

The KOMA-Script key fontsize can be used to switch the font size mid-document (as well as at the start of the document). However, it adds spurious spaces when switching to 10pt, 11pt or 12pt, as can be seen in the MWE below. This seems to only happen for those sizes.

Why is this happening and how can I prevent it?

\documentclass{scrartcl}

\usepackage{lmodern}

\def\fontsizetest#1{%
  \noindent\makebox[2em][r]{#1}:
  {X\KOMAoptions{fontsize=#1}X}\par
}

\begin{document}

\fontsizetest{9pt}
\fontsizetest{9.5pt}
\fontsizetest{10pt}
\fontsizetest{10.5pt}
\fontsizetest{11pt}
\fontsizetest{11.5pt}
\fontsizetest{12pt}
\fontsizetest{12.5pt}
\fontsizetest{13pt}

\end{document}

MWE output

9
  • 1
    It will be some missing % in the class but do you ever really want to change the document layout mid-paragraph? spaces are harmless in vertical mode Commented Oct 6, 2022 at 10:43
  • 1
    there is probably a spurious space somewhere. KOMA has a bug tracker, report it (but imho this options shouldn't be used in the middle of a document). Commented Oct 6, 2022 at 10:43
  • If you just want to change the fontsize, don't use this, use the standard latex \fontsize command Commented Oct 6, 2022 at 10:45
  • @DavidCarlisle But \fontsize doesn't set up \large and friends, does it? KOMA-Script changes all of those, as well as setting up dimensions like \abovedisplayskip.
    – schtandard
    Commented Oct 6, 2022 at 10:55
  • I agree that the font size should not usually be changed mid-document, but I believe there are reasonable exceptions. The KOMA-Script documentation itself mentions wanting to typeset an appendix in a slightly smaller font size. In my case, I am typesetting a poster with a large font size and want to include some tikzpictures that I need to scale up (using adjustbox; there is no good way to scale all the relevant dimensions using TikZ itself), so I need to reset the font size to a small value for the tikzpictures.
    – schtandard
    Commented Oct 6, 2022 at 10:55

1 Answer 1

4

If you use a "known" size then a pre-made size-file is loaded and the log says

Class scrartcl Info: File `scrsize12pt.clo' used to setup font sizes on input l
ine 18.

Looking at scrsize12pt.clo you see things like

\def\small{%
  \@setfontsize\small\@xipt{13.6}%
  \abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@
  \abovedisplayshortskip \z@ \@plus3\p@
  \belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@
  \def\@listi{\leftmargin\leftmargini
    \topsep 9\p@ \@plus3\p@ \@minus5\p@
    \parsep 4.5\p@ \@plus2\p@ \@minus\p@
    \itemsep \parsep}%
  \belowdisplayskip \abovedisplayskip
}

Where the newline after } makes a space token if used in horizontal mode.

It is rare to change document layout mid-document, and almost never a requirement to change mid-paragraph so newlines after definitions haven't been guarded by % here.

1
  • 1
    as a workaround, if switching to vmode is not an option, follow by enough \unskip\unskip... Commented Oct 6, 2022 at 11:33

You must log in to answer this question.

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