Open vlotorev opened 8 years ago
+1
(Especially for the text header)
+1
(Also especially regarding the the table header \textsf )
side note, in fact on master branch since b3d8961c, it is not \textsf{
but \sphinxstylethead{
hence this can be customized from the 'preamble'
key. Thus this sub-issue may be already closed (on master branch).
how to set the table header colour?
@liminkai520520 it is not clear if you mean the background colour or the text colour. Anyway, you can insert commands in a redefinition of \sphinxstylethead
. That is, starting with future release 1.5
.
How to set the background row color for the table head?
You can try this in conf.py.
latex_elements = {
'passoptionstopackages': r'\PassOptionsToPackage{table}{xcolor}',
'preamble' : r'\protected\def\sphinxstylethead{\cellcolor{red}\textsf}',
}
This does not answer directly your question because it colours the cells not the row, but may be functionally equivalent in default situation. Perhaps it will help you.
The LaTeX advice at wikibook of using \rowcolors
has issues : does not work with longtable header, forces repeated use at each table because the macro does not reset row count after tables, does not work well with complicated grid tables. (further, \rowcolors
does not seem to allow easily coloring only the header row)
Thanks @jfbu ! It indeed does the trick.
Just to mention here that table templates were introduced at 976fc32 on master branch for Sphinx 1.6 release and will be modifiable by user (2a37b0e). This will make it easier for user knowing well LaTeX to customize tables: for example with table
option passed to xcolor
package, the templates could contain \rowcolors
command and thus get coloring of rows; indeed this xcolor
provided \rowcolors
macro requires being used at each table, and template is perfect way to achieve this. Perhaps 1.6 will already provide some higher level interface to color table rows without the constraint of a \rowcolors
at each table.
Hi,
as I commented in https://github.com/sphinx-doc/sphinx/issues/2305#issuecomment-182575690 currently there is no way in styling tables for LaTex output. Examples that are cannot be 'styled' for tables:
Also currently sphinx wraps table header with '\textsf{' which also can't be disabled.