Problem with a grid table

154 views
Skip to first unread message

Vladimír Marek

unread,
May 14, 2021, 1:59:50 AM5/14/21
to sphinx-users
Hello all,

I hit a problem with a grid table.
It has 3 columns and I can compile a pdf from it. So far OK.

Then I added:
.. tabularcolumns:: |l|L|L|

at the beginning of that table and it is not possible to compile pdf any
longer.
The compilation stops and reports:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.23356 \end{tabulary}

If I delete that tabularcolumns line, it works OK again.
I use that tabularcolumn directive for other tables without any issue
but this particular table causes problems.

Any idea what might be wrong?
Would it be possible that some special characters inside the table could
cause this issue?
From formatting point of view the table looks OK.

Regards,
  Vladimir

jfbu

unread,
May 14, 2021, 3:27:02 AM5/14/21
to sphinx...@googlegroups.com
Le 14/05/2021 à 07:59, Vladimír Marek a écrit :
> Then I added:
> .. tabularcolumns:: |l|L|L|
>
> at the beginning of that table
Hi,
you must add the directive **before** the table,
Best,
Jean-François

Vladimír Marek

unread,
May 14, 2021, 3:29:21 AM5/14/21
to sphinx...@googlegroups.com
Yeah sorry, that's what I meant by the "beginning".
I have there something like:

.. tabularcolumns:: |l|L|L|
+-----+-----+----+
|    1  |   2  |  3  |
+-----+-----+----+

V.

jfbu

unread,
May 14, 2021, 3:39:12 AM5/14/21
to sphinx...@googlegroups.com
Le 14/05/2021 à 09:29, Vladimír Marek a écrit :
> Yeah sorry, that's what I meant by the "beginning".
> I have there something like:
>
> .. tabularcolumns:: |l|L|L|
> +-----+-----+----+
> |    1  |   2  |  3  |
> +-----+-----+----+
>
> V.
>
ah ok sorry.

If a cell in first column contains a list for example then it will trigger the error you see


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.106 \end{tabulary}


.. tabularcolumns:: |l|L|L|

+-----+-----+----+
| - a | 2 | 3 |
+-----+-----+----+


the l specifier is not compatible with list in table cell

is that your case?
Best,
JF

jfbu

unread,
May 14, 2021, 3:45:46 AM5/14/21
to sphinx...@googlegroups.com
the L specifier also is incompatible

You can use p{2cm}, or the \X, \Y from Sphinx, e.g. \Y{0.3} to occupy 30% of page width for that column

Vladimír Marek

