Skip to content

Conversation

@tim-nordell-nimbelink
Copy link

The table from issue #9313:

.. table::
   :class: standard nocolorrows

   +--------------------+----------------+
   |  2 rows and 2 cols | 1 row x 3 cols |
   |                    +----+-----+-----+
   |                    |  A |  B  |  C  |
   +---+----------------+----+-----+-----+
   | 1 |       2        |  3 |  4  |  5  |
   +---+----------------+----+-----+-----+

has merged vertical cells that notably needs to draw a vertical line on the left and right-hand side of the cells in the 2x2 grid area. If you add a column to the left of this:

    .. table::
       :class: standard nocolorrows

       +---+---+----------------+----------------+
       | X |  2 rows and 2 cols | 1 row x 3 cols |
       |   |                    +----+-----+-----+
       |   |                    |  A |  B  |  C  |
       +---+---+----------------+----+-----+-----+
       | Y | 1 |       2        |  3 |  4  |  5  |
       +---+---+----------------+----+-----+-----+

then the 2x2 area should not draw a column line to the left of the area.

We can fix this by adjusting the \multicolumn invocation to adjust when it emits the colspec.

Notably, this commit does not consider the other broken case where a person maybe just wants the table borders like:

    .. tabularcolumns:: |llllll|

    .. table::
       :class: standard nocolorrows

       +---+---+----------------+----------------+
       |   |  2 rows and 2 cols | 1 row x 3 cols |
       | X |                    +----+-----+-----+
       |   |                    |  A |  B  |  C  |
       +---+---+----------------+----+-----+-----+
       | Y | 1 |       2        |  3 |  4  |  5  |
       +---+---+----------------+----+-----+-----+

That has an impact in this area of the code, but to correctly consider that one has to parse out the given colspec to determine which columns have borders between them. (This line of code has a bug for this case as the colspec being emitted should be conditional if the specific column actually has it enabled, but the supporting code only determines if a vertical line is enabled anywhere rather than which columns.)

Here are the three tables mentioned prior to this fix:

image

And after the fix (which just fixes the second case):

image

Notably, the 3rd case (which is not a full grid fill) leaves extra vertical lines, and an extraneous "dot".

@tim-nordell-nimbelink tim-nordell-nimbelink force-pushed the fix/latex_lines_in_merged_vertical_cells branch from 1377a64 to 0e7c941 Compare November 3, 2025 21:45
The table from issue sphinx-doc#9313:

    .. table::
       :class: standard nocolorrows

       +--------------------+----------------+
       |  2 rows and 2 cols | 1 row x 3 cols |
       |                    +----+-----+-----+
       |                    |  A |  B  |  C  |
       +---+----------------+----+-----+-----+
       | 1 |       2        |  3 |  4  |  5  |
       +---+----------------+----+-----+-----+

has merged vertical cells that notably needs to draw a vertical line on
the left and right-hand side of the cells in the 2x2 grid area.  If you
add a column to the left of this:

    .. table::
       :class: standard nocolorrows

       +---+---+----------------+----------------+
       | X |  2 rows and 2 cols | 1 row x 3 cols |
       |   |                    +----+-----+-----+
       |   |                    |  A |  B  |  C  |
       +---+---+----------------+----+-----+-----+
       | Y | 1 |       2        |  3 |  4  |  5  |
       +---+---+----------------+----+-----+-----+

then the 2x2 area should *not* draw a column line to the left of the
area.

We can fix this by adjusting the \multicolumn invocation to adjust when
it emits the colspec.

Notably, this commit does *not* consider the other broken case where a
person maybe just wants the table borders like:

    .. tabularcolumns:: |llllll|

    .. table::
       :class: standard nocolorrows

       +---+---+----------------+----------------+
       |   |  2 rows and 2 cols | 1 row x 3 cols |
       | X |                    +----+-----+-----+
       |   |                    |  A |  B  |  C  |
       +---+---+----------------+----+-----+-----+
       | Y | 1 |       2        |  3 |  4  |  5  |
       +---+---+----------------+----+-----+-----+

That has an impact in this area of the code, but to correctly consider
that one has to parse out the given colspec to determine which columns
have borders between them.  (This line of code has a bug for this case
as the colspec being emitted should be conditional if the specific column
actually has it enabled, but the supporting code only determines if a
vertical line is enabled anywhere rather than which columns.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant