
我有\VerbatimInput
一個文件調用test.dat
,如下所示:
\documentclass[12pt]{article}
\usepackage[left=2.5cm,top=2.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\usepackage{fancyvrb}
\usepackage{color,soul}
\usepackage[dvipsnames]{xcolor}
\begin{document}
\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}%
{fontsize=\footnotesize,
%
frame=lines, % top and bottom rule only
framesep=2em, % separation between frame and text
rulecolor=\color{Gray},
%
label=\fbox{\color{Black}test.dat},
labelposition=topline,
%
commandchars=\|\(\), % escape character and argument delimiters for
% commands within the verbatim
commentchar=* % comment character
}
\VerbatimInput{./test.dat}
\end{document}
該test.dat
文件如下:
#l.77:
TEST11
A3
(EL = 4) # this is compiled ok
mH/(C*K) # this is not compiled, giving that error
由於( * )
符號的原因,編譯會出現以下錯誤:
Runaway definition?
-> mH/(C
! File ended within \read.
<read 1>
l.97 \VerbatimInput{./test.dat}
我怎麼能編譯這個?
答案1
首先我要說的是我\VerbatimInput
自己並沒有實際使用過。但是,您發布的那段程式碼看起來與以下答案中發布的程式碼完全相同:逐字包含 .txt 中的數據
引用作者的話:
- 指定
|
and(
/)
作為轉義字元和參數分隔符號表示這些符號不能作為逐字文字的一部分出現(或在本例中為 data.txt 的內容);- data.txt 中的星號行透過指定
*
為註解字元被刪除(類似%
LaTeX);
換句話說,您複製的程式碼賦予這四個字元特殊的含義,因此它不能用於包含它們的檔案。
似乎執行此操作的行是:
commandchars=\|\(\), % escape character and argument delimiters for
% commands within the verbatim
commentchar=* % comment character
因此,我建議從您的程式碼中刪除這些字符,或將這些字符替換為文件中未出現的其他字符。