Menu

#53 undefining \do can break other packages

KOMA-Script 3.41
closed
2023-05-16
2023-05-16
Cabohah
No

Package tocbasic does \let\do\relax. LaTeX interprets this a undefining \let. But some packages like dynkin-diagrams use \renewcommand to change the definition of \do. Because scrbook and scrreprt use \doforeachtoc inside \chapter this also happens with these classes (example from TeX.SX):

\documentclass{scrbook} 
\usepackage{dynkin-diagrams} 
\begin{document} 
\chapter{One}
Here is one \dynkin A2
\end{document}

results in:

LaTeX Error: Command \do undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.5 Here is one \dynkin A2

Discussion

  • Markus Kohm

    Markus Kohm - 2023-05-16

    IMHO, this is an issue of those packages. Indeed \do is undefined before loading dynkin-diagrams and \catcode \number `#1=12 after it. But depending on a definition of \do is dangerous, because it is used for a kind of foreach in LaTeX and everyone can there define it to whatever wanted. So a package should even work, if \do is \relax (as it is after loading the LaTeX format).

    AFAIR the \let\do\relax already has been added as a workaround for another package (don't remember which one). Maybe I could change if to \let\do\@empty or \let\do\noexpand (which is the default after \begin{document}). But IMHO this is not really a solution but would only be a workaround. And it would fail if \doforeachtocfile is used in the document preamble and after this a package would use \newcommand\do (which is IMHO also not a good idea but in the document preamble as (in-)correct as using \renewcommand\do after the document preamble).

    There are several other packages, e.g., pcatcode.sty (amsrefs), flexisym.sty, bxnewfont.sty, catoptions (which is AFAIK broken), examplep.sty, grfpaste.sty, underscore.sty, skeyval.sty, smfmulti.sty, theoremref.sty …, which also use \let\do\relax. Moreover depending on a so called hidden feature IMHO is not the best idea.

    Because of this IMHO it would be better, if dynkin-diagrams would use \def to change \do. The LaTeX kernel (and KOMA-Script) also uses \def or \let.

    Have you already reported an issue to dynkin-diagrams?

     

    Last edit: Markus Kohm 2023-05-17
  • Markus Kohm

    Markus Kohm - 2023-05-16
    • status: open --> closed
     
  • Markus Kohm

    Markus Kohm - 2023-05-16

    Workaround to the workaround added to [r4056].

     

    Related

    Commit: [r4056]


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.