The following example cannot be compiled (infinite loop). About a quarter of a year ago, such a construct still worked. I don't know what the problem is (my code ?, KOMA-Script?, LaTeX?). For my minimal example see attachment.
Nevertheless I would recommend to use \LoadClassWithOptions, because it doesn't make sense to explicitly pass all the global options to the class, which surely does not know all of them.
Last edit: Markus Kohm 2021-06-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
does not add the option to the raw option list \@raw@opt@foo.cls but the unexpanded \CurrentOption. AFAIK the KOMA-Script classes currently are the only classes, that process the raw option list. So the problem does currently only affects the KOMA-Script classes.
However, you can test the problem without KOMA-Script:
\begin{filecontents*}[force]{testclass.cls}\ProvidesClass{testclass}[2021/06/05 v0.0 test class]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{testclassi}}\ProcessOptions\relax\LoadClass{testclassi}\endinput\end{filecontents*}\begin{filecontents*}[force]{testclassi.cls}\ProvidesClass{testclassi}[2021/06/05 v0.0 internal test class]
\expandafter\show\csname @raw@opt@testclassi.cls\endcsname\expandafter\show\csname opt@testclassi.cls\endcsname\ProcessOptions\relax\LoadClass{minimal}\endinput\end{filecontents*}%------------------------------------------------------------\documentclass[draft]{testclass}\begin{document}\end{document}
So the raw option list and the classic options list differs here. The classic options list contains the expanded \CurrentOption → draft, but the raw option list contains \CurrentOption itself.
I don't know whether this is a bug in LaTeX or a mistake in your code. But you can fix your code, be forcing a one step expansion:
\begin{filecontents*}{foo.cls}\ProvidesClass{foo}[2021/06/04 v0.1a foo-Klasse (RN)]
\DeclareOption*{\expandafter\PassOptionsToClass\expandafter{\CurrentOption}{scrlttr2}}\ProcessOptions\relax\LoadClass{scrlttr2}\endinput\end{filecontents*}%------------------------------------------------------------\documentclass[twoside]{foo}\usepackage[ngerman]{babel}\begin{document}\begin{letter}{Petra Mustermann\\
Vor dem Berg 1\\
12345 Musterhausen}
XXXXXXXXXXXXXXXXXXXXXXXXXXXX
\newpage
YYYYYYYYYYYYYYYYYYYYYYYYYYYY
\end{letter}\end{document}
Please ask The LaTeX Team, whether this is intended or not.
Last edit: Markus Kohm 2021-06-05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Seems to be a bug in KOMA-Script.
Nevertheless I would recommend to use
\LoadClassWithOptions
, because it doesn't make sense to explicitly pass all the global options to the class, which surely does not know all of them.Last edit: Markus Kohm 2021-06-04
I was wrong. It is not a bug in KOMA-Script but either a bug or feature of LaTeX. Your
does not add the option to the raw option list
\@raw@opt@foo.cls
but the unexpanded\CurrentOption
. AFAIK the KOMA-Script classes currently are the only classes, that process the raw option list. So the problem does currently only affects the KOMA-Script classes.However, you can test the problem without KOMA-Script:
results in
So the raw option list and the classic options list differs here. The classic options list contains the expanded
\CurrentOption
→draft
, but the raw option list contains\CurrentOption
itself.I don't know whether this is a bug in LaTeX or a mistake in your code. But you can fix your code, be forcing a one step expansion:
Please ask The LaTeX Team, whether this is intended or not.
Last edit: Markus Kohm 2021-06-05
[r3604] adds a very simple detection and proper error message for this case.
Related
Commit: [r3604]
Delegated to The LaTeX Team → https://github.com/latex3/latex2e/issues/580
sorry about that, we'll arrange a patch level 1 latex update.