Search code examples
latexmarkdowndocxpandoc

Mathematics not working when converting from LaTeX to docx (through markdown) using pandoc


Does anyone have a suggestion as to why I am unable to convert the simple latex file shown below to docx using pandoc (version 1.12.4.2, Compiled with texmath 0.6.6.3, highlighting-kate 0.5.11.1).

\documentclass{article}

\begin{document}

\begin{equation}
  1+1
\end{equation}

\end{document}

The pandoc commands I have used are:

pandoc --from=latex --to=markdown --output=FILE.md FILE.tex
pandoc --from=markdown+tex_math_dollars --to=docx --output=FILE.docx FILE.md

The result from the first command (the markdown file) is a file consisting of a single line: "$$1+1$$". The second command, which is supposed to produce the docx document, is empty.


Solution

  • This turned out to be one of those cases where the strategy "when in doubt re-install" does the trick. I lay the blame on OS-X Yosemite, it has been a "problematic child" since its inception.

    Pandoc is dependent on an arsenal of haskell libraries and somewhere in the macports installation "something" must have gone wrong. I therefore uninstalled pandoc and all dependent packages as follows:

    usr@cmptr $ sudo port uninstall --follow-dependents pandoc
    

    Note --follow-dependents not --follow-dependencies, the latter is only for people who know what they are doing (read more).

    EDIT

    The pandoc version from mac Ports is often severely lagging compared the development. The reason for this is probably that the development is happening quite rapidly at the moment; therefore one can consider to install pandoc using the haskell "cabal" repository:

    usr@cmptr $ sudo port install cabal
    usr@cmptr $ cabal update
    usr@cmptr $ cabal install pandoc
    

    Also enable bibliography:

    usr@cmptr $ cabal install pandoc-citeproc
    

    And finally enable cross referencing (markdown notation, LaTeX -> Markdown conversion still iffy):

    usr@cmptr $ cabal install pandoc-crossref
    

    Add pandoc to $PATH:

    usr@cmptr $ export PATH="${PATH}:${HOME}/.cabal/bin/" >> ${HOME}/.bashrc