How to use longtable?

59 views
Skip to first unread message

VlaMa

unread,
Mar 30, 2021, 3:55:41 AM3/30/21
to sphinx-users
Hello,

I have a table which is generated across one pdf page and rest of it is hidden (it is not
shown on second page). I found out I should be able to use

.. table::
      :class: longtable

and that should break the table in my pdf output. However this does not work for me and
the table is still rendered incorrectly.
During document compilation there is following warning:
WARNING: Content block expected for the "table" directive; none found.

Unfortunately I did not figured out what that means and I don't know how to fix it. Is it
possible this warning causing the issue that table is not well formatted?

Any tips are appreciated.

Thanks!

Komiya Takeshi

unread,
Apr 3, 2021, 3:36:10 AM4/3/21
to sphinx...@googlegroups.com
Hi,

It seems you did not write a table mark-up as a content of the table
directive. It expects table mark-up as its content. Please read the
document of the directive:
https://docutils.sourceforge.io/docs/ref/rst/directives.html#table

Thanks,
Takeshi KOMIYA

2021年3月30日(火) 16:55 VlaMa <vladimi...@frafos.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 view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/43b01acb-8c98-4904-a9bf-286ba0a867fbn%40googlegroups.com.

VlaMa

unread,
Apr 3, 2021, 3:41:42 PM4/3/21
to sphinx-users
Hi,

I read about that but most likely I did not understand it well. I thought that the content is a table itself ...
What should I write there as a "table mark-up content"? Could you please give me an example?

Thanks!

Komiya Takeshi

unread,
Apr 3, 2021, 10:28:07 PM4/3/21
to sphinx...@googlegroups.com
>I read about that but most likely I did not understand it well. I thought that the content is a table itself ...

Yes. Please put your table into the content area of the table directive.
The error you saw (WARNING: Content block expected for the "table"
directive; none found.) means the directive could not find any
content.

>Could you please give me an example?

Here.

.. table:: Truth table for "not"
:class: longtable

===== =====
A not A
===== =====
False True
True False
===== =====

2021年4月4日(日) 4:41 VlaMa <vladimi...@frafos.com>:
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/b9704311-3019-4aac-be5a-2bb06b58c4ean%40googlegroups.com.

Vladimír Marek

unread,
Apr 4, 2021, 2:29:16 PM4/4/21
to sphinx...@googlegroups.com
Ahaa
I did not know that the content is specified by indentation, thanks for
explanation!
I tried that and works OK!

Just one more question. The table directive adds a caption "Table 1" ...
"Table 1 – continued from previous page" which is misleading in my case.
I have many other tables in my doc (but they are not specified by table
directive).
Is it possible to either rename this label or remove it completely?

Komiya Takeshi

unread,
Apr 7, 2021, 11:36:31 AM4/7/21
to sphinx...@googlegroups.com
>Is it possible to either rename this label or remove it completely?

There is no formal way to remove it. But you can do it by a hacky way.
Please add this configuration to your conf.py:

latex_elements = {
'preamble': r"""\protected\def\sphinxtablecontinued#1{}"""
}

Thanks,
Takeshi KOMIYA

2021年4月5日(月) 3:29 Vladimír Marek <vladimi...@frafos.com>:
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/7c664f81-baa6-f4d5-de82-5540854c4306%40frafos.com.
Reply all
Reply to author
Forward
0 new messages