1

I would like to create a table using latex elements in my sphinx documentation. So far I have added the following lines to my conf.py:

latex_engine = 'xelatex'
latex_elements = {
    'preamble': r'''
    \usepackage{tabular}
    '''
}

my rst looks as following:

.. math::

  \begin{tabular}{|l|c|r|}
    \hline
    foo   & bar    & fubar \\
    fubar & toobar & foo \\
    \hline
  \end{tabular}

  \vspace{1cm}

  \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}|l|c|r|}
    \hline
    foo   & bar    & fubar \\
    fubar & toobar & foo \\
    \hline
  \end{tabular*}

  \vspace{1cm}

  \begin{tabularx}{\textwidth}{|X|X|X|}
    \hline
    foo   & bar    & fubar \\
    fubar & toobar & foo \\
    \hline
  \end{tabularx}

However, the html only displays a "unknown environment "tabular"" and none of the described elements. Is there a way to properly include the package?

Yes
  • 339
  • 3
  • 19
  • 1
    MathJax does not support "tabular": https://github.com/mathjax/mathjax-docs/wiki/LaTeX-Tabular-environment – mzjn Jul 22 '21 at 16:40
  • 2
    I assumed that you use MathJax with Sphinx since I can reproduce the 'unknown environment "tabular"' error when using `sphinx.ext.mathjax`. I don't think the `latex_engine` and `latex_elements` options have any effect when you are generating HTML. See also https://stackoverflow.com/q/51803244/407651. – mzjn Jul 22 '21 at 17:40

0 Answers0