英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论