Right way to customizing latex output - lines between table rows

404 views
Skip to first unread message

Chip Webber

unread,
Aug 27, 2009, 10:35:44 AM8/27/09
to sphin...@googlegroups.com
Guys,
I have huge table that I'm turning into latex/pdf. Good news is that
sphinx and the longtable work like a charm, IIRC this wasn't always the
case.

I am adding a line (\hline) between each table row by tweaking the latex
writer in the sphinx distribution. Do you guys have advice on the right
place to make these changes so I am not modifying the Sphinx distribution?

I don't think I can do this with a latex stylesheet, but my latex
knowledge is limited so I may be mistaken. Is this a case of writing an
extension and overloading a function in the latex builder?

I appreciate the input,
Chip

Wolfram Riedel

unread,
Sep 10, 2009, 9:29:40 AM9/10/09
to sphinx-dev

Hi.

On Aug 27, 4:35 pm, Chip Webber <chipweb...@gmail.com> wrote:
> I am adding a line (\hline) between each table row by tweaking the latex
> writer in the sphinx distribution.  Do you guys have advice on the right
> place to make these changes so I am not modifying the Sphinx distribution?
>
> I don't think I can do this with a latex stylesheet, but my latex
> knowledge is limited so I may be mistaken.  Is this a case of writing an
> extension and overloading a function in the latex builder?

I had the same problem. Just wanted to add, that there is an open
issue about this:
http://bitbucket.org/birkenfeld/sphinx/issue/160/horizontal-rulers-in-latex-tables

Cheers,
Wolfram

frank

unread,
Sep 22, 2009, 11:28:52 PM9/22/09
to sphinx-dev
I also find this problem:

+--------------+----------+-----------+-----------+
| row 1, col 1 | column 2 | column 3 | column 4 |
+==============+==========+===========+===========+
| row 2 | | | |
+--------------+----------+-----------+-----------+
| row 3 | | | |
+--------------+----------+-----------+-----------+
| row 4 | | | |
+--------------+----------+-----------+-----------+

this will not generate \hline for each row.


any suggestion?

Chip Webber

unread,
Sep 25, 2009, 1:10:51 PM9/25/09
to sphin...@googlegroups.com
I do not think that constructing the table using this syntax implies
that a there should be a line between each row.

There are several different ways to make a table in RST, but at the end
of the day they are all just tables. My understanding is that there is
no difference between your table and one constructed like this once they
have been been parsed and put into the doctree.

======== ==== =====
r1, c1 c2 ...
======== ==== =====
r2
r3
r4
========= ==== =====

So it comes down to just a matter of personal preference when you are
writing documentation.

-Chip

Guenter Milde

unread,
Sep 25, 2009, 3:04:19 PM9/25/09
to sphin...@googlegroups.com
On 2009-09-25, Chip Webber wrote:

> I do not think that constructing the table using this syntax implies
> that a there should be a line between each row.

> There are several different ways to make a table in RST, but at the end
> of the day they are all just tables. My understanding is that there is
> no difference between your table and one constructed like this once they
> have been been parsed and put into the doctree.

>======== ==== =====
> r1, c1 c2 ...
>======== ==== =====
> r2
> r3
> r4
>========= ==== =====

True.

> So it comes down to just a matter of personal preference when you are
> writing documentation.

However, while you can style the table with CSS in the html output, some
aspects of the table style are "hardcoded" in the latex writer and cannot
be configured "arbitrarily". There are currently the pre-defined table
classes (unfortunately called cssclasses in Sphinx):

From http://docutils.sf.net/docs/user/config.html#latex2e-writer

table_style
Specify the drawing of separation lines.

* "standard" lines around and between cells.
* "booktabs" a line above and below the table and one after the head.
* "borderless".


Günter

Wolfram Riedel

unread,
Oct 5, 2009, 12:40:19 PM10/5/09
to sphinx-dev

Hello.

On Sep 25, 9:04 pm, Guenter Milde <mi...@users.berlios.de> wrote:
> However, while you can style thetablewith CSS in the html output, some
> aspects of thetablestyle are "hardcoded" in the latex writer and cannot
> be configured "arbitrarily". There are currently the pre-definedtable
> classes (unfortunately called cssclasses in Sphinx):
>
> From  http://docutils.sf.net/docs/user/config.html#latex2e-writer
>
> table_style
>     Specify the drawing of separation lines.
>
>     * "standard" lines around and between cells.
>     * "booktabs" a line above and below thetableand one after the head.
>     * "borderless".

I don't get it. Is this available in Sphinx' LaTeX writer? If so, how
do I access it? Putting ".. cssclass:: booktabs" or ".. cssclass::
borderless" before my tables doesn't seem to change anything.

Regards,
Wolfram

Guenter Milde

unread,
Oct 5, 2009, 2:31:10 PM10/5/09
to sphin...@googlegroups.com

>> From  http://docutils.sf.net/docs/user/config.html#latex2e-writer

So it seems like the Sphinx latex writer is based on a really old version of
the Docutils one.

Günter

Reply all
Reply to author
Forward
0 new messages