在我的 Latex 文件中:
\lstinputlisting[caption={Pascal Quellcode HashFunctionsTest.pas}]{../source/HashFunctions.pas}
错误:
[{
"owner": "LaTeX",
"severity": 8,
"message": "Extra }, or forgotten $.\n {$Q-}\n",
"source": "LaTeX",
"startLineNumber": 29,
"startColumn": 1,
"endLineNumber": 29,
"endColumn": 65536
}
我的第一风格
\lstdefinestyle{sourceCodeBlock}{
backgroundcolor=\color{backcolour},
keywordstyle=\color{codeblue},
commentstyle=\color{codegreen},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=true,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
morekeywords={*, UNIT, INTERFACE, IMPLEMENTATION, USES, BREAK, WORD, LONGINT}, mathescape=true,
}
导致问题的源文件:
IF (m = 0) THEN BEGIN
Powers := 1;
END ELSE BEGIN
result := x;
FOR i := 1 TO (m - 1) DO BEGIN
{$Q-} (* Disable Overflow Checks *)
result := result * x;
{$Q+} (* Enable Overflow Checks *)
END; (* FOR *)
IF (result = 0) THEN BEGIN
result := x;
END; (* IF *)
Powers := result;
END; (* IF *)
现在我的源代码显然被 LaTeX 错误地解释。我该如何禁用它?
答案1
禁用转义全部有效
% List Style for Code Blocks
\lstdefinestyle{sourceCodeBlock}{
backgroundcolor=\color{backcolour},
keywordstyle=\color{codeblue},
commentstyle=\color{codegreen},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=true,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
morekeywords={*, UNIT, INTERFACE, IMPLEMENTATION, USES, BREAK, WORD, LONGINT},
inputencoding=utf8,
extendedchars=true
escapeinside={},
mathescape=false,
texcl=false
}