Pandoc LaTeX Conversion Process

Converting TeX Files

Pandoc can be used to convert file types and most commonly is used to convert .tex files to .docx or .html. 

Note: this process varies slightly between PC and Mac. The Using Pandoc video gives a good overview of the steps for both.

Install Pandoc

Pandoc Installer

Pandoc must be installed on your computer in order to convert files. 

File Setup

To begin this file conversion process, place the original file to be converted on your Desktop. The file name cannot include spaces. Copy the entire file name (ex. “Module_11.tex”). 

Command Prompt or Mac Terminal

To use Pandoc, do not open the program directly. Instead, enter text-based commands into either Windows Command Prompt or the Mac Terminal. 

In Windows and Mac, begin by typing “cd desktop” to use Pandoc on files on your desktop. 

The file conversion command must be formatted as follows:

pandoc filename.tex -s -o filename.extension

Beginning with “pandoc” will run the Pandoc program. Then, you will list the file name of the file to be converted. “-s” will produce a standalone document, and “-o" tells Pandoc to output to a file. Finally, end with the name of the file you want to create.

Conversion Command Examples


pandoc Module_11.tex -s -o Module_11.docx

HTML using MathML:

pandoc Assignment-6.tex -s --mathml -o Assignment6_mathml.html

Common Command Errors

This command process commonly produces an error that there is an unexpected \hbox{\strut} on a specific line of the .tex file. Edit the .tex file to remove the \hbox{\strut} text. Notepad++ is a free code editor that may be used to complete this step. Save the edited file, and insert the pandoc command again.

You also may encounter the error “unexpected \end” referring to the \end{document} code. To troubleshoot this, try moving the \end{document} code to different locations progressively from the end of the document towards the beginning of the document. At each location, attempt the Pandoc conversion. If the error persists, the LaTeX problem is still within the parameters of \begin and \end{document} and this troubleshooting should continue. Once the Pandoc conversion is successful, this should help isolate the area of the file where the problem is located. Common LaTeX problems that would cause this are an unclosed curly bracket ( { ) or an unintended special character ( % ).

Format the Final Version of the Converted File

After converting .tex to your desired file type, there is some formatting required to apply EP templates and/or pull in any images that were in the original file.

For Word files, copy all the text in your new “Module_11.docx” and paste it into our Word template. Apply heading styles as needed. Equations will be in Word’s built-in equation editor. Ensure that all equations are in professional display, rather than LaTeX. Insert any images as needed and inline with text.

For HTML or Canvas pages, paste the HTML code into the HTML editor and apply appropriate headings. The first heading on a Canvas page should be an <h2>. For any equations that did not convert correctly, use the original LaTeX or EquatIO’s screenshot tool to copy the correct equation code and insert into Canvas. MathML can be inserted directly into the HTML editor. LaTeX can be inserted directly onto the Canvas page but must include LaTeX delimiters $$ or /(. \(...\) format indicates the equation should be in an inline format; $$...$$ format indicates the equation should be in a block format.

Refer to a pre-existing PDF version of the .tex file or the compiled view in Overleaf to verify any equation numbering that may have been lost during the conversion.


Pandoc demos

Pandoc Installer

Pandoc User’s Guide

Using Pandoc (YouTube Video)

Making Equations in Online Learning Accessible

Overleaf Professional Accounts at WSE

Overleaf Tips and Tricks for Troubleshooting LaTeX

Was this article helpful?
0 out of 0 found this helpful