[Tex/LaTex] What causes this \discretionary error

babelerrorshyphenation

I would like to compile my old LaTeX thesis to PDF. The text was created in 1999 (emTeX, I believe) when the computers and the tools were a bit different — read it, I am returning to LaTeX after 14 years; that is long enough time to forget everything 🙂 The babel was not used for Czech in the time.

So far, (after several trial/failure, digging the info from my memory, and searching a bit) I have converted the sources to UTF-8, and changed the

\documentclass[a4paper,11pt]{report}
\usepackage{czech}

to

\documentclass[a4paper,11pt]{report}
\usepackage[czech]{babel}
\usepackage[utf8]{inputenc}

When running the following pdflatex --version on Windows 7

pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/W32TeX)
kpathsea version 6.1.1
Copyright 2013 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.5.16; using libpng 1.5.16
Compiled with zlib 1.2.7; using zlib 1.2.7
Compiled with xpdf version 3.03

(and running bibtex for my.aux file, and rerunning several times the pdflatex pri98dis.tex, I still get the following problem reported:

) [141] (./pri98dis.aux (./dekuji.aux) (./abstrakt.aux)
! Missing \endcsname inserted.
<to be read again> 
                   \unhbox 
l.223 ...`\discretionary {-}{}{}step}{{3.1.5}{52}}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Improper alphabetic constant.
<to be read again> 
                   \discretionary 
l.223 ...`\discretionary {-}{}{}step}{{3.1.5}{52}}

A one-character control sequence belongs after a ` mark.
So I'm essentially inserting \0 here.

! Extra \endcsname.
\@newl@bel ... \bbl@tempa \csname #1@#2\endcsname 
                                                  \def \bbl@tempb {#3}\@safe...
l.223 ...`\discretionary {-}{}{}step}{{3.1.5}{52}}

I'm ignoring this, since I wasn't doing a \csname.

)

LaTeX Warning: There were undefined references.


LaTeX Warning: There were multiply-defined labels.

The [141] is the very last page of the document. (Notice the ! Missing \endcsname inserted. and later the ! Extra \endcsname.)

In pri98dis.aux (belongs to the main document), the lines 222 and 223 look this way:

\@writefile{toc}{\contentsline {paragraph}{Krok modelov\IeC {\'e}ho \IeC {\v c}asu.}{52}}
\newlabel{time\unhbox \voidb@x \kern \z@ \char `\discretionary {-}{}{}step}{{3.1.5}{52}}

It seems that it belongs to the following part of the source:

\paragraph{Krok modelového času.}

... text of one paragraph...

\begin{verbatim}
    in('EvQue', 'head', ?head_time);                               { 1 }
    in('EvQue', 'list', head_time, ?next_time);                    { 2 }
    out('EvQue', 'head', next_time);                               { 3 }
\end{verbatim}
\label{time-step}

It seems that the problem is somehow caused by the \label{time-step}.

How can I fix the problem?

(Thanks, and wishing you the Happy New Year, and all of the days after.)

Best Answer

Most likely this is caused by a package (babel language shorthand?) defining - to be active and then trying it to act "as normal" by defining it to be

\leavevmode\char`\-

I get almost the same error (slightly different context, but the same

time\unhbox \voidb@x \char `\discretionary {-}{}{}step

from the following:

\documentclass{article}

\catcode`\-\active
\def-{\leavevmode\char`\-}

\begin{document}

aa \section{zzz\label{time-step}} aa

zzz\ref{time-step}

\end{document}

If you don't want to change the macros, the simple way to avoid the error is to not use - in label, ref and cite arguments.

Related Question