2009-06-15 96 views
1

這是我最小的LaTeX文檔:爲什麼使用ledpar會導致文檔失敗?

\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} 

執行latex test.tex產生以下錯誤:

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

? 

一些注意事項:

  1. 產生的DVI看起來很好,儘管錯誤。

  2. 註釋掉\usepackage{ledpar}可解決問題。

  3. 不使用\Gk命令也解決了這個問題。 (但有點違背了一個腳註的目的。)

這是怎麼回事,我該如何解決該錯誤消息得到什麼?

回答

1

按照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.

所以\Gk命令獲取你TeX非法代碼的文件和結果的過程中過早擴大。最簡單的解決方案是聲明命令健壯:

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

至於爲何使用ledpar包產生錯誤,我少一定。爲了便於在並行文本的左側和右側註釋,ledpar程序包需要重新定義由ledmac程序包提供的幾乎所有命令。儘管我還沒有發現這種有害的區別,但是一個或多個重新定義必須導致脆弱的命令過早地被擴展。

相關問題