Skip to content

Commit 5969163

Browse files
authored
Merge pull request #8787 from jfbu/latex_repair_celllinetrimming_after_8781
Let latex writer line trimming from depart_entry() work as before #8781
2 parents 34ac0ff + 5b6a273 commit 5969163

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

sphinx/writers/latex.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,8 @@ def visit_paragraph(self, node: Element) -> None:
11631163
else:
11641164
# the \sphinxAtStartPar is to allow hyphenation of first word of
11651165
# a paragraph in narrow contexts such as in a table cell
1166-
self.body.append('\n\\sphinxAtStartPar\n')
1166+
# added as two items (cf. line trimming in depart_entry())
1167+
self.body.extend(['\n', '\\sphinxAtStartPar\n'])
11671168

11681169
def depart_paragraph(self, node: Element) -> None:
11691170
self.body.append('\n')

tests/roots/test-latex-table/complex.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ grid table
1111
+---------+ +---------+
1212
| cell2-1 | | cell2-3 |
1313
+ +---------+---------+
14-
| | cell3-2 |
14+
| | cell3-2-par1 |
1515
+---------+ |
16-
| cell4-1 | |
16+
| cell4-1 | cell3-2-par2 |
1717
+---------+---------+---------+
1818
| cell5-1 |
1919
+---------+---------+---------+

tests/roots/test-latex-table/expects/complex_spanning_cell.tex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
\hline
2020
\sphinxmultirow{3}{1}{%
2121
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
22-
2322
\sphinxAtStartPar
2423
cell1\sphinxhyphen{}1
2524
\par
2625
\vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}%
2726
}%
2827
&\sphinxmultirow{3}{2}{%
2928
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
30-
3129
\sphinxAtStartPar
3230
cell1\sphinxhyphen{}2
3331
\par
@@ -38,15 +36,13 @@
3836
cell1\sphinxhyphen{}3
3937
&\sphinxmultirow{3}{4}{%
4038
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
41-
4239
\sphinxAtStartPar
4340
cell1\sphinxhyphen{}4
4441
\par
4542
\vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}%
4643
}%
4744
&\sphinxmultirow{2}{5}{%
4845
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
49-
5046
\sphinxAtStartPar
5147
cell1\sphinxhyphen{}5
5248
\par
@@ -55,7 +51,6 @@
5551
\\
5652
\cline{3-3}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxmultirow{2}{6}{%
5753
\begin{varwidth}[t]{\sphinxcolwidth{1}{5}}
58-
5954
\sphinxAtStartPar
6055
cell2\sphinxhyphen{}3
6156
\par

tests/roots/test-latex-table/expects/gridtable.tex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
cell1\sphinxhyphen{}1
2020
&\sphinxmultirow{2}{5}{%
2121
\begin{varwidth}[t]{\sphinxcolwidth{1}{3}}
22-
2322
\sphinxAtStartPar
2423
cell1\sphinxhyphen{}2
2524
\par
@@ -31,7 +30,6 @@
3130
\\
3231
\cline{1-1}\cline{3-3}\sphinxmultirow{2}{7}{%
3332
\begin{varwidth}[t]{\sphinxcolwidth{1}{3}}
34-
3533
\sphinxAtStartPar
3634
cell2\sphinxhyphen{}1
3735
\par
@@ -44,9 +42,11 @@
4442
\cline{2-3}\sphinxtablestrut{7}&\sphinxstartmulticolumn{2}%
4543
\sphinxmultirow{2}{9}{%
4644
\begin{varwidth}[t]{\sphinxcolwidth{2}{3}}
45+
\sphinxAtStartPar
46+
cell3\sphinxhyphen{}2\sphinxhyphen{}par1
4747

4848
\sphinxAtStartPar
49-
cell3\sphinxhyphen{}2
49+
cell3\sphinxhyphen{}2\sphinxhyphen{}par2
5050
\par
5151
\vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}%
5252
}%
@@ -58,7 +58,6 @@
5858
&\multicolumn{2}{l|}{\sphinxtablestrut{9}}\\
5959
\hline\sphinxstartmulticolumn{3}%
6060
\begin{varwidth}[t]{\sphinxcolwidth{3}{3}}
61-
6261
\sphinxAtStartPar
6362
cell5\sphinxhyphen{}1
6463
\par

0 commit comments

Comments
 (0)