如何正确放置标签并在乳胶中使用交叉引用以能够使用pandoc转换为html(5)? [英] How to place labels correctly and use cross-reference in latex to be able to convert to html(5) using pandoc?
问题描述
我想在乳胶中创建源代码,以便通过pdflatex生成pdf,并通过pandoc生成html页面.我使用以下来源
I'd like to create source code in latex in order to produce pdf via pdflatex and html page(s) via pandoc. I use the following source
\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进行编译,而不会出现任何错误或警告.
This can be compiled with pdflatex without any error or warning.
我使用以下代码通过pandoc创建html页面:
I create the html page via pandoc using the following code:
pandoc -f latex sample.tex -t html5 -o sample.html -S --toc -s
但它会在标签和参考周围产生不令人满意的结果
but it creates unsatisfactory results around the label and the reference:
<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>
问题
我应该在乳胶源代码中进行哪些修改,以获得类似这样的内容:
Question
What shall I modify in the latex source code in order to get something like this:
<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>
推荐答案
我应该在乳胶源代码中修改什么[...]
What shall I modify in the latex source code [...]
Pandoc当前不支持解析和处理LaTeX文件中的 \ label {...}
或 \ ref {...}
解决问题的方法.
Pandoc does currently not support parsing and processing of \label{...}
or \ref{...}
from LaTeX files, so there is no easy solution to your problem.
这篇关于如何正确放置标签并在乳胶中使用交叉引用以能够使用pandoc转换为html(5)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!