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:



    There is no largest prime number.

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">
   <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" />
   <style type="text/css">code{white-space: pre;}</style>
   <p>There is no largest prime number.</p>

which is (correctly) rendered to:

enter image description here

The pandoc version I used is pandoc

  • Could you provide a MWE ? A document sample in tex format, and maybe also what command you use, what version of pandoc, a screenshot of the output, or the expected output ?
    – Clément
    Apr 11, 2017 at 14:43
  • 1
    Is using htlatex instead of pandoc an option? Something like htlatex MWE_pandoc.tex "xhtml, mathml, charset=utf-8" " -cunihtf -utf8" might do the job (at least, something like "Theorem 1" is written)
    – Clément
    Apr 11, 2017 at 14:54
  • 3
    Actually, there has been some worked toward supporting amsmath in pandoc, cf. github.com/jgm/pandoc/issues/1608 and github.com/ickc/pandoc-amsthm and ickc.github.io/pandoc-amsthm, but it looks like it is only from markdown to latex and html, not from latex to html
    – Clément
    Apr 11, 2017 at 15:00
  • @Clément: Thank you! htlatex might indeed be an option.
    – Christian
    Apr 11, 2017 at 15:01
  • @Christian this feature has been added in pandoc 2.10.1 (2020-07-23), see the release notes and my post below.
    – el_tenedor
    Mar 30, 2022 at 8:30

2 Answers 2


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"  
<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" /> 
  <div class="newtheorem">
<!--l. 7--><p class="noindent" ><span class="head">
class="cmbx-10x-x-109">Theorem 1.</span>  </span><span 
class="cmti-10x-x-109">There is no largest prime number.</span>


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…

  • tex4ht supports html5 in fact, but not by default. You can try html5 option.
    – michal.h21
    Apr 11, 2017 at 15:24
  • and command used to compile the example can be simplified to make4ht -u MWE_pandoc.tex "html5,mathml"
    – michal.h21
    Apr 11, 2017 at 15:26
  • 1
    when used with htlatex, html5 can be requested like this: htlatex filename.tex "xhtml,html5". The docs haven't been updated yet, unfortunately.
    – michal.h21
    Apr 11, 2017 at 15:29
  • 1
    the code of tex4ht is updated regularly, but the fixes goes directly to TeX Live, not to CTAN, so the updates aren't visible at the first sight. This is quite unfortunate, but there are some issues which prevents us from CTAN update.
    – michal.h21
    Apr 11, 2017 at 15:45
  • 1
    @Clément Thank you for your answer. I will look into tex4ht. In case someone knows a pandoc solution I will wait a little bit before I accept the answer.
    – Christian
    Apr 11, 2017 at 20:11

It seems that the issue no longer exists with newer versions of pandoc (OP raising the question in 2017 and using pandoc


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

generates the HTML <body>

<div class="theorem">
<p><strong>Theorem 1</strong>.  <em>There is no largest prime number.</em></p>


enter image description here

To sum up, when properly called, pandoc will generate:

  • enclosing <div class="theorem"> tag that can be used for further styling
  • typesetting in of the theorem's name (bold) and body (italic)

MWE Tested with pandoc --version:

Compiled with pandoc-types 1.22.1, texmath 0.12.4, skylighting 0.12.2,
citeproc, ipynb 0.2


I also tested the available pandoc/core Docker images and the above should work for pandoc --version >= 2.10.1, i.e. pandoc/core:2.10.1 and subsequent versions.

According to the release notes, the feature was added in pandoc 2.10.1 (2020-07-23). Search for LaTeX reader in order to spot further improvements over time.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .