简介
我想在乳胶中创建源代码,以便通过pdflatex生成pdf,通过pandoc生成html页面。我使用以下来源
documentclass[12pt,a4paper]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[magyar]{babel}
usepackage{hyperref}
begin{document}
begin{enumerate}
item label{itm:thefirst}
First example point
end{enumerate}
This is an example to demonstrate how textbackslash label{} and textbackslash ref{} are not working with pandoc. Here should be a reference to the first example: ref{itm:thefirst}
end{document}
这可以用pdflatex编译,没有任何错误或警告。
问题
我使用以下代码通过 pandoc 创建 html 页面:
pandoc -f latex sample.tex -t html5 -o sample.html -S --toc -s
但它在标签和参考周围会产生不令人满意的结果:
<body>
<ol>
<li><p>[itm:thefirst] First example point</p></li>
</ol>
<p>This is an example to demonstrate how label{} and ref{} are not working with pandoc. Here should be a reference to the first example: [itm:thefirst]</p>
</body>
问题
我应该在乳胶源代码中修改什么才能得到这样的东西:
<body>
<ol>
<li><p id="itm:thefirst">First example point</p></li>
</ol>
<p>This is an example to demonstrate how label{} and ref{} are not working with pandoc. Here should be a reference to the first example: <a href="#itm:thefirst">(1)</a></p>
</body>
我应该在乳胶源代码中修改什么 [...]
Pandoc 目前不支持解析和处理 LaTeX 文件中的label{...}
或ref{...}
,因此没有简单的解决方案来解决您的问题。
为什么不走另一条路呢?
与其用LaTeX编写源代码,不如在Markdown中编写它们。
这样,我将更容易将源代码转换为HTML以及LaTeX和PDF。
作为奖励,您还可以获得一流的支持,将源代码转换为 EPUB、DOCX、ODT 等等。