unread,
May 14, 2021, 5:09:22 AM5/14/21
to sphinx...@googlegroups.com
Hmmm but I do not have any list inside table cells :-(
I forgot to mention I use the sphinx version 1.8.5 ... pretty old I know
but as of now I'm not able to upgrade to the latest

Vladimír Marek

unread,
May 14, 2021, 5:10:21 AM5/14/21
to sphinx...@googlegroups.com


On 14. 05. 21 9:45, jfbu wrote:
> Le 14/05/2021 à 09:39, jfbu a écrit :
>> Le 14/05/2021 à 09:29, Vladimír Marek a écrit :
>>> Yeah sorry, that's what I meant by the "beginning".
>>> I have there something like:
>>>
>>> .. tabularcolumns:: |l|L|L|
>>> +-----+-----+----+
>>> |    1  |   2  |  3  |
>>> +-----+-----+----+
>>>
>>> V.
>>>
>> ah ok sorry.
>>
>> If a cell in first column contains a list for example then it will
>> trigger the error you see
>>
>>
>> ! LaTeX Error: Something's wrong--perhaps a missing \item.
>>
>> See the LaTeX manual or LaTeX Companion for explanation.
>> Type  H <return>  for immediate help.
>>   ...
>> l.106 \end{tabulary}
>>
>>
>> .. tabularcolumns:: |l|L|L|
>>
>> +-----+-----+----+
>> | - a |  2  | 3  |
>> +-----+-----+----+
>>
>>
>> the l specifier is not compatible with list in table cell
>>
>
>
> the L specifier also is incompatible
according to
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html?highlight=table#tables
the L is suppose to be supported ...

jfbu

unread,
May 14, 2021, 5:18:04 AM5/14/21
to sphinx...@googlegroups.com
The L is a tabulary specific specifier and tabulary is not compatible with "problematic" contents in table cells.

The doc says further down:

Tables that contain list-like elements such as object descriptions, blockquotes or any kind of lists cannot be set out of the box with tabulary. They are therefore set with the standard LaTeX tabular (or longtable) environment if you don’t give a tabularcolumns directive. If you do, the table will be set with tabulary but you must use the p{width} construct (or Sphinx’s \X and \Y specifiers described below) for the columns containing these elements.


However it would be interesting to have a concrete example of a problematic grid table else the discussion may be off the mark

Vladimír Marek

unread,
May 14, 2021, 5:54:26 AM5/14/21
to sphinx...@googlegroups.com
So I debug that a bit and found out following:

the table has 18 rows and only one is problematic.
If the table contains:
+----------+----------------+--------------------------------------------------------------+

| 10000    | UDP            | Audio/video
media.                                           |
| 60000    |
|                                                              |
+----------+----------------+--------------------------------------------------------------+

then table is generated correctly.
However if table contains

+----------+----------------+--------------------------------------------------------------+

| 10000    | UDP            | Audio/video
media.                                           |
|    to        |
|                                                              |
| 60000    |
|                                                              |
+----------+----------------+--------------------------------------------------------------+

then it breaks compilation. Please note, the formatting is correct, it
just looks bad in the email.
Loots like it does not like the 3 lines in the first column.
Talking about those lines, would you know how to force a new line inside
the table? If those numbers are on 2 rows then in the final document
they are usually on a single line ...

Thanks!
  Vladimir

jfbu

unread,
May 14, 2021, 6:38:25 AM5/14/21
to sphinx...@googlegroups.com
Le 14/05/2021 à 11:54, Vladimír Marek a écrit :
> +----------+----------------+--------------------------------------------------------------+
> | 10000    | UDP            | Audio/video media.                                           |
> |    to        | |                                                              |
> | 60000    | |                                                              |
> +----------+----------------+--------------------------------------------------------------+
Hi Vladimir,
copying pasting and fixing blanks to get this
+----------+----------------+--------------------------------------------------------------+
| 10000 | UDP | Audio/video media. |
| to | | |
| 60000 | | |
+----------+----------------+--------------------------------------------------------------+

I see on make latex the following Docutils 16 warning

/.../index.rst:21: WARNING: Definition list ends without a blank line; unexpected unindent.


This means the

10000
to

is interpreted as a definition list

Despite the warning, some latex file is produced containing a

\begin{description}
\item[{10000}] \leavevmode
\sphinxAtStartPar
to

\end{description}

\sphinxAtStartPar
60000


(the \sphinxAtStartPar is mark-up because I am testing with a recent Sphinx)

This is a list-like environment and triggers the error.

Using this input

.. tabularcolumns:: |l|L|L|

+----------+----------------+--------------------------------------------------------------+
| 10000 | UDP | Audio/video media. |
| \ \ \ to | | |
| 60000 | | |
+----------+----------------+--------------------------------------------------------------+

compilation works to pdf works.

It works with same result with

.. tabularcolumns:: |l|L|L|

+----------+----------------+--------------------------------------------------------------+
| 10000 | UDP | Audio/video media. |
| to | | |
| 60000 | | |
+----------+----------------+--------------------------------------------------------------+

> Talking about those lines, would you know how to force a new line inside the table? If those numbers are on 2 rows then in the final document they are usually on a single line ...

Yes indeed the above input and the l specifier means to produce a single line

One can force as many lines in output as input like this:



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

+----------+----------------+--------------------------------------------------------------+
| | 10000 | UDP | Audio/video media. |
| | to | | |
| | 60000 | | |
+----------+----------------+--------------------------------------------------------------+

But the pdf output is not nice, because LaTeX adds whitespace before and after the quoted environment

You can resort to some more devious input

.. |NL| raw:: latex

\newline


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

+--------------+----------------+--------------------------------------------------------------+
| 10000\ |NL| | UDP | Audio/video media. |
| to\ |NL| | | |
| 60000 | | |
+--------------+----------------+--------------------------------------------------------------+


It is mandatory here to use some p{width}, or \Y{0.1} (10% of available line with) for the column type

However the html output will have a "10000 to 60000" single line, but I am focusing here on a LaTeX only solution (as I am a bit rusty on Sphinx generally speaking)

and perhaps there is much simpler way, ah this should work:

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

+--------------+----------------+--------------------------------------------------------------+
| 10000 | UDP | Audio/video media. |
| | | |
| to | | |
| | | |
| 60000 | | |
+--------------+----------------+--------------------------------------------------------------+


yes this is much better as it works also for html output; but same remark about the column type

If copying pasting make sure to keep blanks are as in original, i.e. the | match across rows

Does this work?

Best,
J.-F.


jfbu

unread,
May 14, 2021, 6:51:32 AM5/14/21
to sphinx...@googlegroups.com
Le 14/05/2021 à 12:38, jfbu a écrit :
>
> +--------------+----------------+--------------------------------------------------------------+
> | 10000        | UDP            | Audio/video media.                                           |
> |              |                |                                                              |
> | to           |                |                                                              |
> |              |                |                                                              |
> | 60000        |                |                                                              |
> +--------------+----------------+--------------------------------------------------------------+
>
>
> yes this is much better as it works also for html output; but same remark about the column type
>

as I said I am a bit rusty here : I meant that the "l" column type would produce single line output, which is correct.

But on the other hand it is here not needed to use p{width} or \Y{fraction} column type: tabulary is compatible with such cell out of the box and if you use tabularcolumns, it can be for example

.. tabularcolumns:: |L|L|L|


The requirement for alternative list-compatible types such as p{} in only for case of list environment.

Multi-paragraph input as above however is tabulary compatible


Vladimír Marek

unread,
May 14, 2021, 8:52:37 AM5/14/21
to sphinx...@googlegroups.com
Thanks for the detailed answer!
I tried your hints but only thing which worked for me was:
+----------+
| 10000   |
| to          |
| 60000   |
+----------+

All the other did not work. I suspect the problem might be in the old
version of Sphinx I use.
Once I have a bit of time I will try it with the latest and will see if
that improves the behavior or not.

Regards,
  Vladimir

Reply all
Reply to author
Forward
0 new messages