Menu

#10 Infinite loop

KOMA-Script 3.34
closed
LaTeX (3)
2021-06-06
2021-06-04
Rolf
No

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.

1 Attachments

Discussion

  • Markus Kohm

    Markus Kohm - 2021-06-04
    • labels: --> bug
    • Milestone: KOMA-Script 3.33 --> KOMA-Script 3.34
     
  • Markus Kohm

    Markus Kohm - 2021-06-04

    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
  • Markus Kohm

    Markus Kohm - 2021-06-05

    I was wrong. It is not a bug in KOMA-Script but either a bug or feature of LaTeX. Your

    \DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrlttr2}}
    

    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}
    

    results in

    > \@raw@opt@testclassi.cls=macro:
    ->\CurrentOption ,.
    <recently read> \@raw@opt@testclassi.cls 
    
    l.2 ...ow\csname @raw@opt@testclassi.cls\endcsname
    
    > \opt@testclassi.cls=macro:
    ->draft,.
    <recently read> \opt@testclassi.cls 
    
    l.3 ...er\show\csname opt@testclassi.cls\endcsname
    

    So the raw option list and the classic options list differs here. The classic options list contains the expanded \CurrentOptiondraft, 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
  • Markus Kohm

    Markus Kohm - 2021-06-05
    • labels: bug --> LaTeX
    • status: open --> closed
     
  • Markus Kohm

    Markus Kohm - 2021-06-05

    [r3604] adds a very simple detection and proper error message for this case.

     

    Related

    Commit: [r3604]

  • Markus Kohm

    Markus Kohm - 2021-06-05

    Delegated to The LaTeX Team → https://github.com/latex3/latex2e/issues/580

     
  • David Carlisle

    David Carlisle - 2021-06-06

    sorry about that, we'll arrange a patch level 1 latex update.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.