【问题标题】:Markdown and references inside the listing captions列表标题中的降价和引用
【发布时间】:2020-04-26 03:15:06
【问题描述】:

是否可以在 pandoc 中处理列表标题的文本标记?

Pandoc 适用于图形标题并翻译 emphasisinline code,但在列出标题时显然没有这样做。 例如,在下面的代码中,我在第二个清单和图形的标题中进行了一些格式设置和引用。 但是,只有图中的格式被正确转换为latex。 列表标题保持原样,这会在管道中破坏 tex 处理器。

是否可以像处理图片标题一样处理列表标题?


    ```{#lst:first .C caption="Hi"}
    int hi() {
        return ((int)'h'<<8) | 'i';
    }
    ```

    ```{#lst:second .C caption="Code *using* the function `hi` from [@lst:first]"}
    x = hi();
    ```

    ![Picture *with* `inline code` and reference [@lst:first]](picture.png)

pandoc example.so.md -o example.so.tex --listings --filter=pandoc-crossref

生产:

\begin{codelisting}

\caption{Hi}

\begin{lstlisting}[language=C, caption=Hi, label=lst:first]
int hi() {
    return ((int)'h'<<8) | 'i';
}
\end{lstlisting}

\end{codelisting}

\begin{codelisting}

\caption{Code *using* the function `hi` from {[}@lst:first{]}}

\begin{lstlisting}[language=C, caption={Code *using* the function `hi` from [@lst:first]}, label=lst:second]
x = hi();
\end{lstlisting}

\end{codelisting}

\begin{figure}
\centering
\includegraphics{picture.png}
\caption{Picture \emph{with} \passthrough{\lstinline!inline code!} and
reference lst.~\ref{lst:first}}
\end{figure}

我使用 pandoc 2.7.3 和 pandoc-crossref v0.3.4.1

附:正如https://github.com/jgm/pandoc/issues/673 建议的那样,可能仍然没有对此的本机支持。有解决办法吗?

【问题讨论】:

    标签: latex markdown pandoc cross-reference


    【解决方案1】:

    K4zuki 对 pandoc google 小组的回复对我有用。(https://groups.google.com/forum/#!msg/pandoc-discuss/DItTuL5S1EM/L1Ou25gTCAAJ)

    使用此处解释的 pandoc-crossref 选项:http://lierdakil.github.io/pandoc-crossref/#table-style-captions 在元数据块中添加codeBlockCaptions: true 或使用-M codeBlockCaptions=true 运行pandoc

    这行得通:

    Listing: Code *using* the function `hi` from [@lst:first]
    
    ```{#lst:second .C}
    x = hi();
    ```
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-06
      • 1970-01-01
      • 1970-01-01
      • 2013-09-01
      • 1970-01-01
      相关资源
      最近更新 更多