Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to style tables in LaTex #2832

Open
vlotorev opened this issue Aug 4, 2016 · 9 comments
Open

Provide a way to style tables in LaTex #2832

vlotorev opened this issue Aug 4, 2016 · 9 comments

Comments

@vlotorev
Copy link

vlotorev commented Aug 4, 2016

Hi,

as I commented in #2305 (comment) currently there is no way in styling tables for LaTex output.
Examples that are cannot be 'styled' for tables:

  • cells background color can't be changed, this is especially useful for changing background color of table header
  • header text colour can't be changed
  • cells text font can't be changed

Also currently sphinx wraps table header with '\textsf{' which also can't be disabled.

@andreacassioli
Copy link

+1

(Especially for the text header)

@christinaweyher
Copy link

+1

(Also especially regarding the the table header \textsf )

@jfbu
Copy link
Contributor

jfbu commented Oct 1, 2016

side note, in fact on master branch since b3d8961, 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).

@liminkai520520
Copy link

liminkai520520 commented Oct 7, 2016

how to set the table header colour?

@jfbu
Copy link
Contributor

jfbu commented Oct 7, 2016

@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.

@rakhimov
Copy link

rakhimov commented Feb 9, 2017

How to set the background row color for the table head?

@jfbu
Copy link
Contributor

jfbu commented Feb 9, 2017

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)

@rakhimov
Copy link

rakhimov commented Feb 9, 2017

Thanks @jfbu !
It indeed does the trick.

@jfbu
Copy link
Contributor

jfbu commented Mar 11, 2017

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.

@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants