[Tex/LaTex] Pandoc LaTeX to HTML and theorem environments

amsthmpandoc

I am using Pandoc to convert LaTeX files to HTML files. Since these LaTeX files are mathematical documents, they contain theorem-like environments using amsthm. In the output HTML files these environments are missing.

More precisely, the contents of the environments are there but e.g. the word "Theorem" and the theorem number are missing.

Is there a way to automatically convert these environments as well?

Edit: Please find below a MWE:

\documentclass{scrartcl}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}

\begin{document}
  \begin{theorem}
    There is no largest prime number.
  \end{theorem}
\end{document}

which is compiled by pdflatex to (which is the desired output)
enter image description here

Using pandoc with the command

pandoc MWE_pandoc.tex -f latex -s --mathjax -o MWE_pandoc.html

this generates the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta http-equiv="Content-Style-Type" content="text/css" />
   <meta name="generator" content="pandoc" />
   <title></title>
   <style type="text/css">code{white-space: pre;}</style>
 </head>
 <body>
   <p>There is no largest prime number.</p>
 </body>

which is (correctly) rendered to:

enter image description here

The pandoc version I used is pandoc 1.16.0.2

Best Answer

Your MWE_pandoc.tex document, when processed with tex4ht, using

 make4ht -u MWE_pandoc.tex "html5,mathml"

(see this page for other options) gives:

<?xml version="1.0" encoding="utf-8" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" 
"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd" > 
<html xmlns="http://www.w3.org/1999/xhtml"  
> 
<head><title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)" /> 
<!-- xhtml,html5,mathml,charset=utf-8,html --> 
<meta name="src" content="MWE_pandoc.tex" /> 
<link rel="stylesheet" type="text/css" href="MWE_pandoc.css" /> 
</head><body 
>
  <div class="newtheorem">
<!--l. 7--><p class="noindent" ><span class="head">
<a 
 id="x1-2r1"></a>
<span 
class="cmbx-10x-x-109">Theorem 1.</span>  </span><span 
class="cmti-10x-x-109">There is no largest prime number.</span>
</p>
  </div>

</body></html> 

which is rendered as

enter image description here

As a side note, I find pandoc more flexible to use, so if I were you, I would watch this topic on github, to see if a reliable interface amsmath / pandoc sees the day. But that's probably just a matter of personal taste…

Related Question