Sphinx: stub-columns have no effect in LaTeX output

Created on 28 Feb 2017  路  3Comments  路  Source: sphinx-doc/sphinx

List-tables are much easier to type in than rst grid tables or "simple" tables, see list-table in rst documentation
These support an option stub-columns to mark a column as one that contains header cells:

.. list-table:: Table with a header row and header column
    :header-rows: 1
    :stub-columns: 1

    * -
      - Col 1
      - Col 2
    * - Row 1
      - Cell 1,1
      - Cell 2,1
    * - Row 2
      - Cell 2,1
      - Cell 2,2

This works fine with HTML output:
html

Underlying code:

<table border="1" class="docutils" id="id1">
<caption><span class="caption-number">Table 2.1 </span><span class="caption-text">Table with a header row and header column</span><a class="headerlink" href="#id1" title="Permalink to this table">露</a></caption>
<colgroup>
<col width="33%">
<col width="33%">
<col width="33%">
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head stub">&nbsp;</th>
<th class="head">Col 1</th>
<th class="head">Col 2</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><th class="stub">Row 1</th>
<td>Cell 1,1</td>
<td>Cell 2,1</td>
</tr>
<tr class="row-odd"><th class="stub">Row 2</th>
<td>Cell 2,1</td>
<td>Cell 2,2</td>
</tr>
</tbody>
</table>

But not with LaTeX output:
latex

The screenshot may not be very clear, but the .tex file clearly shows only the header row is marked up:

\begin{threeparttable}
\capstart\caption{Table with a header row and header column}\label{\detokenize{REDACTED}}
\noindent\begin{tabulary}{\linewidth}{|L|L|L|}
\hline
\sphinxstylethead{\relax \unskip}\relax &\sphinxstylethead{\relax 
Col 1
\unskip}\relax &\sphinxstylethead{\relax 
Col 2
\unskip}\relax \\
\hline
Row 1
&
Cell 1,1
&
Cell 2,1
\\
\hline
Row 2
&
Cell 2,1
&
Cell 2,2
\\
\hline\end{tabulary}

\end{threeparttable}

Expected results

Also apply \sphinxstylethead to the cells in the stub-columns column

Environment info

  • OS: OSX 10.10.5
  • Python version: 2.7.13
  • Sphinx version: 1.5.1
bug latex

Most helpful comment

Note: this is classified as a bug. But we'd refactored the tables much on master branch.
So it is hard to merge to master branch if we'll fix this on stable branch.
Therefore I decided to fix this on master branch.

All 3 comments

Thanks ! if implemented this should probably use \sphinxstyletstub (or like name) with possibly a two arguments macro, first argument being column number.

out of curiosity: is there use for multiple stub columns ?

and it seems stub entries are often layered (for example this reference) and I wonder if Docutils list-table supports that.

aside: Emacs table-mode provides rather efficient grid table entry method.

Note: this is classified as a bug. But we'd refactored the tables much on master branch.
So it is hard to merge to master branch if we'll fix this on stable branch.
Therefore I decided to fix this on master branch.

Fixed at #3684. Thanks for reporting!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shimizukawa picture shimizukawa  路  3Comments

samweisgamdschie picture samweisgamdschie  路  3Comments

jfbu picture jfbu  路  3Comments

shimizukawa picture shimizukawa  路  3Comments

eine picture eine  路  3Comments