Pandoc 使用 .html 中的包 \lstinputlisting 转换 Latex 文档

问题描述 投票:0回答:1

我尝试使用 pandoc 转换 Latex 文档为 html,但出现以下错误:

unexpected 

\lstinputlisting[

是否可以将 \lstinputlisting 与 Pandoc 一起使用?

我的代码main.tex如下:

\usepackage{listings}
\lstinputlisting[
    float,
    language=Java,
    caption={My very first program in Java},
    label={lst:helloworld},
]{listings/HelloWorld.java}

in \Cref{lst:helloworld}, we describe an hello world program in Java.
latex pandoc listings
1个回答
0
投票

我解决了将

--listings
添加到 Pandoc 转换并删除参数中的新行的问题。看起来 Latex 可以解释它们,但不能解释 Pandoc。

\usepackage{listings}

\lstinputlisting[float,language=Java,caption={My very first program in Java},label={lst:helloworld},]{listings/HelloWorld.java}

in \Cref{lst:helloworld}, we describe an hello world program in Java.
© www.soinside.com 2019 - 2024. All rights reserved.