2009-06-15 99 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程序包提供的几乎所有命令。尽管我还没有发现这种有害的区别,但是一个或多个重新定义必须导致脆弱的命令过早地被扩展。

相关问题