1

The following MWE is giving error:

./test.tex:10: Missing \endcsname inserted.
<to be read again> 
               :   
l.10 \section{A section}\label{sec:one`}

The source:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[french,main=english]{babel}

\usepackage{crossreftools}

\begin{document}

\section{A section}\label{sec:one}

Some math $1+1=2$.

\end{document}

There is no error if I:

  • delete \usepackage{crossreftools}; OR
  • omit french from the options to `babel; OR
  • replace french by german or russian.

The Incompatibilities section of the docs for crossreftools say "...any unexpandable content written to the aux-file by redefinitions of \label or @currentlabel etc will cause problems.

Is that what the french option to babel is doing — writing such unexpandable content to the .aux?

If so, is there some work-around?

3
  • You can try the version currently in github.com/latex3/babel . Oct 2, 2019 at 14:43
  • @JavierBezos: Is that newer than the stable version 3.34 that I just updated with the TeXLive Utility? If so, how do I use latex on the .ins so as NOT to replace the stable version already in my texmf tree? Don't I want to do that and just place the new files in the same folder as my source document, for testing?
    – murray
    Oct 2, 2019 at 19:01
  • @JavierBezos: the problem arises not with babel itself, so far as I can see, but with babel-french.ldf, where : is made active. (Likewise ; and ! and ?).
    – murray
    Oct 5, 2019 at 16:36

3 Answers 3

4

crossreftools creates a list of labels and tries to write the label key to it. That is a bit fragile ... You could add \detokenize:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[french,main=english]{babel}

\usepackage{crossreftools}
\makeatletter
\renewcommand{\crtaddlabeltotoc}[1]{%
  \ifcrtfinal
  \else
  \addcontentsline{\crt@listoflabelsfileextension}{\crt@listoflabelsstructurelevel}{%
   \protect\numberline{\expandafter\crtrefnumber\expandafter{\detokenize{#1}}}#1}%
  \fi
}
\makeatother

\begin{document}
\crtlistoflabels
\tableofcontents
\section{A section:abc }  \label{sec:onea} \label{seconea}
Some math $1+1=2$.

\end{document}
2
  • While that does fix the crossreftools+babel-french incompatibility for the crossreftools command crtlistoflabelsthat I raised, it does not fix the incompatibility with the other commands from that package, including its redefinition of the version of \cref(from cleveref).
    – murray
    Oct 11, 2019 at 15:31
  • There is another place where a \detokenize is needed, see my answer. Oct 14, 2019 at 10:46
3

The French option has made : active to produce French punctuation spacing and this interferes with its use in \label the simplest solution is simply to avoid punctuation characters in \label, \label{sec-one} works for example.

Normally babel ensures : still works in \label but apparently crossreftools disables that.

2
  • Ouch! In my actual book-length document, all the 1500+ labels include a colon. So I'm hoping there's some other workaround -- for babel-french.
    – murray
    Oct 1, 2019 at 22:02
  • 1
    @murray oh there is always a workaround:-) I don't actually know crossreftools package and I was hoping to avoid looking but I'll look tomorrow if no one else has answered. Oct 1, 2019 at 22:09
1

There is another place where a \detokenize is needed:

\renewcommand{\@@crtextr@ct@ref}[2]{%
  \expandafter\@@@crtextr@ct@ref\expandafter{\detokenize{#2}}{#1}%
}
\newcommand{\@@@crtextr@ct@ref}[2]{%
  \expandafter\ifx\csname r@#1\endcsname\relax
  \crt@refundefined%
  \else
  \expandafter\expandafter\csname crt@ref@splitter@#2\endcsname\csname r@#1\endcsname%
  \fi
}

My preference is to make the changes in my own copy of crossreftools.sty. And then just replace the original definitions with the new ones. That means in each case the \renewcommand should be replaced by \newcommand.

You must log in to answer this question.

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