![\lstlisting 中的代码破坏了文档(编译错误)](https://linux22.com/image/263945/%5Clstlisting%20%E4%B8%AD%E7%9A%84%E4%BB%A3%E7%A0%81%E7%A0%B4%E5%9D%8F%E4%BA%86%E6%96%87%E6%A1%A3%EF%BC%88%E7%BC%96%E8%AF%91%E9%94%99%E8%AF%AF%EF%BC%89.png)
我想在文档中显示 JSON 对象。如果我执行以下操作,它就会起作用:
\begin{lstlisting}
{
"id": "5",
"key": "discardedCard"
}
\end{lstlisting}
但是如果我将代码扩展为如下形式,则编译文档时只会出现错误:
\begin{lstlisting}
{
"id": "5",
"key": "discardedCard",
"value": {
"suit": "DIAMONDS",
"rank": "QUEEN"
}
}
\end{lstlisting}
错误日志:
! Incomplete \iffalse; all text was ignored after line 19.
<inserted text>
\fi
l.19 "
suit": "DIAMONDS",
A forbidden control sequence occurred in skipped text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.
! Incomplete \iffalse; all text was ignored after line 19.
我想提供 MWE,但如果我在 MWE 中运行代码,它就会起作用。因此,看起来我的学士论文中的其他部分破坏了文档。
有没有办法以安全的方式输出列表中的代码或者可能转义?
答案1
我猜你有一个语言简写(babel?)定义"
做某事,你可以在本地关闭简写,这可能会有所帮助