tags:

views:

44

answers:

1

Here is my minimal LaTeX document:

\documentclass{article}

\usepackage[polutonikogreek,english]{babel}
\newcommand{\Gk}[1]{\selectlanguage{polutonikogreek}#1\selectlanguage{english}}

\usepackage{ledmac}
\newcommand{\cn}[1]{\Afootnote{#1}}

\usepackage{ledpar}

\begin{document}
\beginnumbering
\pstart
\edtext{apostle}{\cn{\Gk{apostoloc}}}
\pend
\endnumbering
\end{document}

Executing latex test.tex produces the following error:

...
Section 1 (./test.1)
! Missing control sequence inserted.
<inserted text> 
                \inaccessible 
l.15 \pend

?

Some notes:

  1. The DVI produced looks fine despite the error.

  2. Commenting out the \usepackage{ledpar} fixes the problem.

  3. Not using the \Gk command also solves the problem. (But sort of defeats the purpose of having a footnote.)

What's going on here and how do I get around the error message?

A: 

According to the FAQ:

Sometimes LaTeX saves data it will reread later. These data are often the argument of some command; they are the so-called moving arguments. (‘Moving’ because data are moved around.) Candidates are all arguments that may go into table of contents, list of figures, etc.; namely, data that are written to an auxiliary file and read in later. Other places are those data that might appear in head- or footlines. Section headings and figure captions are the most prominent examples; there’s a complete list in Lamport’s book (see TeX-related books).

What’s going on really, behind the scenes? The commands in moving arguments are normally expanded to their internal structure during the process of saving. Sometimes this expansion results in invalid TeX code, which shows either during expansion or when the code is processed again. Protecting a command, using “\protect\cmd” tells LaTeX to save \cmd as \cmd, without expanding it at all.

So the \Gk command gets expanded too early in the process of TeXing the file and results in illegal code. The simplest solution is to declare the command robust:

\usepackage{makerobust}
\DeclareRobustCommand{\Gk}[1]{\selectlanguage{polutonikogreek}#1\selectlanguage{english}}

As to why using the ledpar package produces the error, I'm less certain. In order to facilitate notes in both the left and right side of parallel text, the ledpar package needs to redefine virtually every command provided by the ledmac package. Although I have not found the offending difference, one or more of the redefinitions must cause fragile commands to be expanded prematurely.

Jon Ericson