Rendering Latex tables in Hugo

Rendering Latex tables in Hugo

Thank you so much @spf13 and the entire community that has been developing Hugo and providing support! I’ve started using Hugo for a project and the speed, capacity and convenience of it are amazing! After this project I’ll start using Hugo for my personal website as well.

Here’s my question: Is it possible to render Latex tables in Hugo and if so how?

I am creating a documentation website using Hugo v0.16 BuildDate: 2016-06-06T13:29:38+01:00 and the Material Docs theme by digitalcraftsman.

The original content of the documentation was in Latex and I have ported it to Markdown. However, it contains complex tables with different column sizes within the same table (using Latex’ \multicolumn). Since Markdown does not support such complex table structures, I chose to keep the tables in the original Latex inside otherwise Markdown content files. I need the capacity for complex tables and I figure it’s easier for my social sciences colleagues to keep authoring new tables in Latex as opposed to HTML when expanding the documentation website.

What I tried

Without any modification

Without any modification a Latex table is rendered as plain text.

With MathJax support enabled

I followed the instructions to enable Hugo’s MathJax support found here in the Hugo documentation.

With that enabled my table looks like this:

It’s apparent that MathJax is doing something with the Latex code. It creates a kind of box, perhaps recognizing that there should be a figure here. But the code is still rendered as plain text.

Please help!

I’d greatly appreciate any help or advice on how to render Latex tables in Hugo!

For reference, here’s the code I used in the examples above:

1 & 1 \\
2 & 2 \\
3 & 3 \\
4 & 4 \\
5 & 5 \\

Thank you!


1 Like

Looks like you’ll have to use something like this:
I checked the blackfriday docs: - under extensions

Thank you so much, @justrjlewis! I’ll have to take a closer look at blackfriday. For now, what I’m reading there goes over my head.

And it’s not clear from their documentation whether complex tables with changing cell structure are supported. Simple tables like the one given there are already supported by Hugo afaik.

I realize now it may be misleading that I gave a simple table as an example myself. What I ultimately want to display looks something like this:

Note how the selected text is a single cell sitting atop two separate cells.

I just played with it and wasn’t able to make a structure that complex. Not saying it can’t be done, but I wasn’t able to figure out how. Sorry.

Thank you so much for your help. I appreciate it!

The main trouble your having in the original example is that MathJax is rendering LaTeX math mode, whereas tables in LaTeX are in table environments, rather than math environments.

Do you need to render the table in HTML rather than doing it in LaTeX, typesetting to PDF, and including the table as an image?

Otherwise, you might construct the table in LaTeX, and then try using Pandoc to convert it to HTML, and include that output?

Thank you so much @chreliot!

Problem is, I’m creating a process that allows my colleagues to author documentation in Markdown that then is used to generate both printable pdfs and the website from the same modifiable source files.

I also need to create a somewhat straightforward process that allows them to port existing documentations from Latex to Markdown.

Thus, I’m stuck with markdown as output format and coming with a most mass-applicable way to convert troves of Latex manuscripts to Markdown ones.

I’ve tried converting the Latex tables to HTML using Pandoc but the HTML code came out faulty.

Right now I’m looking if Jekyll can handle Latex tables.