使用 LuaLaTex 运行时,etextools 会抛出错误

使用 LuaLaTex 运行时,etextools 会抛出错误

我尝试将该etextools包与 LuaLaTeX 一起使用,但遇到了以下错误

! String contains an invalid utf-8 sequence.
l.233    \csdef{ettl@ifdef#2}##1#1##2/End
                                   �Meaning/{\ettl@nbk##2//\rmn@firstoft...

通过在 LuaLaTeX 中运行以下简单文档可以重现该错误:

\documentclass{article}
\usepackage{etextools}
\begin{document}
Some text
\end{document} 

是否有与 LuaLaTeX 一起使用的解决方法etextools,或者我只是在这里遗漏了一些东西?

答案1

的定义\ettl@ifd@f包含两个实例,^^a7这是无效的 UTF-8 序列。该字符在文档部分中被激活,但它应该是无关紧要的。

我猜测其意图是为了宏提供一个“非标准”分隔符,但这当然是一个错误的决定。

\def\ettl@ifd@f#1#2{%
   \csdef{ettl@ifdef#2}##1#1##2/End^^a7Meaning/{\ettl@nbk##2//\rmn@firstoftwo\rmn@secondoftwo//}
   \csedef{ifdef#2}##1{\noexpand\romannumeral\noexpandafter%
      \noexpandcs{ettl@ifdef#2}\noexpand\meaning##1#1/End^^a7Meaning/}%//{##2}{##3}//}
}

更好的编程风格应该是为和分配一个非标准类别代码,QZ使用更安全的字符作为分隔符,比如

\begingroup\catcode`Q=3 \catcode`Z=3
\gdef\ettl@ifd@f#1#2{%
   \csdef{ettl@ifdef#2}##1#1##2/EndQZMeaning/{\ettl@nbk##2//\rmn@firstoftwo\rmn@secondoftwo//}
   \csedef{ifdef#2}##1{\noexpand\romannumeral\noexpandafter%
      \noexpandcs{ettl@ifdef#2}\noexpand\meaning##1#1/EndQZMeaning/}%//{##2}{##3}//}
}
\endgroup

但是,我无法使用 TeX Live 重现该错误:

This is LuaTeX, Version beta-0.79.1 (TeX Live 2014) (rev 4971) 
 restricted \write18 enabled.
(./arnobug.tex
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2014/texmf-dist/tex/latex/etextools/etextools.sty
(/usr/local/texlive/2014/texmf-dist/tex/latex/etex-pkg/etex.sty)
(/usr/local/texlive/2014/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/local/texlive/2014/texmf-dist/tex/latex/oberdiek/letltxmacro.sty)

Package etextools Warning: \pdfstrcmp primitive not found
(etextools)                Macro \xifempty has been replaced by \xifstrempty 
(etextools)                It is not purely expandable on input line 381.


Package etextools Warning: \pdfstrcmp primitive not found
(etextools)                Macro \ifstrcmp has been replaced by \ifstrequal 
(etextools)                It is not purely expandable on input line 403.


Package etextools Warning: \pdfstrcmp primitive not found
(etextools)                Macro \xifstrcmp has been replaced by \xifstrequal 
(etextools)                It is not purely expandable on input line 409.

) (./arnobug.aux) [1{/usr/local/texlive/2014/texmf-var/fonts/map/pdftex/updmap/p
dftex.map}] (./arnobug.aux))
 264 words of node memory still in use:
   2 hlist, 1 vlist, 1 rule, 2 glue, 40 glue_spec, 1 write nodes
   avail lists: 1:4,2:13,3:2,4:23,6:15,7:1,9:6
<</usr/local/texlive/2014/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on arnobug.pdf (1 page, 11626 bytes).
Transcript written on arnobug.log.

最后说明:避免使用etextools。据我所知,它有缺陷,而且作者已经放弃了它。

etextools无论如何, TeX Live 提供的版本是

Package: etextools 2010/12/07 v3.1415926 e-TeX more useful tools for LaTeX package writers

我不知道有新版本。

相关内容