Pandoc latex to other formats: is there an out-of-the-box way to preserve selected latex commands? (in particular \ref)

huangapple go评论53阅读模式
英文:

Pandoc latex to other formats: is there an out-of-the-box way to preserve selected latex commands? (in particular \ref)

问题

I want to convert old lecture notes from LaTeX to markdown, in order to use them in quarto afterwards. I would like to preserve the raw LaTeX references, \ref{some-label} and possibly also other raw LaTeX commands. Is there a canonical way to do that, or should I write a filter?

Minimal example: pandoc minimal.tex -o minimal.md

with
minimal.tex

\documentclass{article}
\begin{document}
Refer to **example** \ref{example1}, blabla
\end{document}

gives
minimal.md

Refer to **example** \[example1\], blabla

but I want

Refer to **example** \ref{example1}, blabla

p.s. The reason why I want to preserve references is, that I want to use my own filter to resolve them.

英文:

I want to convert old lecture notes from LaTeX to markdown, in order to use them in quarto afterwards. I would like to preserve the raw LaTeX references, \ref{some-label} and possibly also other raw LaTeX commands. Is there a canonical way to do that, or should I write a filter?

Minimal example: pandoc minimal.tex -o minimal.md

with
minimal.tex

\documentclass{article}
\begin{document}
Refer to \textbf{example} \ref{example1}, blabla
\end{document}

gives
minimal.md

Refer to **example** [\[example1\]](#example1){reference-type="ref"
reference="example1"}, blabla

but I want

Refer to **example** \ref{example1}, blabla

p.s. The reason why I want to preserve references is, that I want to use my own filter to resolve them.

答案1

得分: 1

"raw_tex"扩展将导致所有未知或难以转换的TeX命令被传递为原始元素:

% pandoc --from=latex+raw_tex minimal.tex
参见**示例**`\ref{example1}`{=latex},blabla

然后,通过过滤"RawInline"和"RawBlock"元素,可以以任何您认为合适的方式处理这些元素。

英文:

The raw_tex extension will cause all unknown or difficult to convert TeX commands to be passed through as raw elements:

% pandoc --from=latex+raw_tex minimal.tex
Refer to **example** `\ref{example1}`{=latex}, blabla

Filtering on RawInline and RawBlock elements then allows to process these elements in whatever way you see fit.

huangapple
  • 本文由 发表于 2023年5月20日 20:44:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76295293.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定