Menu

#67 Setting fontsize in expl3-context gives warning

KOMA-Script 4
open
2024-04-18
2024-04-17
U_Fischer
No

Setting a fontsize which uses a clo when \ExplSyntaxOn is in effect (e.g. inside some package) gives a warning as the clo-file is read with unexpected catcodes:

\documentclass{scrartcl}

\ExplSyntaxOn
\KOMAoptions{fontsize=11pt}
\ExplSyntaxOff
\begin{document}
abc
\end{document}

gives

LaTeX Warning: \KOMAScriptVersion  is`2023/07/07 v3.41 KOMA-Script',
               but`2023/07/07v3.41KOMA-Script'wasexpected!
               Youshouldnotuseclasses,packagesorfilesfrom
               differentKOMA-Scriptversions.

I would suggest to use instead of a simple \InputIfFileExists the LaTeX2e kernel mechanism \@pushfilename/@popfilename, described here https://www.texdev.net/2015/07/30/making-custom-loaders-expl3-aware/

So something like this:

\documentclass{scrartcl}

\makeatletter
\newcommand\loadsizeclo[1]{%
 \@pushfilename
 \xdef\@currname{#1}% 
 \makeatletter
 \InputIfFileExists{#1}{}{}%
 \@popfilename}
\makeatother

\ExplSyntaxOn
\loadsizeclo{scrsize11pt.clo}
\ExplSyntaxOff

\showthe\catcode`\@ %still 12
\begin{document}
hello
\end{document}

Discussion

  • Markus Kohm

    Markus Kohm - 2024-04-17

    Unfortunately \@pushfilename and \@popfilename work only in the document preamble and result in an error inside the document. But being able to use option fontsize inside the document is one of the major features of KOMA-Script classes. So using \@pushfilename and \@popfilename wouldn't really be an improvement but break one of the documented KOMA-Script features.

     
  • Markus Kohm

    Markus Kohm - 2024-04-17
    • labels: --> feature request
     
  • Markus Kohm

    Markus Kohm - 2024-04-17
    • assigned_to: Markus Kohm
     
  • Markus Kohm

    Markus Kohm - 2024-04-17

    IMHO the problem with the scrsize*.clo files provided by KOMA-Script is the version test. The rest of the scrsize*.clo files should be expl3-context-hard. So making the version test expl3-context-hard, should be enough as a first step. Whether or not loading size files should (locally) change the catcode context, can be decided later, maybe for KOMA-Script 4 or when The LaTeX Team decides to support \@pushfilename and \@popfilename not only in the document preamble.

     

    Last edit: Markus Kohm 2024-04-17
    • Markus Kohm

      Markus Kohm - 2024-04-17

      Done so in [r4108].

       

      Related

      Commit: [r4108]

  • Markus Kohm

    Markus Kohm - 2024-04-17
    • Milestone: KOMA-Script 3.42 --> KOMA-Script 4
     
  • U_Fischer

    U_Fischer - 2024-04-18

    If you use a dedicated loader as wrapper you could naturally redefine it at begin document again. Inside the document body the machinery is not really needed. But I will discuss the \@pushfilename/\@popfilename question with the team.

     

Log in to post a comment.