eplain 中的 \xrdef 和 \xref

eplain 中的 \xrdef 和 \xref

我尝试将eplain《TeX for the Impatient》一书中使用的版本从 1.9 升级到最新版本 3.6,但在使用新版本时遇到了以下问题eplain

eplain下面的代码可以用1.9编译,但不能用eplain3.6 编译:

\input eplain
define at \xrdef\input and refer to \xrefn\input done
\bye

错误信息如下:

This is XeTeX, Version 3.1415926-2.5-0.9999.3 (MiKTeX 2.9) (preloaded format=xetex 2014.5.27)  5 OCT 2014 19:20
entering extended mode
**xrefn.tex
(E:\test\xrefn.tex
(E:\test\eplain.tex
Requested font "logo10" scaled 1000
Requested font "logosl10" scaled 1000
Requested font "line10" scaled 1000
Requested font "cmtt8" scaled 1000
)
! I can't find file `}'.
<to be read again> 
                   \global 
\readauxfile ->\if@auxfiledone \else \global 
                                             \@auxfiledonetrue \@testfileexi...

\definexref ...f}{#1}\edef \temp {#1}\readauxfile 
                                                  \edef \@wr {\noexpand \wri...

\xrdef ...definexref {#1}{\noexpand \folio }{page}
                                                  \endgroup \endgroup \ignor...
l.5 define \xrdef\input
                        and refer \xref\input done
Please type another input file name
! Emergency stop.
<to be read again> 
                   \global 
\readauxfile ->\if@auxfiledone \else \global 
                                             \@auxfiledonetrue \@testfileexi...

\definexref ...f}{#1}\edef \temp {#1}\readauxfile 
                                                  \edef \@wr {\noexpand \wri...

\xrdef ...definexref {#1}{\noexpand \folio }{page}
                                                  \endgroup \endgroup \ignor...
l.5 define \xrdef\input
                        and refer \xref\input done
*** (job aborted, file error in nonstop mode)

No pages of output.

我该如何解决这个问题?

答案1

如果你需要这个来处理旧文件,你可以这样做

\input eplain

\catcode`@=11
\def\stringify#1{%
  \expandafter\let\csname zh@\string#1\endcsname#1%
  \def#1##1{%
    \begingroup\def\temp{##1}%
    \edef\x{\endgroup
      \expandafter\noexpand\csname zh@\string#1\endcsname{%
        \expandafter\strip@prefix\meaning\temp}%
    }\x
  }%
}
\stringify\xrdef
\stringify\xrefn
\stringify\@definelabel
\catcode`@=12

define at \xrdef\input and refer to \xrefn\input

define at \xrdef{xyz} and refer to \xrefn{xyz}
\bye

然而,使用符号标记作为参数绝对是个坏主意\xrdef

.aux如果文件尚未更新,则会出现以下情况:

在此处输入图片描述

这是 TeX 第二次运行后的结果

在此处输入图片描述

答案2

不确定这在一般情况下是否有效,但在这里有效(.aux首先删除任何现有文件)

\input eplain
%\input eplain-2.1/eplain
\let\oldxrdef\xrdef
\def\xrdef#1{\expandafter\oldxrdef\expandafter{\string\string\string#1}}
\let\oldxrefn\xrefn
\def\xrefn#1{\expandafter\oldxrefn\expandafter{\string#1}}

define at \xrdef\input and refer to \xrefn\input done
\bye

相关内容