我尝试使用以下最小示例测试包catchfilebetweentags
,但出现编译错误。这里出了什么问题?如何修复?
内容catch_main.tex
\documentclass{article}%
\usepackage{catchfilebetweentags}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\CatchFBT@Fin@l}{\endlinechar\m@ne}{}
{}{\typeout{Unsuccessful patch!}}
\makeatother
\begin{document}
\ExecuteMetaData[inputfile]{mytag1}
\ExecuteMetaData[inputfile]{mytag1}
\ExecuteMetaData[inputfile]{mytag2}
\end{document}
内容inputfile.tex
\documentclass{article}%
\begin{document}
Some text.
%<*mytag1>
This is the text for mytag1.
% </mytag1>
%<*mytag2>
This is the other text for mytag2.
% </mytag2>
\end{document}
编译器消息:
Running `LaTeX' on `catch_main' with ``pdflatex -file-line-error -interaction=nonstopmode "\input" catch_main.tex''
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 81 language(s) loaded.
(./catch_main.tex (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/catchfilebetweentags/catchfilebetweentags.sty (/usr/share/texlive/texmf-dist/tex/latex/etex-pkg/etex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/catchfile.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty))))
(./catch_main.aux) (./inputfile.tex)
Runaway text?
This is the text for mytag1. \par This is the other text for mytag2.\ETC.
./catch_main.tex:11: File ended while scanning text of \CatchFBT@tok.
<inserted text>
}
l.11 \ExecuteMetaData[inputfile]{mytag1}
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./catch_main.aux) )
(see the transcript file for additional information)</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on catch_main.pdf (1 page, 13823 bytes).
Transcript written on catch_main.log.
TeX Output exited abnormally with code 1 at Sat Jul 23 16:50:02
答案1
存在语法错误inputfile.tex
。结束标记不应包含空格:
% </mytag1>
⇒%</mytag1>
修正版本inputfile.tex
:
\documentclass{article}%
\begin{document}
Some text.
%<*mytag1>
This is the text for mytag1.
%</mytag1>
%<*mytag2>
This is the other text for mytag2.
%</mytag2>
\end{document}