標籤之間的捕獲文件不起作用

標籤之間的捕獲文件不起作用

根據catchfilebetweentags套件命令的描述\ExecuteMetaData*[<file>]{tag}應該做同樣的工作,但也取消註解''以 single開頭\ExecuteMetaData[<file>]{tag}的註解行。%文件:

\documentclass{article}
\usepackage{catchfilebetweentags}
\begin{document}
\ExecuteMetaData*[example.tex]{tag}
\end{document}

具有以下檔案 example.tex:

%<*tag>
some text 
%some more text
%</tag>

應該產生輸出:

一些文字 更多文字

不幸的是,在 Texmaker 中它給出了:

[example.tex]標籤

而在 Overleaf 中,它編譯了 30 秒,並彈出逾時錯誤。如何解決這個問題?

答案1

抱歉,但沒有解決方法。考慮這個例子

\begin{filecontents*}{\jobname-example}
%<*tag>
some text 
%some more text
%</tag>

\end{filecontents*}

\documentclass{article}
\usepackage{catchfilebetweentags}

\begin{document}

\tracingmacros=1 % for debugging

\CatchFileBetweenTags{\foo}{\jobname-example.tex}{tag}\show\foo

\CatchFileBetweenTags*{\foo}{\jobname-example.tex}{tag}

%\ExecuteMetaData[\jobname-example.tex]{tag}

\end{document}

第一個\CatchFileBetweenTags開始於

\CatchFileBetweenTags #1#2#3->\CatchFileBetweenDelims \CatchFBT@tok {#2}{%<*#3>}{%</#3>}[\CatchFBT@sanitize ]\CatchFBT@Final {#1}
#1<-\foo 
#2<-\jobname -example.tex
#3<-tag

而第二個有

\CatchFileBetweenTags #1#2#3->\CatchFileBetweenDelims \CatchFBT@tok {#2}{%<*#3>}{%</#3>}[\CatchFBT@sanitize ]\CatchFBT@Final {#1}
#1<-*
#2<-\foo 
#3<-\jobname -example.tex

你可以清楚地看到有些問題。

更糟的是: 的定義\ExecuteMetaData

% catchfilebetweentags.sty, line 53:
\newrobustcmd*\ExecuteMetaData[2][\jobname]{%
   \CatchFileBetweenTags\CatchFBT@tok{#1}{#2}%
   \global\expandafter\CatchFBT@tok\expandafter{%
            \expandafter}\the\CatchFBT@tok
}% \ExecuteMetaData

所以有根本沒有任何規定用於區分\ExecuteMetaData\ExecuteMetaData*

顯然,作者記錄了他對該包的願望,但忘記了實現它們。

相關內容