I'm using sphinx to generate documentations. The tables it produces via latex are pretty ugly, so I'd like to give them some global styling. What I'd like to achieve is

  • Always 100% width
  • A header row color
  • Bold header text
  • Maybe some more spacing

So what sphinx does is it writes tables like this:

} & \textsf{\relax 
} & \textsf{\relax 
Enthält Meta-Informationen zum Dossier

My approach was something like this (for the header row color):


\definecolor{tablehead}{rgb}{0.7294117647058823, 0.6823529411764706, 0.6235294117647059}

\renewenvironment{tabulary}[2]{\bgroup\begin{tabu} to \textwidth{#2}

This results in following error:

! Missing # inserted in alignment preamble.
<to be read again> 
l.294 \hline\end{tabulary}

? x
  • Why the \bgroup and \egroup? They serve no purpose whatsoever. Did you try with \tabu and \endtabu instead of \begin{tabu} and \end{tabu}? – egreg Apr 1 '15 at 11:10
  • Uh I think I saw a renewenvironment example with them. I've been trying back and forth. Using \tab produces the same error. – Schtibe Apr 1 '15 at 11:44

The L column type is useless as far as tabu is concerned.



\definecolor{tablehead}{rgb}{0.7294117647058823, 0.6823529411764706, 0.6235294117647059}

% redefine the L column type

 {\noindent\tabu to \textwidth{#2}\hline\rowcolor{tablehead}}


\textsf{Nummer} & \textsf{Name} & \textsf{Bemerkungen}\\
Enthält Meta-Informationen zum Dossier


enter image description here

Note that we have to swallow the first \hline otherwise and place it by hand, because it's illegal after \rowcolor.

  • currently Sphinx uses three different ways of doing tables: tabular and tabulary, wrapped in a threeparttable if there is a caption, and longtable if either requested by an instruction in the mark-up or if the table has at least 30 rows. No table is actually rendered as a float, which is good as it alleviates some issues with footnotes for example. tabular is used as fall-back if the (small) table contains verbatim material. This legacy situation is very unsatisfactory, switching to tabu is tempting except that FC said next one will break things. And Sphinx must work on TL2009 or older as is. – user4686 Oct 14 '16 at 20:12

Since sphinx 1.6.5 you can now add files


and override everything quite nicely. You can get the templates from github or from sphinx source.

I don't think there is any documentation for it yet, at least I couldn't find it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.