If I use the following custom class:

\ProvidesClass{upecha}[2014/09/21 v0.8 tibetan modern pecha class]

with the following test file


I get

! Missing control sequence inserted.
<inserted text> 
l.2 ...phenmin =\tw@ \righthyphenmin =\thr@@ \edef e
                                              nglish{english}\def tt{tt}...

with the aux file containing:

\protect \language =\z@ \lefthyphenmin =\tw@ \righthyphenmin =\thr@@ \edef english{english}\def tt{tt}\def sf{sf}\edef {}\edef English{English}\protect \relax \protect \edef lmr{lmr}\protect \xdef \EU2/lmr/m/n/10.95 {\EU2/lmr/m/n/10.95 }\EU2/lmr/m/n/10.95 \size@update \enc@update \def rm{rm}\language =\l@english \def 21{21}\def September{September}\def September 21, 2014{September 21, 2014}\lefthyphenmin 2\relax \righthyphenmin 3\relax \relax \def Preface{Preface}\def References{References}\def Abstract{Abstract}\def Bibliography{Bibliography}\def Chapter{Chapter}\def Appendix{Appendix}\def Contents{Contents}\def List of Figures{List of Figures}\def List of Tables{List of Tables}\def Index{Index}\def Figure{Figure}\def Table{Table}\def Part{Part}\def encl{encl}\def cc{cc}\def To{To}\def Page{Page}\def see{see}\def see also{see also}\def Proof{Proof}

while it should contain

\select@language {english}

This wrong definition in the aux file is more or less the definition of select@language.

I was tempted to accuse the following line in polyglossia.sty:


because if I replace \protect by \string, everything works again. BUT, the most stange thing is that this behaviour disappears if I comment the line


in my class file. Also, this error doesn't show if I add this line to a document using the article class...

So who's wrong here: my code, LaTeX core or polyglossia? (LuaTeX and XeLaTeX have the same behaviour here, so I wouldn't say it comes from the engine...)

Thank you!

  • may I ask how? This is the most obscure part for me: where did I disable anything? Is it that all output routines should call \set@typeset@protect ?
    – Elie Roux
    Sep 21, 2014 at 12:52
  • See @egreg's answer, the \protect mechanism assumes that \protect is set up to do the correct thing during the shipout, if you simplify the output routine not to set up protect then it's not set up. Sep 21, 2014 at 13:17

1 Answer 1


The LaTeX kernel takes several precautions against this:


    \aftergroup \endgroup
    \aftergroup \set@typeset@protect


See source2e.pdf page 334 for the reason why \let\protect\noexpand is needed here and the \aftergroup trickery is used.

  • Thank you! It seems it was the reduction from my whole output routine to this minimal example that was the culprit here, but using your template I was able to fix my real-life output routine!
    – Elie Roux
    Sep 21, 2014 at 12:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .