Text doesn't fit in simple table column - Latex-PDF export

759 views
Skip to first unread message

Alan Evangelista

unread,
Sep 7, 2011, 4:48:36 PM9/7/11
to sphinx-dev
I've created the following simple table in restructuredText:

========= ========
=======================================================
Tag Required Description
========= ========
=======================================================
columns No Columns of the content to return. Each
content listing
has a set of defaults columns
that make sense for that
particular content type. By
default, these columns are
returned in addition to what was
requested here.
xquery No A xquery
filter No Return files containing the
specified filter string
========= ========
=======================================================

When I export this table to Latex and then PDF, the words in each line
of the 1st column overflow and intersect the table vertical line. This
works OK in rst2pdf. This could be a rst error, a output formatting
error (eg style) or is it a Sphinx bug?

Thanks in advance for any help.

Minkai Li

unread,
Oct 12, 2016, 5:37:57 AM10/12/16
to sphinx-users, sphin...@googlegroups.com
use CSV tables

在 2011年9月8日星期四 UTC+8上午4:48:36,Alan Evangelista写道:

Komiya Takeshi

unread,
Oct 12, 2016, 10:47:19 PM10/12/16
to sphinx-users, sphin...@googlegroups.com
Hi,

That might come from the behavior of LaTeX engine.
As a adhoc way, you can give a hint to LaTeX engine with following notation:

.. tabularcolumns:: |p{1.0cm}|p{1.0cm}|L|

========= ======== =======================================================
Tag       Required Description
========= ======== =======================================================
columns   No       Columns of the content to return. Each content listing
                   has a set of defaults columns that make sense for that
                   particular content type. By default, these columns are
                   returned in addition to what was requested here.
xquery    No       A  xquery
filter    No       Return files containing the specified filter string
========= ======== =======================================================

I will file this as sphinx issues, and will continue to investigate how to avoid without hinting.

Thanks,
Takeshi KOMIYA

2011年9月8日木曜日 5時48分36秒 UTC+9 Alan Evangelista:

Komiya Takeshi

unread,
Oct 12, 2016, 11:54:24 PM10/12/16
to sphinx-users, sphin...@googlegroups.com
Note:
I filed this as following issues:


2016年10月13日木曜日 11時47分19秒 UTC+9 Komiya Takeshi:

Peter Burdine

unread,
Oct 13, 2016, 4:09:00 PM10/13/16
to sphinx-users, sphin...@googlegroups.com
It looks like Komiya Takeshi already mentioned this, but here is a more complicated example. 


.. tabularcolumns:: |>{\RaggedRight}p{\dimexpr 0.3\linewidth-2\tabcolsep}
                   
|>{\RaggedRight}p{\dimexpr 0.5\linewidth-2\tabcolsep}
                   
|>{\RaggedRight}p{\dimexpr 0.2\linewidth-2\tabcolsep}|

The above says the following:
  • It will be a table with 3 columns -- yes this needs to match the columns you have in your table or you will get wierd LaTeX build errors
  • The table cells are left justified (>{\RaggedRight}), this is optional.  If you leave this part out, you will get a justified column.  Note that depending on what role/directives you use in the table cell, it still may not wrap (eg, :file:, :samp:, ``...``)The p{...} tells it that it is a justified cell with the dimensions.  See https://en.wikibooks.org/wiki/LaTeX/Tables#The_tabular_environment for more options.
  • The first column is 30% of the available space, the 2nd is 50%, and the 3rd is 20%.  Adjust the values to what looks good.  These do NOT need add up to 100%, if they add up to .5, then the table will only use 50% of the space available to it.
  • The pipes tell it where and how many separators to use.  In the above, there is a vertical column line around ALL cells.  You you put two pipes in (||), then it would be a double vertical line. 
Reply all
Reply to author
Forward
0 new messages