How to place labels and use cross-references in latex in order to be able to convert to html (5) using pandoc?

Introduction

I would like to create the source code in latex in order to create a pdf via pdflatex and an html page through 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} 

This can be compiled using pdflatex without any errors or warnings.

Problem

I am creating an html page through 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 link:

 <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 should I change in the latex source code 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> 
0
html latex cross-reference pandoc
Mar 16 '15 at 21:02
source share
2 answers

What should I change in the latex source code [...]

Pandoc does not currently parse and process \label{...} or \ref{...} from LaTeX files, so there is no easy solution to your problem.

+1
Mar 17 '15 at 11:25
source share

Why not go an alternative way?

Instead of writing sources in LaTeX, write them in Markdown.

Thus, it will be much easier for me to convert sources to HTML, as well as to LaTeX and PDF.

As a bonus, you also get first-class support for converting sources to EPUB, DOCX, ODT and much more ....

0
May 7, '15 at 1:30 pm
source share



All Articles