Skip to Content

Digital Accessibility

Using Pandoc to Convert LaTeX to HTML and MathML

Pandoc is a document converter that makes it easy to convert your LaTeX document into an accessible HTML format that can be uploaded to Blackboard.

Example Pandoc Conversion

Following the instructions for creating accessible LaTeX, say we have the following LaTeX: 

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[english]{babel}

\title{Quadratic Functions}
\author{Mary Prouty}

\begin{document}

% The document title becomes a heading level 1 when converted to HTML.
\maketitle

\section*{Problem 1}
Given the quadratic formula: $$x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}$$ Determine the maximum or minimum of \(y\):
\begin{equation}
y = -4x^2 + 24x - 35
\end{equation}

\pagebreak
\section*{Problem 2}
What is the y-intercept of the following function?

\begin{figure}[h!]
\centering
% Alt text makes the graph accessible to screen reader users with visual or cognitive disabilities.
\includegraphics[alt={Line graph of f(x)}, width=0.8\textwidth]{quadratic_equation_graph.png}
\caption{f(x)}
\end{figure}

% The data table presents the same data as the graph, but in a format that screen readers can navigate.
\begin{table}[!h]
\centering
\begin{tabular}{|c|c|}
\hline
\textbf{y} & \textbf{x} \\
\hline
$4$ & $-2$ \\
$1$ & $-1$ \\
$0$ & $0$ \\
$1$ & $1$ \\
$4$ & $2$ \\
\hline
\end{tabular}
\caption{f(x)}
\end{table}

\end{document}

We can input this LaTeX into Pandoc to convert it to HTML and MathML:

  1. Navigate to Pandoc online
  2. Select the options: from latex to html5, Standalone, and MathML
    Screenshot of Try pandoc! with the following options selected: latex, html5, Standalone, and MathML.
  3. Upload your TeX file or paste your TeX into the text editor
  4. Select the Convert button
  5. Select download trypandoc.html and rename your file accordingly.

You should now have an accessible HTML format from your LaTeX, with any math marked up in accessible MathML.

Pro tip: If you're feeling tech savvy, you can install Pandoc to use its more robust command line interface instead of the webapp.


Uploading to Blackboard

You can upload your HTML file to Blackboard just as you would upload any other file or document; however, if your LaTeX includes any images, you will need to upload those to Blackboard separately so that the HTML has access to the images.

Avoid using Pandoc's Embed Resources option because Blackboard will not allow you to upload the resulting HTML when this option is selected for embedding images.


Limitations with Pandoc

As a universal document converter, Pandoc does not specialize in the conversion of LaTeX to HTML and MathML. It may ignore some LaTeX packages and commands that it does not recognize. 

LaTeXML may be a better fit for you if you are writing a number of custom macros.


Challenge the conventional. Create the exceptional. No Limits.

©