1

I am trying to change the font size of the achemso document class, and I came across this snippet of code on the second answer here: Is it possible to use 12 pt font size in the achemso package?

\let\titlefont\undefined
\makeatletter
\let\l@addto@macro\relax
\makeatother
\usepackage[fontsize=10pt]{scrextend}

It accomplishes the goal just fine, but I want to understand what the various lines are doing. I get that \let\titlefont\undefined is un-defining the title font of KOMA-script to avoid clash with achemso. I'm also okay with the \makeatletter \makeatother lines and the \usepackage line. But what is the \let\l@addto@macro\relax line doing? It seems to work with or without it. I tried researching \l@addto@macro, but all I could find is information on \g@addto@macro; what's the difference?

  • Normally \g@addto@macro changes the definition of the macro globally, while \l@addto@macro does so locally. Usage looks like this \newcommand\foo{bar}\l@addto@macro\foo{baz} and then the replacement text of \foo is barbaz. – Skillmon Sep 13 '23 at 20:35
  • I doubt that the l@addto-line is still needed (and it is unclear if it was ever needed). Leave out. But as said in the other answer: it doesn't make sense to use a class like achemso and to change it. – Ulrike Fischer Sep 13 '23 at 20:39
  • @Skillmon: In the usage above, then, is it adding \relax to the \let command for just this document (since it was local and not global)? Am I understanding that correctly? Many thanks! – the_chemist Sep 13 '23 at 20:47
  • @UlrikeFischer: The line definitely seems to not be required. Thanks for confirming. The only reason that I wanted to change the font size was to save paper when printing for my supervisor. – the_chemist Sep 13 '23 at 20:50
  • No, \let acts on \l@addto@macro turning it into \relax (which is roughly as good as undefining it). – Skillmon Sep 13 '23 at 20:58
  • 1
    By the way, I doubt very much that such a code would have worked correctly, because \l@addto@macro is a macro with two arguments and that redefinition would leave the two arguments in the input stream. – egreg Sep 13 '23 at 20:59
  • @egreg I'd guess it was used because scrextend defined \l@addto@macro with \newcommand and was erring because it was already defined. – Skillmon Sep 13 '23 at 21:08
  • @Skillmon I doubt that one would have ever got an error, because scrextend uses \l@addto@macro only inside the definition of \deffootnote. And doesn't define it. One gets an error if \deffootnote is used, but undefining \l@addto@macro is not the solution. – egreg Sep 13 '23 at 21:14
  • @egreg but scrextend requires scrkbase which requires scrbase which defines \l@addto@macro (the current version uses \def, but I have no idea whether that's always been the case). – Skillmon Sep 13 '23 at 21:25
  • @Skillmon Did you try without? I did, with TeX Live from 2020 (when scrextend was deployed) to 2023. – egreg Sep 13 '23 at 21:40
  • @egreg as I said I didn't check the history. In the meantime I looked at TL2018's scrbase and there it was already a \def plus a check if it's defined whether the meaning matches what KOMA expects. So all this \let-code ever could've done was throw a warning that KOMA redefines it because the meaning of \l@addto@macro is wrong... Indeed not that useful :) – Skillmon Sep 14 '23 at 07:43

1 Answers1

1

That code between \makeatletter and \makeatother is wrong and should be used nowhere.

If you try without that line, you'll see no difference at all.

The komascript classes and packages use \l@addto@macro in a few places. In scrextend.sty it's used once:

\newcommand\deffootnote[4][]{%
  \expandafter\ifnum\scr@v@is@ge{3.22}\relax
    \long\def\@makefntext##1{%
      \ExecuteDoHook{footnote/text/begin}%
      \raggedfootnote
      \leftskip #2
      \l@addto@macro\@trivlist{%
        \ifnum\@listdepth=\@ne\advance\leftmargin #2\relax\fi
      }%
      \parindent #3\noindent
  [...code not relevant...]
}

The macro is supposed to take two arguments and making it equivalent to \relax would leave those arguments in the input stream as soon as \deffootnote is used and later a footnote is processed, so executing \@trivlist at an unexpected and wrong place. For completeness of description, the second argument would do nothing, because the assignment would be executed in a group anyway.

egreg
  • 1,121,712