table formatting help

999 views
Skip to first unread message

Jason S

unread,
Aug 4, 2010, 1:53:44 PM8/4/10
to sphinx-dev
Could someone please post an example of table formatting for regular
sphinx+restructuredText, as well as rst2pdf?

I really need to have some control over the column widths. Also it
would be helpful to control the justification, background color, and
the borders. But restructuredText tables
http://docutils.sourceforge.net/docs/user/rst/quickref.html#tables
gives no way to do this, and sphinx tabularcolumns doesn't give any
example for how to use it. http://sphinx.pocoo.org/markup/misc.html#tabularcolumns

please help!

James Evans

unread,
Aug 4, 2010, 6:34:03 PM8/4/10
to sphin...@googlegroups.com
I had submitted a patch to docutils a while back that added a lot more
control to tables and their columns:

http://sourceforge.net/tracker/?func=detail&aid=2977130&group_id=38414&atid=
422032

I was told that it could not be added because it had an html specific option
for the table directive.

The comment also suggested making it a global option whereas I wanted to
still have specific control over each table. My team-mates and I have been
successfully using this patch for some time now, with no problems.

--James

please help!

--
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to sphin...@googlegroups.com.
To unsubscribe from this group, send email to
sphinx-dev+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en.


Guenter Milde

unread,
Aug 5, 2010, 1:52:07 AM8/5/10
to sphin...@googlegroups.com
Dear James,

On 2010-08-04, James Evans wrote:
> I had submitted a patch to docutils a while back that added a lot more
> control to tables and their columns:

> http://sourceforge.net/tracker/?func=detail&aid=2977130&group_id=38414&atid=
> 422032

> I was told that it could not be added because it had an html specific option
> for the table directive.

> The comment also suggested making it a global option whereas I wanted to
> still have specific control over each table.

Actually the comment suggested turning the HTML-specific option into a
"special class argument" (like 'borderless') so that it can be savely
ignored by other output formats.

Besides following the general Docutils conventions (options are for all
writers, class arguments are optional), this also has the added benefit
that the 'nocolgroup' can be specified as a global configuration value as
well as on a per-table basis.

> My team-mates and I have been successfully using this patch for some
> time now, with no problems.

What happens if you generate PDF, XML, or LaTeX output from a document
containing the "nocolgroup" option?

Günter

ralsina

unread,
Aug 6, 2010, 7:53:03 AM8/6/10
to sphinx-dev
On Aug 4, 2:53 pm, Jason S <jmsa...@gmail.com> wrote:
> Could someone please post an example of table formatting for regular
> sphinx+restructuredText, as well as rst2pdf?
>
> I really need to have some control over the column widths. Also it
> would be helpful to control the justification, background color, and
> the borders. But restructuredText tableshttp://docutils.sourceforge.net/docs/user/rst/quickref.html#tables
> gives no way to do this, and sphinx tabularcolumns doesn't give any
> example for how to use it.http://sphinx.pocoo.org/markup/misc.html#tabularcolumns
>
> please help!

In rst2pdf you do that by applying a class to the table.

Here's an example.

Text file: http://code.google.com/p/rst2pdf/source/browse/trunk/rst2pdf/tests/input/test_table_classes.txt
Style file: http://code.google.com/p/rst2pdf/source/browse/trunk/rst2pdf/tests/input/test_table_classes.style

Or, in general, you could use the "csv-table" directive, which
supports specifying column widths, but that means you will move your
data outside of your document.
Reply all
Reply to author
Forward
0 new messages