Table Header in Latex Output in Sphinx 2.0

490 views
Skip to first unread message

Sebastian Huber

unread,
Apr 4, 2019, 8:20:35 AM4/4/19
to sphinx-users
Hello,

I created a simple example project using the Sphinx 2.0 sphinx-quickstart and added a simple table to index.rst:

.. Table documentation master file, created by
   sphinx
-quickstart on Thu Apr  4 14:08:53 2019.
   
You can adapt this file completely to your liking, but it should at least
   contain the root
`toctree` directive.

Welcome to Table's documentation!
=================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:


Table
=============

.. list-table:: Table
    :header-rows: 1
    :stub-columns: 1

    * - Header A
      - Header B
      - Header C
      - Header D
      - Header E
    * - Row Header X
      - 1
      - 2
      - 3
      - 4
    * - Row Header Y
      - 5
      - 6
      - 7
      - 8
    * - Row Header Z
      - 9
      - 10
      - 11
      - 12

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`.

It generates the attached PDF output. I don't see anything special in the format of the table column/row headers. Is this a bug or a feature? I though the header-rows and stub-columns specify which rows/columns are headers?


table.pdf

Komiya Takeshi

unread,
Apr 4, 2019, 10:23:42 AM4/4/19
to sphinx...@googlegroups.com
Hi,

By default, sphinx uses san-serif fonts for table headers. It is
different from other text.
You can customize it with LaTeX macros. For example, the following
setting uses bold font
for table headers.

latex_elements = {
'preamble': r'\protected\def\sphinxstyletheadfamily {\bfseries}'
}

Thanks,
Takeshi KOMIYA

2019年4月4日(木) 21:20 Sebastian Huber <seb...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To post to this group, send email to sphinx...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/d/optout.

Sebastian Huber

unread,
Apr 5, 2019, 12:51:57 AM4/5/19
to sphinx...@googlegroups.com
Hello Takeshi,

thanks a lot for this information. I use now:

\protected\def\sphinxstyletheadfamily{\py@HeaderFamily \py@TitleColor}

where would I have found this customization option in the documentation?

jfbu

unread,
Apr 5, 2019, 4:34:25 AM4/5/19
to sphinx...@googlegroups.com
Hi Sebastian

Le 05/04/2019 à 06:51, Sebastian Huber a écrit :
> Hello Takeshi,
>
> thanks a lot for this information. I use now:
>
> \protected\def\sphinxstyletheadfamily{\py@HeaderFamily \py@TitleColor}
>

use \makeatletter before and \makeatother after if used in 'preamble' key

(saying this for others, as obviously it does work for you)

> where would I have found this customization option in the documentation?
>

http://www.sphinx-doc.org/en/master/latex.html#latex-macros-and-environments

but it is written for people who know LaTeX macros...

(which is obviously your case ...)

Best,

Jean-François


Sebastian Huber

unread,
Apr 5, 2019, 9:09:46 AM4/5/19
to sphinx...@googlegroups.com
On Fri, Apr 5, 2019 at 10:34 AM jfbu <jf...@free.fr> wrote:
>
> Hi Sebastian
>
> Le 05/04/2019 à 06:51, Sebastian Huber a écrit :
> > Hello Takeshi,
> >
> > thanks a lot for this information. I use now:
> >
> > \protected\def\sphinxstyletheadfamily{\py@HeaderFamily \py@TitleColor}
> >
>
> use \makeatletter before and \makeatother after if used in 'preamble' key
>
> (saying this for others, as obviously it does work for you)

Yes, I use a custom *.sty file, so this \makeatletter was not necessary.

>
> > where would I have found this customization option in the documentation?
> >
>
> http://www.sphinx-doc.org/en/master/latex.html#latex-macros-and-environments
>
> but it is written for people who know LaTeX macros...
>
> (which is obviously your case ...)

I did look at this page, but apparently this is one of the documents
in which every word counts. I wished I had the time to add examples to
all these macros.

jfbu

unread,
Apr 7, 2019, 4:52:07 AM4/7/19
to sphinx...@googlegroups.com

Hi Sebastian

>>> where would I have found this customization option in the documentation?
>>>
>>
>> http://www.sphinx-doc.org/en/master/latex.html#latex-macros-and-environments
>>
>> but it is written for people who know LaTeX macros...
>>
>> (which is obviously your case ...)
>
> I did look at this page, but apparently this is one of the documents
> in which every word counts. I wished I had the time to add examples to
> all these macros.
>

Thanks! I feel the same but Sphinx LaTeX doc got already voluminous
by my fault in recent times, and the problem with documentation
is that the bigger it is the harder it gets to maintain ;-)

(a bit ironical to say that in the context of Sphinx "documentation
generator" but there is some truth to it; for example the internet
is full of unmaintained documentation for LaTeX proper, from 10,
20 or 30 years ago, sometimes completely outdated or inadequate
nowadays)

However, maybe the paragraph could at least be improved to use
some kind of a description list presentation with the full names
of the macros and a one line description of what they do for each.

Jean-François

Reply all
Reply to author
Forward
0 new messages