diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 55d56d630..da0d39e24 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1163,7 +1163,8 @@ class LaTeXTranslator(SphinxTranslator): else: # the \sphinxAtStartPar is to allow hyphenation of first word of # a paragraph in narrow contexts such as in a table cell - self.body.append('\n\\sphinxAtStartPar\n') + # added as two items (cf. line trimming in depart_entry()) + self.body.extend(['\n', '\\sphinxAtStartPar\n']) def depart_paragraph(self, node: Element) -> None: self.body.append('\n') diff --git a/tests/roots/test-latex-table/complex.rst b/tests/roots/test-latex-table/complex.rst index f3f927a3e..fa84f8266 100644 --- a/tests/roots/test-latex-table/complex.rst +++ b/tests/roots/test-latex-table/complex.rst @@ -11,9 +11,9 @@ grid table +---------+ +---------+ | cell2-1 | | cell2-3 | + +---------+---------+ -| | cell3-2 | +| | cell3-2-par1 | +---------+ | -| cell4-1 | | +| cell4-1 | cell3-2-par2 | +---------+---------+---------+ | cell5-1 | +---------+---------+---------+ diff --git a/tests/roots/test-latex-table/expects/complex_spanning_cell.tex b/tests/roots/test-latex-table/expects/complex_spanning_cell.tex index 4d432f500..966f39a95 100644 --- a/tests/roots/test-latex-table/expects/complex_spanning_cell.tex +++ b/tests/roots/test-latex-table/expects/complex_spanning_cell.tex @@ -19,7 +19,6 @@ consecutive multirow at end of row (1\sphinxhyphen{}4 and 1\sphinxhyphen{}5) \hline \sphinxmultirow{3}{1}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} - \sphinxAtStartPar cell1\sphinxhyphen{}1 \par @@ -27,7 +26,6 @@ cell1\sphinxhyphen{}1 }% &\sphinxmultirow{3}{2}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} - \sphinxAtStartPar cell1\sphinxhyphen{}2 \par @@ -38,7 +36,6 @@ cell1\sphinxhyphen{}2 cell1\sphinxhyphen{}3 &\sphinxmultirow{3}{4}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} - \sphinxAtStartPar cell1\sphinxhyphen{}4 \par @@ -46,7 +43,6 @@ cell1\sphinxhyphen{}4 }% &\sphinxmultirow{2}{5}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} - \sphinxAtStartPar cell1\sphinxhyphen{}5 \par @@ -55,7 +51,6 @@ cell1\sphinxhyphen{}5 \\ \cline{3-3}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxmultirow{2}{6}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} - \sphinxAtStartPar cell2\sphinxhyphen{}3 \par diff --git a/tests/roots/test-latex-table/expects/gridtable.tex b/tests/roots/test-latex-table/expects/gridtable.tex index fc5b757b9..a71c9e202 100644 --- a/tests/roots/test-latex-table/expects/gridtable.tex +++ b/tests/roots/test-latex-table/expects/gridtable.tex @@ -19,7 +19,6 @@ header3 cell1\sphinxhyphen{}1 &\sphinxmultirow{2}{5}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{3}} - \sphinxAtStartPar cell1\sphinxhyphen{}2 \par @@ -31,7 +30,6 @@ cell1\sphinxhyphen{}3 \\ \cline{1-1}\cline{3-3}\sphinxmultirow{2}{7}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{3}} - \sphinxAtStartPar cell2\sphinxhyphen{}1 \par @@ -44,9 +42,11 @@ cell2\sphinxhyphen{}3 \cline{2-3}\sphinxtablestrut{7}&\sphinxstartmulticolumn{2}% \sphinxmultirow{2}{9}{% \begin{varwidth}[t]{\sphinxcolwidth{2}{3}} +\sphinxAtStartPar +cell3\sphinxhyphen{}2\sphinxhyphen{}par1 \sphinxAtStartPar -cell3\sphinxhyphen{}2 +cell3\sphinxhyphen{}2\sphinxhyphen{}par2 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% @@ -58,7 +58,6 @@ cell4\sphinxhyphen{}1 &\multicolumn{2}{l|}{\sphinxtablestrut{9}}\\ \hline\sphinxstartmulticolumn{3}% \begin{varwidth}[t]{\sphinxcolwidth{3}{3}} - \sphinxAtStartPar cell5\sphinxhyphen{}1 \par