2

I am trying to use pandoc to convert a latex file into an html file with math rendered via mathjax or mathml. I would like to simultaneously provide cross-references to both numbered amsthm theorems and numbered equations. It seems that I can get only one of these two to work at a time. Either a cross-reference to a numbered theorem or a cross-reference to a numbered equation. But not both. Below is my MWE.

\documentclass[11pt]{article} \usepackage{amsthm} \newtheorem{thm}{Theorem} \begin{document} \title{This is a test document} \begin{thm} \label{mythm} This is a theorem. \end{thm} \begin{proof} Easy. \end{proof} Theorem \ref{mythm} is correct. \begin{equation} \label{myequation} a+b=c. \end{equation} Equation \ref{myequation} is also correct. \end{document} 

I am executing this using either

pandoc --filter pandoc-tex-numbering test.tex -f latex -t html -s -o test.html --mathjax -crossref 

or

pandoc test.tex -f latex -t html -s -o test.html --mathjax -crossref 

at the Terminal command line on macOS Sonoma 14.5. The former command produces this output. Output from the MWE using the first pandoc command. The latter command produces this output. Output from the MWE using the second pandoc command.

So, it seems that the pandoc-tex-numbering filter is suppressing the cross-reference to the amsthm Theorem, whereas removing that filter eliminates the equation numbering as well as the equation cross-reference. Do you have any suggestions for how I can make this work? I am willing to use other pandoc filters if needed. I am using pandoc version 3.6.3.

2
  • 1
    Welcome to TeX.SE. Commented Mar 2 at 12:20
  • 1
    I'm the author of pandoc-tex-numbering. I've decided to support theorem numbering and am working on it. This wont take too long. Commented Mar 13 at 4:54

1 Answer 1

2

I'm the author of pandoc-tex-numbering. I'm glad to inform you that in the newest released v1.2.5, we have now supported numbering of theorems.

Numbering of theorems in pandoc is a little complicated since, in terms of filters, we CANNOT get access to your \newtheorem declaration in your raw latex files (we can via raw_tex, by it may cause much more issues, for example, in case of subfiles). Current solution is that you must tell the filter what theorems you've declared with metadata.

Make sure you have a newer version of pandoc-tex-numbering:

pip install pandoc-tex-numbering>=1.2.5 -U 

With your codes in test.tex:

pandoc -F pandoc-tex-numbering -i test.tex -o out.docx -M theorem-names="thm" 

You get this:

your test document

If you encountered any further problems, feel free to open an issue here.

3
  • Thank you for releasing a new version of pandoc-tex-numbering to address my question. I am able to produce docx output as you displayed. However, the html output is rendered incorrectly. The equation a+b=c does not appear on a new line. It appears on the same line as the text preceding it. I can provide a screenshot of my html output if needed. Commented Mar 14 at 19:23
  • @DeepBlue Insert line breaks before and after your equation environment. pandoc will recognize all equations without line breaks as an inline math. I cannot override this behavior as a filter of pandoc. See also a previous issue of pandoc-tex-numbering. Commented Mar 15 at 7:10
  • Thanks. That worked. Commented Mar 23 at 3:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.