# CSName parameters should (sometimes?) expand protected macros #1006

Closed
opened this issue Jun 10, 2018 · 4 comments
Labels
Milestone

 Minimal latex example: \documentclass{article} \usepackage{etoolbox} \begin{document} \expandafter\def\csname test-def\endcsname{prints the word def} \expandafter\def\csname test-robust\endcsname{prints the word robust} \def\mydef{def} \newrobustcmd\myrobust{robust} \csname test-\mydef\expandafter\endcsname \csname test-\myrobust\expandafter\endcsname \end{document} The PDF result is: prints the word def prints the word robust  The latexml result is correct for the def case, but fails with an error in the robust case: Error:unexpected:\myrobust The control sequence \myrobust should not appear between \csname and \endcsname  Tracing this down, I landed in State::lookupExpandable where this peculiar line is responsible for the discrepancy:  && ($toplevel || !$$defn{isProtected})) { # is this the right logic here? don't expand unless digesting? Simply commenting out that condition gets the example working, and fixes the general issue of using robust macros in expandable contexts. However, running a make test shows failures in various places, so I'm assuming the real adjustment is more subtle. added labels Jun 10, 2018 added this to the LaTeXML-0.8.4 milestone Jun 10, 2018 changed the title readXToken should expand protected macros readXToken should (sometimes?) expand protected macros Jun 10, 2018 ### dginev commented Jun 10, 2018  Alternatively, maybe the CSName parameter type should expand with the $toplevel flag set to true? Would need to read into the documentation to really know what's ajar.
modified the milestones: LaTeXML-0.8.4, LaTeXML-0.8.3 Jun 10, 2018

### dginev commented Jun 10, 2018

 FWIW, switching the toplevel flag to true and ensuring it's passed to the State method keeps all tests passing. I will add my commits to the etoolbox PR, but feel free to offer feedback in this issue - trying to avoid clutter. Side-note, I had mentioned the \protected mechanism print in \meaning via email to Bruce and I'll also add my tweak to that to the PR.

### dginev commented Jun 10, 2018

changed the title readXToken should (sometimes?) expand protected macros CSName parameters should (sometimes?) expand protected macros Jun 10, 2018

### dginev commented Jul 11, 2018

 Solved by merging #978
closed this Jul 11, 2018