From 185a2d27fee2418ee9056caac0a0652c63a0a7d7 Mon Sep 17 00:00:00 2001 From: jfbu Date: Fri, 29 Jan 2021 00:24:44 +0100 Subject: [PATCH 1/3] Fix #8780: long words in narrow columns may not be hyphenated This is done by adding '\hskip0pt\relax\n' whenever a paragraph starts. --- CHANGES | 1 + doc/extdev/deprecated.rst | 6 +-- sphinx/writers/latex.py | 4 +- .../expects/latex-equations.tex | 7 +-- .../expects/complex_spanning_cell.tex | 15 ++++-- .../test-latex-table/expects/gridtable.tex | 18 ++++--- .../test-latex-table/expects/longtable.tex | 20 +++---- .../expects/longtable_having_align.tex | 20 +++---- .../expects/longtable_having_caption.tex | 20 +++---- .../longtable_having_problematic_cell.tex | 22 ++++---- ...ving_stub_columns_and_problematic_cell.tex | 26 ++++----- .../expects/longtable_having_verbatim.tex | 18 +++---- .../expects/longtable_having_widths.tex | 22 ++++---- ...ble_having_widths_and_problematic_cell.tex | 22 ++++---- .../expects/longtable_with_tabularcolumn.tex | 20 +++---- .../test-latex-table/expects/simple_table.tex | 16 +++--- .../expects/table_having_caption.tex | 16 +++--- .../expects/table_having_problematic_cell.tex | 18 +++---- ...ving_stub_columns_and_problematic_cell.tex | 20 +++---- ...ving_threeparagraphs_cell_in_first_col.tex | 8 +-- .../expects/table_having_verbatim.tex | 14 ++--- .../expects/table_having_widths.tex | 18 +++---- ...ble_having_widths_and_problematic_cell.tex | 18 +++---- .../expects/tabular_having_widths.tex | 16 +++--- .../expects/tabularcolumn.tex | 16 +++--- .../expects/tabulary_having_widths.tex | 16 +++--- tests/test_build_latex.py | 42 ++++++++------- tests/test_markup.py | 54 +++++++++++-------- 28 files changed, 269 insertions(+), 244 deletions(-) diff --git a/CHANGES b/CHANGES index 9a5c3ef51..61b9ee3f8 100644 --- a/CHANGES +++ b/CHANGES @@ -109,6 +109,7 @@ Bugs fixed :confval:`numfig` is not True * #8442: LaTeX: some indexed terms are ignored when using xelatex engine (or pdflatex and :confval:`latex_use_xindy` set to True) with memoir class +* #8780: LaTeX: long words in narrow columns may not be hyphenated Testing -------- diff --git a/doc/extdev/deprecated.rst b/doc/extdev/deprecated.rst index dc9d9973d..1350085ef 100644 --- a/doc/extdev/deprecated.rst +++ b/doc/extdev/deprecated.rst @@ -12,17 +12,13 @@ The following is a list of deprecated interfaces. .. tabularcolumns:: |>{\raggedright}\Y{.4}|>{\centering}\Y{.1}|>{\centering}\Y{.12}|>{\raggedright\arraybackslash}\Y{.38}| -.. |LaTeXHyphenate| raw:: latex - - \hspace{0pt} - .. list-table:: deprecated APIs :header-rows: 1 :class: deprecated :widths: 40, 10, 10, 40 * - Target - - |LaTeXHyphenate|\ Deprecated + - Deprecated - (will be) Removed - Alternatives diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 918dda774..5d42ad71d 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1161,7 +1161,9 @@ class LaTeXTranslator(SphinxTranslator): # (first one is label node) pass else: - self.body.append('\n') + # the \hskip0pt\relax is to allow hyphenation of first word of + # a paragraph in narrow contexts such as in a table cell + self.body.append('\\hskip0pt\\relax\n') def depart_paragraph(self, node: Element) -> None: self.body.append('\n') diff --git a/tests/roots/test-latex-equations/expects/latex-equations.tex b/tests/roots/test-latex-equations/expects/latex-equations.tex index ce07a0128..7732d172b 100644 --- a/tests/roots/test-latex-equations/expects/latex-equations.tex +++ b/tests/roots/test-latex-equations/expects/latex-equations.tex @@ -1,13 +1,14 @@ +\hskip0pt\relax Equation without a label. \begin{equation*} \begin{split}E = mc^2\end{split} -\end{equation*} +\end{equation*}\hskip0pt\relax Equation with label. \begin{equation}\label{equation:equations:test} \begin{split}E = hv\end{split} -\end{equation} +\end{equation}\hskip0pt\relax Second equation without label. \begin{equation*} \begin{split}c^2 = a^2 + b^2\end{split} -\end{equation*} +\end{equation*}\hskip0pt\relax Equation with label \eqref{equation:equations:test} is important. 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 5d524c257..442c68d8d 100644 --- a/tests/roots/test-latex-table/expects/complex_spanning_cell.tex +++ b/tests/roots/test-latex-table/expects/complex_spanning_cell.tex @@ -1,10 +1,10 @@ -\label{\detokenize{complex:complex-spanning-cell}} +\label{\detokenize{complex:complex-spanning-cell}}\hskip0pt\relax table having … \begin{itemize} -\item {} +\item {} \hskip0pt\relax consecutive multirow at top of row (1\sphinxhyphen{}1 and 1\sphinxhyphen{}2) -\item {} +\item {} \hskip0pt\relax consecutive multirow at end of row (1\sphinxhyphen{}4 and 1\sphinxhyphen{}5) \end{itemize} @@ -16,26 +16,30 @@ consecutive multirow at end of row (1\sphinxhyphen{}4 and 1\sphinxhyphen{}5) \hline \sphinxmultirow{3}{1}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} +\hskip0pt\relax cell1\sphinxhyphen{}1 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% &\sphinxmultirow{3}{2}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} +\hskip0pt\relax cell1\sphinxhyphen{}2 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% -& +&\hskip0pt\relax cell1\sphinxhyphen{}3 &\sphinxmultirow{3}{4}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} +\hskip0pt\relax cell1\sphinxhyphen{}4 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% &\sphinxmultirow{2}{5}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} +\hskip0pt\relax cell1\sphinxhyphen{}5 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% @@ -43,12 +47,13 @@ cell1\sphinxhyphen{}5 \\ \cline{3-3}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxmultirow{2}{6}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} +\hskip0pt\relax cell2\sphinxhyphen{}3 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% &\sphinxtablestrut{4}&\sphinxtablestrut{5}\\ -\cline{5-5}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxtablestrut{6}&\sphinxtablestrut{4}& +\cline{5-5}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxtablestrut{6}&\sphinxtablestrut{4}&\hskip0pt\relax cell3\sphinxhyphen{}5 \\ \hline diff --git a/tests/roots/test-latex-table/expects/gridtable.tex b/tests/roots/test-latex-table/expects/gridtable.tex index 28b0b086b..c91773f51 100644 --- a/tests/roots/test-latex-table/expects/gridtable.tex +++ b/tests/roots/test-latex-table/expects/gridtable.tex @@ -4,47 +4,51 @@ \centering \begin{tabulary}{\linewidth}[t]{|T|T|T|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header3 \\ -\hline +\hline\hskip0pt\relax cell1\sphinxhyphen{}1 &\sphinxmultirow{2}{5}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{3}} +\hskip0pt\relax cell1\sphinxhyphen{}2 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% -& +&\hskip0pt\relax cell1\sphinxhyphen{}3 \\ \cline{1-1}\cline{3-3}\sphinxmultirow{2}{7}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{3}} +\hskip0pt\relax cell2\sphinxhyphen{}1 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% -&\sphinxtablestrut{5}& +&\sphinxtablestrut{5}&\hskip0pt\relax cell2\sphinxhyphen{}3 \\ \cline{2-3}\sphinxtablestrut{7}&\sphinxstartmulticolumn{2}% \sphinxmultirow{2}{9}{% \begin{varwidth}[t]{\sphinxcolwidth{2}{3}} +\hskip0pt\relax cell3\sphinxhyphen{}2 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% \sphinxstopmulticolumn \\ -\cline{1-1} +\cline{1-1}\hskip0pt\relax cell4\sphinxhyphen{}1 &\multicolumn{2}{l|}{\sphinxtablestrut{9}}\\ \hline\sphinxstartmulticolumn{3}% \begin{varwidth}[t]{\sphinxcolwidth{3}{3}} +\hskip0pt\relax cell5\sphinxhyphen{}1 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% diff --git a/tests/roots/test-latex-table/expects/longtable.tex b/tests/roots/test-latex-table/expects/longtable.tex index 9febfcef5..041b8749f 100644 --- a/tests/roots/test-latex-table/expects/longtable.tex +++ b/tests/roots/test-latex-table/expects/longtable.tex @@ -2,9 +2,9 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|l|l|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -13,9 +13,9 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -26,19 +26,19 @@ header2 \endfoot \endlastfoot - +\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_align.tex b/tests/roots/test-latex-table/expects/longtable_having_align.tex index 1969e19d2..e9dfe1cc4 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_align.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_align.tex @@ -2,9 +2,9 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[r]{|l|l|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -13,9 +13,9 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -26,19 +26,19 @@ header2 \endfoot \endlastfoot - +\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_caption.tex b/tests/roots/test-latex-table/expects/longtable_having_caption.tex index f0041e9ec..2e0004d44 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_caption.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_caption.tex @@ -4,9 +4,9 @@ \sphinxthelongtablecaptionisattop \caption{caption for longtable\strut}\label{\detokenize{longtable:id1}}\\*[\sphinxlongtablecapskipadjust] \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -15,9 +15,9 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -28,19 +28,19 @@ header2 \endfoot \endlastfoot - +\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex index 050527b69..926cbcc65 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex @@ -2,9 +2,9 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{2}{\X{1}{2}|}} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -13,9 +13,9 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -27,24 +27,24 @@ header2 \endlastfoot \begin{itemize} -\item {} +\item {} \hskip0pt\relax item1 -\item {} +\item {} \hskip0pt\relax item2 \end{itemize} -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex index 68e74c5f4..c0b867edc 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex @@ -2,11 +2,11 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{3}{\X{1}{3}|}} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header3 \\ \hline @@ -15,11 +15,11 @@ header3 \multicolumn{3}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header3 \\ \hline @@ -31,23 +31,23 @@ header3 \endlastfoot \sphinxstyletheadfamily \begin{itemize} -\item {} +\item {} \hskip0pt\relax instub1\sphinxhyphen{}1a -\item {} +\item {} \hskip0pt\relax instub1\sphinxhyphen{}1b \end{itemize} -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax instub1\sphinxhyphen{}2 -& +&\hskip0pt\relax notinstub1\sphinxhyphen{}3 \\ -\hline\sphinxstyletheadfamily +\hline\sphinxstyletheadfamily \hskip0pt\relax cell2\sphinxhyphen{}1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax cell2\sphinxhyphen{}2 -& +&\hskip0pt\relax cell2\sphinxhyphen{}3 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex b/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex index c7213b906..dba6573d1 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex @@ -2,9 +2,9 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{2}{\X{1}{2}|}} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -13,9 +13,9 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -30,17 +30,17 @@ header2 \begin{sphinxVerbatimintable}[commandchars=\\\{\}] \PYG{n}{hello} \PYG{n}{world} \end{sphinxVerbatimintable} -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_widths.tex b/tests/roots/test-latex-table/expects/longtable_having_widths.tex index 884fd9f8a..e2f35e628 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_widths.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_widths.tex @@ -2,9 +2,9 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|\X{30}{100}|\X{70}{100}|} \hline\noalign{\phantomsection\label{\detokenize{longtable:namedlongtable}}\label{\detokenize{longtable:mylongtable}}}% -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -13,9 +13,9 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -26,22 +26,22 @@ header2 \endfoot \endlastfoot - +\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline \end{longtable}\sphinxatlongtableend\end{savenotes} - +\hskip0pt\relax See {\hyperref[\detokenize{longtable:mylongtable}]{\sphinxcrossref{mylongtable}}}, same as {\hyperref[\detokenize{longtable:namedlongtable}]{\sphinxcrossref{\DUrole{std,std-ref}{this one}}}}. diff --git a/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex index 17c5ec4cc..8b91bbecc 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex @@ -2,9 +2,9 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|\X{30}{100}|\X{70}{100}|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -13,9 +13,9 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -27,24 +27,24 @@ header2 \endlastfoot \begin{itemize} -\item {} +\item {} \hskip0pt\relax item1 -\item {} +\item {} \hskip0pt\relax item2 \end{itemize} -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex b/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex index 2fbbbc4ef..5d5936d16 100644 --- a/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex +++ b/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex @@ -2,9 +2,9 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|c|c|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -13,9 +13,9 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline @@ -26,19 +26,19 @@ header2 \endfoot \endlastfoot - +\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/simple_table.tex b/tests/roots/test-latex-table/expects/simple_table.tex index 8044a6cc4..f339ec772 100644 --- a/tests/roots/test-latex-table/expects/simple_table.tex +++ b/tests/roots/test-latex-table/expects/simple_table.tex @@ -4,24 +4,24 @@ \centering \begin{tabulary}{\linewidth}[t]{|T|T|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ -\hline +\hline\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_caption.tex b/tests/roots/test-latex-table/expects/table_having_caption.tex index d4423a05d..dd864f0b6 100644 --- a/tests/roots/test-latex-table/expects/table_having_caption.tex +++ b/tests/roots/test-latex-table/expects/table_having_caption.tex @@ -8,24 +8,24 @@ \sphinxaftertopcaption \begin{tabulary}{\linewidth}[t]{|T|T|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ -\hline +\hline\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex index 7a9b0f293..99a47b940 100644 --- a/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex @@ -4,30 +4,30 @@ \centering \begin{tabular}[t]{|*{2}{\X{1}{2}|}} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline\begin{itemize} -\item {} +\item {} \hskip0pt\relax item1 -\item {} +\item {} \hskip0pt\relax item2 \end{itemize} -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex index 700fc4663..3a4cb7eaa 100644 --- a/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex @@ -4,31 +4,31 @@ \centering \begin{tabular}[t]{|*{3}{\X{1}{3}|}} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header3 \\ \hline\sphinxstyletheadfamily \begin{itemize} -\item {} +\item {} \hskip0pt\relax instub1\sphinxhyphen{}1a -\item {} +\item {} \hskip0pt\relax instub1\sphinxhyphen{}1b \end{itemize} -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax instub1\sphinxhyphen{}2 -& +&\hskip0pt\relax notinstub1\sphinxhyphen{}3 \\ -\hline\sphinxstyletheadfamily +\hline\sphinxstyletheadfamily \hskip0pt\relax cell2\sphinxhyphen{}1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax cell2\sphinxhyphen{}2 -& +&\hskip0pt\relax cell2\sphinxhyphen{}3 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex b/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex index 6d3e81021..daa29f2b2 100644 --- a/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex +++ b/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex @@ -4,14 +4,14 @@ \centering \begin{tabulary}{\linewidth}[t]{|T|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 \\ -\hline +\hline\hskip0pt\relax cell1\sphinxhyphen{}1\sphinxhyphen{}par1 - +\hskip0pt\relax cell1\sphinxhyphen{}1\sphinxhyphen{}par2 - +\hskip0pt\relax cell1\sphinxhyphen{}1\sphinxhyphen{}par3 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_verbatim.tex b/tests/roots/test-latex-table/expects/table_having_verbatim.tex index f66bb8001..e8bba4bf4 100644 --- a/tests/roots/test-latex-table/expects/table_having_verbatim.tex +++ b/tests/roots/test-latex-table/expects/table_having_verbatim.tex @@ -4,26 +4,26 @@ \centering \begin{tabular}[t]{|*{2}{\X{1}{2}|}} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline \begin{sphinxVerbatimintable}[commandchars=\\\{\}] \PYG{n}{hello} \PYG{n}{world} \end{sphinxVerbatimintable} -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_widths.tex b/tests/roots/test-latex-table/expects/table_having_widths.tex index 094596bec..186a7752c 100644 --- a/tests/roots/test-latex-table/expects/table_having_widths.tex +++ b/tests/roots/test-latex-table/expects/table_having_widths.tex @@ -5,29 +5,29 @@ \phantomsection\label{\detokenize{tabular:namedtabular}}\label{\detokenize{tabular:mytabular}}\nobreak \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ -\hline +\hline\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline \end{tabular} \par \sphinxattableend\end{savenotes} - +\hskip0pt\relax See {\hyperref[\detokenize{tabular:mytabular}]{\sphinxcrossref{\DUrole{std,std-ref}{this}}}}, same as {\hyperref[\detokenize{tabular:namedtabular}]{\sphinxcrossref{namedtabular}}}. diff --git a/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex index a636b022e..42346de61 100644 --- a/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex @@ -4,30 +4,30 @@ \centering \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ \hline\begin{itemize} -\item {} +\item {} \hskip0pt\relax item1 -\item {} +\item {} \hskip0pt\relax item2 \end{itemize} -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/tabular_having_widths.tex b/tests/roots/test-latex-table/expects/tabular_having_widths.tex index 5ee1542d4..f516affe6 100644 --- a/tests/roots/test-latex-table/expects/tabular_having_widths.tex +++ b/tests/roots/test-latex-table/expects/tabular_having_widths.tex @@ -4,24 +4,24 @@ \raggedright \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ -\hline +\hline\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/tabularcolumn.tex b/tests/roots/test-latex-table/expects/tabularcolumn.tex index 02e9af440..f7f8d5618 100644 --- a/tests/roots/test-latex-table/expects/tabularcolumn.tex +++ b/tests/roots/test-latex-table/expects/tabularcolumn.tex @@ -4,24 +4,24 @@ \centering \begin{tabulary}{\linewidth}[t]{|c|c|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ -\hline +\hline\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/tabulary_having_widths.tex b/tests/roots/test-latex-table/expects/tabulary_having_widths.tex index 06d347fa3..00874cb89 100644 --- a/tests/roots/test-latex-table/expects/tabulary_having_widths.tex +++ b/tests/roots/test-latex-table/expects/tabulary_having_widths.tex @@ -4,24 +4,24 @@ \raggedleft \begin{tabulary}{\linewidth}[t]{|T|T|} \hline -\sphinxstyletheadfamily +\sphinxstyletheadfamily \hskip0pt\relax header1 -&\sphinxstyletheadfamily +&\sphinxstyletheadfamily \hskip0pt\relax header2 \\ -\hline +\hline\hskip0pt\relax cell1\sphinxhyphen{}1 -& +&\hskip0pt\relax cell1\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell2\sphinxhyphen{}1 -& +&\hskip0pt\relax cell2\sphinxhyphen{}2 \\ -\hline +\hline\hskip0pt\relax cell3\sphinxhyphen{}1 -& +&\hskip0pt\relax cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 6f6041aea..819e088a6 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -730,13 +730,14 @@ def test_footnote(app, status, warning): '\\end{footnote}') in result assert '\\begin{footnote}[3]\\sphinxAtStartFootnote\nnamed\n%\n\\end{footnote}' in result assert '\\sphinxcite{footnote:bar}' in result - assert ('\\bibitem[bar]{footnote:bar}\ncite\n') in result + assert ('\\bibitem[bar]{footnote:bar}\\hskip0pt\\relax\ncite\n') in result assert '\\sphinxcaption{Table caption \\sphinxfootnotemark[4]' in result assert ('\\hline%\n\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n' 'footnote in table caption\n%\n\\end{footnotetext}\\ignorespaces %\n' '\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n' - 'footnote in table header\n%\n\\end{footnotetext}\\ignorespaces \n' - 'VIDIOC\\_CROPCAP\n&\n') in result + 'footnote in table header\n%\n\\end{footnotetext}\\ignorespaces ' + '\\hskip0pt\\relax\n' + 'VIDIOC\\_CROPCAP\n&\\hskip0pt\\relax\n') in result assert ('Information about VIDIOC\\_CROPCAP %\n' '\\begin{footnote}[6]\\sphinxAtStartFootnote\n' 'footnote in table not in header\n%\n\\end{footnote}\n\\\\\n\\hline\n' @@ -776,7 +777,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning): assert ('This is a reference to the code\\sphinxhyphen{}block in the footnote:\n' '{\\hyperref[\\detokenize{index:codeblockinfootnote}]' '{\\sphinxcrossref{\\DUrole{std,std-ref}{I am in a footnote}}}}') in result - assert ('&\nThis is one more footnote with some code in it %\n' + assert ('&\\hskip0pt\\relax\nThis is one more footnote with some code in it %\n' '\\begin{footnote}[11]\\sphinxAtStartFootnote\n' 'Third footnote in longtable\n') in result assert ('\\end{sphinxVerbatim}\n%\n\\end{footnote}.\n') in result @@ -816,13 +817,15 @@ def test_latex_show_urls_is_inline(app, status, warning): assert ('\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde} ' '(http://sphinx\\sphinxhyphen{}doc.org/\\textasciitilde{}test/)') in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{URL in term} ' - '(http://sphinx\\sphinxhyphen{}doc.org/)}] \\leavevmode\nDescription' in result) + '(http://sphinx\\sphinxhyphen{}doc.org/)}] ' + '\\leavevmode\\hskip0pt\\relax\nDescription' in result) assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] ' '\\leavevmode%\n\\begin{footnotetext}[6]\\sphinxAtStartFootnote\n' - 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces \n' - 'Description') in result + 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces ' + '\\hskip0pt\\relax\nDescription') in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist} ' - '(http://sphinx\\sphinxhyphen{}doc.org/)}] \\leavevmode\nDescription') in result + '(http://sphinx\\sphinxhyphen{}doc.org/)}] ' + '\\leavevmode\\hskip0pt\\relax\nDescription') in result assert '\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}' '{sphinx\\sphinxhyphen{}dev@googlegroups.com}') in result @@ -867,16 +870,16 @@ def test_latex_show_urls_is_footnote(app, status, warning): '{URL in term}\\sphinxfootnotemark[9]}] ' '\\leavevmode%\n\\begin{footnotetext}[9]\\sphinxAtStartFootnote\n' '\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n' - '\\end{footnotetext}\\ignorespaces \nDescription') in result + '\\end{footnotetext}\\ignorespaces \\hskip0pt\\relax\nDescription') in result assert ('\\item[{Footnote in term \\sphinxfootnotemark[11]}] ' '\\leavevmode%\n\\begin{footnotetext}[11]\\sphinxAtStartFootnote\n' - 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces \n' - 'Description') in result + 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces ' + '\\hskip0pt\\relax\nDescription') in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}' '\\sphinxfootnotemark[10]}] ' '\\leavevmode%\n\\begin{footnotetext}[10]\\sphinxAtStartFootnote\n' '\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n' - '\\end{footnotetext}\\ignorespaces \nDescription') in result + '\\end{footnotetext}\\ignorespaces \\hskip0pt\\relax\nDescription') in result assert ('\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result) assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}' '{sphinx\\sphinxhyphen{}dev@googlegroups.com}\n') in result @@ -913,13 +916,13 @@ def test_latex_show_urls_is_no(app, status, warning): 'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result assert '\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde}' in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{URL in term}}] ' - '\\leavevmode\nDescription') in result + '\\leavevmode\\hskip0pt\\relax\nDescription') in result assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] ' '\\leavevmode%\n\\begin{footnotetext}[6]\\sphinxAtStartFootnote\n' - 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces \n' - 'Description') in result + 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces ' + '\\hskip0pt\\relax\nDescription') in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}}] ' - '\\leavevmode\nDescription') in result + '\\leavevmode\\hskip0pt\\relax\nDescription') in result assert ('\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result) assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}' '{sphinx\\sphinxhyphen{}dev@googlegroups.com}\n') in result @@ -1354,7 +1357,7 @@ def test_latex_index(app, status, warning): '\\index{equation@\\spxentry{equation}}equation:\n' in result) assert ('\n\\index{Einstein@\\spxentry{Einstein}}' '\\index{relativity@\\spxentry{relativity}}' - '\\ignorespaces \nand') in result + '\\ignorespaces \\hskip0pt\\relax\nand') in result assert ('\n\\index{main \\sphinxleftcurlybrace{}@\\spxentry{' 'main \\sphinxleftcurlybrace{}}}\\ignorespaces ' in result) @@ -1403,7 +1406,7 @@ def test_latex_thebibliography(app, status, warning): result = (app.outdir / 'python.tex').read_text() print(result) assert ('\\begin{sphinxthebibliography}{AuthorYe}\n' - '\\bibitem[AuthorYear]{index:authoryear}\n' + '\\bibitem[AuthorYear]{index:authoryear}\\hskip0pt\\relax\n' 'Author, Title, Year\n' '\\end{sphinxthebibliography}\n' in result) assert '\\sphinxcite{index:authoryear}' in result @@ -1447,7 +1450,8 @@ def test_latex_labels(app, status, warning): r'\end{figure}' in result) assert (r'\caption{labeled figure}' '\\label{\\detokenize{index:figure3}}\n' - '\\begin{sphinxlegend}\nwith a legend\n\\end{sphinxlegend}\n' + '\\begin{sphinxlegend}\\hskip0pt\\relax\n' + 'with a legend\n\\end{sphinxlegend}\n' r'\end{figure}' in result) # code-blocks diff --git a/tests/test_markup.py b/tests/test_markup.py index 18c40ec1d..aa643cdfc 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -158,7 +158,8 @@ def get_verifier(verify, verify_re): ':pep:`8`', ('

PEP 8

'), - ('\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}' + ('\\hskip0pt\\relax\n' + '\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}' '!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{http://www.python.org/dev/peps/pep-0008}' '{\\sphinxstylestrong{PEP 8}}') ), @@ -169,7 +170,8 @@ def get_verifier(verify, verify_re): ('

' 'PEP 8#id1

'), - ('\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}' + ('\\hskip0pt\\relax\n' + '\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}' '!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref' '{http://www.python.org/dev/peps/pep-0008\\#id1}' '{\\sphinxstylestrong{PEP 8\\#id1}}') @@ -180,7 +182,8 @@ def get_verifier(verify, verify_re): ':rfc:`2324`', ('

RFC 2324

'), - ('\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}' + ('\\hskip0pt\\relax\n' + '\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}' '\\sphinxhref{http://tools.ietf.org/html/rfc2324.html}' '{\\sphinxstylestrong{RFC 2324}}') ), @@ -191,7 +194,8 @@ def get_verifier(verify, verify_re): ('

' 'RFC 2324#id1

'), - ('\\index{RFC@\\spxentry{RFC}!RFC 2324\\#id1@\\spxentry{RFC 2324\\#id1}}' + ('\\hskip0pt\\relax\n' + '\\index{RFC@\\spxentry{RFC}!RFC 2324\\#id1@\\spxentry{RFC 2324\\#id1}}' '\\sphinxhref{http://tools.ietf.org/html/rfc2324.html\\#id1}' '{\\sphinxstylestrong{RFC 2324\\#id1}}') ), @@ -201,14 +205,14 @@ def get_verifier(verify, verify_re): '``code sample``', ('

' 'code   sample

'), - r'\\sphinxcode{\\sphinxupquote{code sample}}', + r'\\hskip0pt\\relax\n\\sphinxcode{\\sphinxupquote{code sample}}', ), ( # interpolation of arrows in menuselection 'verify', ':menuselection:`a --> b`', ('

a \N{TRIANGULAR BULLET} b

'), - '\\sphinxmenuselection{a \\(\\rightarrow\\) b}', + '\\hskip0pt\\relax\n\\sphinxmenuselection{a \\(\\rightarrow\\) b}', ), ( # interpolation of ampersands in menuselection @@ -216,7 +220,9 @@ def get_verifier(verify, verify_re): ':menuselection:`&Foo -&&- &Bar`', ('

Foo ' '-&- Bar

'), - r'\sphinxmenuselection{\sphinxaccelerator{F}oo \sphinxhyphen{}\&\sphinxhyphen{} \sphinxaccelerator{B}ar}', + ('\\hskip0pt\\relax\n' + r'\sphinxmenuselection{\sphinxaccelerator{F}oo \sphinxhyphen{}' + r'\&\sphinxhyphen{} \sphinxaccelerator{B}ar}'), ), ( # interpolation of ampersands in guilabel @@ -224,21 +230,22 @@ def get_verifier(verify, verify_re): ':guilabel:`&Foo -&&- &Bar`', ('

Foo ' '-&- Bar

'), - r'\sphinxguilabel{\sphinxaccelerator{F}oo \sphinxhyphen{}\&\sphinxhyphen{} \sphinxaccelerator{B}ar}', + ('\\hskip0pt\\relax\n' + r'\sphinxguilabel{\sphinxaccelerator{F}oo \sphinxhyphen{}\&\sphinxhyphen{} \sphinxaccelerator{B}ar}'), ), ( # no ampersands in guilabel 'verify', ':guilabel:`Foo`', '

Foo

', - r'\sphinxguilabel{Foo}', + '\\hskip0pt\\relax\n\\sphinxguilabel{Foo}', ), ( # kbd role 'verify', ':kbd:`space`', '

space

', - '\\sphinxkeyboard{\\sphinxupquote{space}}', + '\\hskip0pt\\relax\n\\sphinxkeyboard{\\sphinxupquote{space}}', ), ( # kbd role @@ -249,7 +256,7 @@ def get_verifier(verify, verify_re): '+' 'X' '

'), - '\\sphinxkeyboard{\\sphinxupquote{Control+X}}', + '\\hskip0pt\\relax\n\\sphinxkeyboard{\\sphinxupquote{Control+X}}', ), ( # kbd role @@ -260,7 +267,8 @@ def get_verifier(verify, verify_re): '+' '^' '

'), - '\\sphinxkeyboard{\\sphinxupquote{Alt+\\textasciicircum{}}}', + ('\\hskip0pt\\relax\n' + '\\sphinxkeyboard{\\sphinxupquote{Alt+\\textasciicircum{}}}'), ), ( # kbd role @@ -275,21 +283,24 @@ def get_verifier(verify, verify_re): '-' 's' '

'), - '\\sphinxkeyboard{\\sphinxupquote{M\\sphinxhyphen{}x M\\sphinxhyphen{}s}}', + ('\\hskip0pt\\relax\n' + '\\sphinxkeyboard{\\sphinxupquote{M\\sphinxhyphen{}x M\\sphinxhyphen{}s}}'), ), ( # kbd role 'verify', ':kbd:`-`', '

-

', - '\\sphinxkeyboard{\\sphinxupquote{\\sphinxhyphen{}}}', + ('\\hskip0pt\\relax\n' + '\\sphinxkeyboard{\\sphinxupquote{\\sphinxhyphen{}}}'), ), ( # kbd role 'verify', ':kbd:`Caps Lock`', '

Caps Lock

', - '\\sphinxkeyboard{\\sphinxupquote{Caps Lock}}', + ('\\hskip0pt\\relax\n' + '\\sphinxkeyboard{\\sphinxupquote{Caps Lock}}'), ), ( # non-interpolation of dashes in option role @@ -297,14 +308,15 @@ def get_verifier(verify, verify_re): ':option:`--with-option`', ('

' '--with-option

$'), - r'\\sphinxcode{\\sphinxupquote{\\sphinxhyphen{}\\sphinxhyphen{}with\\sphinxhyphen{}option}}$', + (r'\\hskip0pt\\relax\n' + r'\\sphinxcode{\\sphinxupquote{\\sphinxhyphen{}\\sphinxhyphen{}with\\sphinxhyphen{}option}}$'), ), ( # verify smarty-pants quotes 'verify', '"John"', '

“John”

', - "“John”", + "\\hskip0pt\\relax\n“John”", ), ( # ... but not in literal text @@ -312,21 +324,21 @@ def get_verifier(verify, verify_re): '``"John"``', ('

' '"John"

'), - '\\sphinxcode{\\sphinxupquote{"John"}}', + '\\hskip0pt\\relax\n\\sphinxcode{\\sphinxupquote{"John"}}', ), ( # verify classes for inline roles 'verify', ':manpage:`mp(1)`', '

mp(1)

', - '\\sphinxstyleliteralemphasis{\\sphinxupquote{mp(1)}}', + '\\hskip0pt\\relax\n\\sphinxstyleliteralemphasis{\\sphinxupquote{mp(1)}}', ), ( # correct escaping in normal mode 'verify', 'Γ\\\\∞$', None, - 'Γ\\textbackslash{}\\(\\infty\\)\\$', + '\\hskip0pt\\relax\nΓ\\textbackslash{}\\(\\infty\\)\\$', ), ( # in verbatim code fragments @@ -342,7 +354,7 @@ def get_verifier(verify, verify_re): 'verify_re', '`test `_', None, - r'\\sphinxhref{https://www.google.com/~me/}{test}.*', + r'\\hskip0pt\\relax\n\\sphinxhref{https://www.google.com/~me/}{test}.*', ), ( # description list: simple From d6e11b89e9d43120bfd008de5563899e58b80b7d Mon Sep 17 00:00:00 2001 From: jfbu Date: Fri, 29 Jan 2021 10:09:36 +0100 Subject: [PATCH 2/3] Fix suppression of needed whiteline, encapsulate into \sphinxAtStartPar Define it to do nothing with lualatex engine --- doc/latex.rst | 8 ++++ sphinx/texinputs/sphinx.sty | 5 +++ sphinx/writers/latex.py | 4 +- .../expects/latex-equations.tex | 12 ++++-- .../expects/complex_spanning_cell.tex | 30 ++++++++----- .../test-latex-table/expects/gridtable.tex | 33 ++++++++++----- .../test-latex-table/expects/longtable.tex | 30 ++++++++----- .../expects/longtable_having_align.tex | 30 ++++++++----- .../expects/longtable_having_caption.tex | 30 ++++++++----- .../longtable_having_problematic_cell.tex | 33 ++++++++++----- ...ving_stub_columns_and_problematic_cell.tex | 39 +++++++++++------ .../expects/longtable_having_verbatim.tex | 27 ++++++++---- .../expects/longtable_having_widths.tex | 33 ++++++++++----- ...ble_having_widths_and_problematic_cell.tex | 33 ++++++++++----- .../expects/longtable_with_tabularcolumn.tex | 30 ++++++++----- .../test-latex-table/expects/simple_table.tex | 24 +++++++---- .../expects/table_having_caption.tex | 24 +++++++---- .../expects/table_having_problematic_cell.tex | 27 ++++++++---- ...ving_stub_columns_and_problematic_cell.tex | 30 ++++++++----- ...ving_threeparagraphs_cell_in_first_col.tex | 12 ++++-- .../expects/table_having_verbatim.tex | 21 ++++++---- .../expects/table_having_widths.tex | 27 ++++++++---- ...ble_having_widths_and_problematic_cell.tex | 27 ++++++++---- .../expects/tabular_having_widths.tex | 24 +++++++---- .../expects/tabularcolumn.tex | 24 +++++++---- .../expects/tabulary_having_widths.tex | 24 +++++++---- tests/test_build_latex.py | 32 +++++++------- tests/test_markup.py | 42 +++++++++---------- 28 files changed, 468 insertions(+), 247 deletions(-) diff --git a/doc/latex.rst b/doc/latex.rst index 77d58389f..91031f547 100644 --- a/doc/latex.rst +++ b/doc/latex.rst @@ -1024,6 +1024,14 @@ Environments Miscellany ~~~~~~~~~~ +- Every text paragraph in document body starts with `\sphinxAtStartPar`. + Currently, this is used to insert a zero width horizontal skip which + is a trick to allow TeX hyphenation of the first word of a paragraph + in a narrow context (like a table cell). For ``'lualatex'`` which + does not need the trick, the `\sphinxAtStartPar` does nothing. + + .. versionadded:: 3.5.0 + - The section, subsection, ... headings are set using *titlesec*'s ``\titleformat`` command. diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index f406b1089..33d3cc445 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -410,6 +410,11 @@ \DisableKeyvalOption{sphinx}{numfigreset} \DisableKeyvalOption{sphinx}{nonumfigreset} \DisableKeyvalOption{sphinx}{mathnumfig} +% To allow hyphenation of first word in narrow contexts; no option, +% customization to be done via 'preamble' key +\newcommand*\sphinxAtStartPar{\hskip\z@skip} +% No need for the \hspace{0pt} trick (\hskip\z@skip) with luatex +\ifdefined\directlua\let\sphinxAtStartPar\@empty\fi % user interface: options can be changed midway in a document! \newcommand\sphinxsetup[1]{\setkeys{sphinx}{#1}} diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 5d42ad71d..5c65f3353 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1161,9 +1161,9 @@ class LaTeXTranslator(SphinxTranslator): # (first one is label node) pass else: - # the \hskip0pt\relax is to allow hyphenation of first word of + # the \sphinxAtStartPar is to allow hyphenation of first word of # a paragraph in narrow contexts such as in a table cell - self.body.append('\\hskip0pt\\relax\n') + self.body.append('\n\\sphinxAtStartPar\n') def depart_paragraph(self, node: Element) -> None: self.body.append('\n') diff --git a/tests/roots/test-latex-equations/expects/latex-equations.tex b/tests/roots/test-latex-equations/expects/latex-equations.tex index 7732d172b..5374a6721 100644 --- a/tests/roots/test-latex-equations/expects/latex-equations.tex +++ b/tests/roots/test-latex-equations/expects/latex-equations.tex @@ -1,14 +1,18 @@ -\hskip0pt\relax + +\sphinxAtStartPar Equation without a label. \begin{equation*} \begin{split}E = mc^2\end{split} -\end{equation*}\hskip0pt\relax +\end{equation*} +\sphinxAtStartPar Equation with label. \begin{equation}\label{equation:equations:test} \begin{split}E = hv\end{split} -\end{equation}\hskip0pt\relax +\end{equation} +\sphinxAtStartPar Second equation without label. \begin{equation*} \begin{split}c^2 = a^2 + b^2\end{split} -\end{equation*}\hskip0pt\relax +\end{equation*} +\sphinxAtStartPar Equation with label \eqref{equation:equations:test} is important. 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 442c68d8d..4d432f500 100644 --- a/tests/roots/test-latex-table/expects/complex_spanning_cell.tex +++ b/tests/roots/test-latex-table/expects/complex_spanning_cell.tex @@ -1,10 +1,13 @@ -\label{\detokenize{complex:complex-spanning-cell}}\hskip0pt\relax +\label{\detokenize{complex:complex-spanning-cell}} +\sphinxAtStartPar table having … \begin{itemize} -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar consecutive multirow at top of row (1\sphinxhyphen{}1 and 1\sphinxhyphen{}2) -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar consecutive multirow at end of row (1\sphinxhyphen{}4 and 1\sphinxhyphen{}5) \end{itemize} @@ -16,30 +19,35 @@ consecutive multirow at end of row (1\sphinxhyphen{}4 and 1\sphinxhyphen{}5) \hline \sphinxmultirow{3}{1}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}1 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% &\sphinxmultirow{3}{2}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}2 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}3 &\sphinxmultirow{3}{4}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}4 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% &\sphinxmultirow{2}{5}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}5 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% @@ -47,13 +55,15 @@ cell1\sphinxhyphen{}5 \\ \cline{3-3}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxmultirow{2}{6}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{5}} -\hskip0pt\relax + +\sphinxAtStartPar cell2\sphinxhyphen{}3 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% &\sphinxtablestrut{4}&\sphinxtablestrut{5}\\ -\cline{5-5}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxtablestrut{6}&\sphinxtablestrut{4}&\hskip0pt\relax +\cline{5-5}\sphinxtablestrut{1}&\sphinxtablestrut{2}&\sphinxtablestrut{6}&\sphinxtablestrut{4}& +\sphinxAtStartPar cell3\sphinxhyphen{}5 \\ \hline diff --git a/tests/roots/test-latex-table/expects/gridtable.tex b/tests/roots/test-latex-table/expects/gridtable.tex index c91773f51..fc5b757b9 100644 --- a/tests/roots/test-latex-table/expects/gridtable.tex +++ b/tests/roots/test-latex-table/expects/gridtable.tex @@ -4,51 +4,62 @@ \centering \begin{tabulary}{\linewidth}[t]{|T|T|T|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header3 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell1\sphinxhyphen{}1 &\sphinxmultirow{2}{5}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{3}} -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}2 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}3 \\ \cline{1-1}\cline{3-3}\sphinxmultirow{2}{7}{% \begin{varwidth}[t]{\sphinxcolwidth{1}{3}} -\hskip0pt\relax + +\sphinxAtStartPar cell2\sphinxhyphen{}1 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% -&\sphinxtablestrut{5}&\hskip0pt\relax +&\sphinxtablestrut{5}& +\sphinxAtStartPar cell2\sphinxhyphen{}3 \\ \cline{2-3}\sphinxtablestrut{7}&\sphinxstartmulticolumn{2}% \sphinxmultirow{2}{9}{% \begin{varwidth}[t]{\sphinxcolwidth{2}{3}} -\hskip0pt\relax + +\sphinxAtStartPar cell3\sphinxhyphen{}2 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% }% \sphinxstopmulticolumn \\ -\cline{1-1}\hskip0pt\relax +\cline{1-1} +\sphinxAtStartPar cell4\sphinxhyphen{}1 &\multicolumn{2}{l|}{\sphinxtablestrut{9}}\\ \hline\sphinxstartmulticolumn{3}% \begin{varwidth}[t]{\sphinxcolwidth{3}{3}} -\hskip0pt\relax + +\sphinxAtStartPar cell5\sphinxhyphen{}1 \par \vskip-\baselineskip\vbox{\hbox{\strut}}\end{varwidth}% diff --git a/tests/roots/test-latex-table/expects/longtable.tex b/tests/roots/test-latex-table/expects/longtable.tex index 041b8749f..e2138ad58 100644 --- a/tests/roots/test-latex-table/expects/longtable.tex +++ b/tests/roots/test-latex-table/expects/longtable.tex @@ -2,9 +2,11 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|l|l|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -13,9 +15,11 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -26,19 +30,25 @@ header2 \endfoot \endlastfoot -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_align.tex b/tests/roots/test-latex-table/expects/longtable_having_align.tex index e9dfe1cc4..764ef55f3 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_align.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_align.tex @@ -2,9 +2,11 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[r]{|l|l|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -13,9 +15,11 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -26,19 +30,25 @@ header2 \endfoot \endlastfoot -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_caption.tex b/tests/roots/test-latex-table/expects/longtable_having_caption.tex index 2e0004d44..0ca5506be 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_caption.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_caption.tex @@ -4,9 +4,11 @@ \sphinxthelongtablecaptionisattop \caption{caption for longtable\strut}\label{\detokenize{longtable:id1}}\\*[\sphinxlongtablecapskipadjust] \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -15,9 +17,11 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -28,19 +32,25 @@ header2 \endfoot \endlastfoot -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex index 926cbcc65..9551a0a3b 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_problematic_cell.tex @@ -2,9 +2,11 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{2}{\X{1}{2}|}} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -13,9 +15,11 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -27,24 +31,31 @@ header2 \endlastfoot \begin{itemize} -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar item1 -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar item2 \end{itemize} -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex index c0b867edc..e54f8acec 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_stub_columns_and_problematic_cell.tex @@ -2,11 +2,14 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{3}{\X{1}{3}|}} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header3 \\ \hline @@ -15,11 +18,14 @@ header3 \multicolumn{3}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header3 \\ \hline @@ -31,23 +37,30 @@ header3 \endlastfoot \sphinxstyletheadfamily \begin{itemize} -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar instub1\sphinxhyphen{}1a -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar instub1\sphinxhyphen{}1b \end{itemize} -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar instub1\sphinxhyphen{}2 -&\hskip0pt\relax +& +\sphinxAtStartPar notinstub1\sphinxhyphen{}3 \\ -\hline\sphinxstyletheadfamily \hskip0pt\relax +\hline\sphinxstyletheadfamily +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar cell2\sphinxhyphen{}2 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}3 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex b/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex index dba6573d1..a0e7ecfcd 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_verbatim.tex @@ -2,9 +2,11 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|*{2}{\X{1}{2}|}} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -13,9 +15,11 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -30,17 +34,22 @@ header2 \begin{sphinxVerbatimintable}[commandchars=\\\{\}] \PYG{n}{hello} \PYG{n}{world} \end{sphinxVerbatimintable} -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_having_widths.tex b/tests/roots/test-latex-table/expects/longtable_having_widths.tex index e2f35e628..cdd0e7a2b 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_widths.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_widths.tex @@ -2,9 +2,11 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|\X{30}{100}|\X{70}{100}|} \hline\noalign{\phantomsection\label{\detokenize{longtable:namedlongtable}}\label{\detokenize{longtable:mylongtable}}}% -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -13,9 +15,11 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -26,22 +30,29 @@ header2 \endfoot \endlastfoot -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline \end{longtable}\sphinxatlongtableend\end{savenotes} -\hskip0pt\relax + +\sphinxAtStartPar See {\hyperref[\detokenize{longtable:mylongtable}]{\sphinxcrossref{mylongtable}}}, same as {\hyperref[\detokenize{longtable:namedlongtable}]{\sphinxcrossref{\DUrole{std,std-ref}{this one}}}}. diff --git a/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex index 8b91bbecc..ea868ffe4 100644 --- a/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/longtable_having_widths_and_problematic_cell.tex @@ -2,9 +2,11 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|\X{30}{100}|\X{70}{100}|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -13,9 +15,11 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -27,24 +31,31 @@ header2 \endlastfoot \begin{itemize} -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar item1 -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar item2 \end{itemize} -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex b/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex index 5d5936d16..426086de5 100644 --- a/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex +++ b/tests/roots/test-latex-table/expects/longtable_with_tabularcolumn.tex @@ -2,9 +2,11 @@ \begin{savenotes}\sphinxatlongtablestart\begin{longtable}[c]{|c|c|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -13,9 +15,11 @@ header2 \multicolumn{2}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} continued from previous page}}}\\ \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline @@ -26,19 +30,25 @@ header2 \endfoot \endlastfoot -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/simple_table.tex b/tests/roots/test-latex-table/expects/simple_table.tex index f339ec772..a06bfb1cf 100644 --- a/tests/roots/test-latex-table/expects/simple_table.tex +++ b/tests/roots/test-latex-table/expects/simple_table.tex @@ -4,24 +4,32 @@ \centering \begin{tabulary}{\linewidth}[t]{|T|T|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_caption.tex b/tests/roots/test-latex-table/expects/table_having_caption.tex index dd864f0b6..33a5f1d8f 100644 --- a/tests/roots/test-latex-table/expects/table_having_caption.tex +++ b/tests/roots/test-latex-table/expects/table_having_caption.tex @@ -8,24 +8,32 @@ \sphinxaftertopcaption \begin{tabulary}{\linewidth}[t]{|T|T|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex index 99a47b940..c5c57e2f7 100644 --- a/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_problematic_cell.tex @@ -4,30 +4,39 @@ \centering \begin{tabular}[t]{|*{2}{\X{1}{2}|}} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline\begin{itemize} -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar item1 -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar item2 \end{itemize} -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex index 3a4cb7eaa..13c48a213 100644 --- a/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_stub_columns_and_problematic_cell.tex @@ -4,31 +4,41 @@ \centering \begin{tabular}[t]{|*{3}{\X{1}{3}|}} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header3 \\ \hline\sphinxstyletheadfamily \begin{itemize} -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar instub1\sphinxhyphen{}1a -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar instub1\sphinxhyphen{}1b \end{itemize} -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar instub1\sphinxhyphen{}2 -&\hskip0pt\relax +& +\sphinxAtStartPar notinstub1\sphinxhyphen{}3 \\ -\hline\sphinxstyletheadfamily \hskip0pt\relax +\hline\sphinxstyletheadfamily +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar cell2\sphinxhyphen{}2 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}3 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex b/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex index daa29f2b2..c1a440558 100644 --- a/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex +++ b/tests/roots/test-latex-table/expects/table_having_threeparagraphs_cell_in_first_col.tex @@ -4,14 +4,18 @@ \centering \begin{tabulary}{\linewidth}[t]{|T|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell1\sphinxhyphen{}1\sphinxhyphen{}par1 -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}1\sphinxhyphen{}par2 -\hskip0pt\relax + +\sphinxAtStartPar cell1\sphinxhyphen{}1\sphinxhyphen{}par3 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_verbatim.tex b/tests/roots/test-latex-table/expects/table_having_verbatim.tex index e8bba4bf4..23faac55e 100644 --- a/tests/roots/test-latex-table/expects/table_having_verbatim.tex +++ b/tests/roots/test-latex-table/expects/table_having_verbatim.tex @@ -4,26 +4,33 @@ \centering \begin{tabular}[t]{|*{2}{\X{1}{2}|}} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline \begin{sphinxVerbatimintable}[commandchars=\\\{\}] \PYG{n}{hello} \PYG{n}{world} \end{sphinxVerbatimintable} -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/table_having_widths.tex b/tests/roots/test-latex-table/expects/table_having_widths.tex index 186a7752c..d01a40576 100644 --- a/tests/roots/test-latex-table/expects/table_having_widths.tex +++ b/tests/roots/test-latex-table/expects/table_having_widths.tex @@ -5,29 +5,38 @@ \phantomsection\label{\detokenize{tabular:namedtabular}}\label{\detokenize{tabular:mytabular}}\nobreak \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline \end{tabular} \par \sphinxattableend\end{savenotes} -\hskip0pt\relax + +\sphinxAtStartPar See {\hyperref[\detokenize{tabular:mytabular}]{\sphinxcrossref{\DUrole{std,std-ref}{this}}}}, same as {\hyperref[\detokenize{tabular:namedtabular}]{\sphinxcrossref{namedtabular}}}. diff --git a/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex b/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex index 42346de61..ca6b697e5 100644 --- a/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex +++ b/tests/roots/test-latex-table/expects/table_having_widths_and_problematic_cell.tex @@ -4,30 +4,39 @@ \centering \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ \hline\begin{itemize} -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar item1 -\item {} \hskip0pt\relax +\item {} +\sphinxAtStartPar item2 \end{itemize} -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/tabular_having_widths.tex b/tests/roots/test-latex-table/expects/tabular_having_widths.tex index f516affe6..596ba4868 100644 --- a/tests/roots/test-latex-table/expects/tabular_having_widths.tex +++ b/tests/roots/test-latex-table/expects/tabular_having_widths.tex @@ -4,24 +4,32 @@ \raggedright \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/tabularcolumn.tex b/tests/roots/test-latex-table/expects/tabularcolumn.tex index f7f8d5618..c020e0cb4 100644 --- a/tests/roots/test-latex-table/expects/tabularcolumn.tex +++ b/tests/roots/test-latex-table/expects/tabularcolumn.tex @@ -4,24 +4,32 @@ \centering \begin{tabulary}{\linewidth}[t]{|c|c|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/roots/test-latex-table/expects/tabulary_having_widths.tex b/tests/roots/test-latex-table/expects/tabulary_having_widths.tex index 00874cb89..0b42fb0cf 100644 --- a/tests/roots/test-latex-table/expects/tabulary_having_widths.tex +++ b/tests/roots/test-latex-table/expects/tabulary_having_widths.tex @@ -4,24 +4,32 @@ \raggedleft \begin{tabulary}{\linewidth}[t]{|T|T|} \hline -\sphinxstyletheadfamily \hskip0pt\relax +\sphinxstyletheadfamily +\sphinxAtStartPar header1 -&\sphinxstyletheadfamily \hskip0pt\relax +&\sphinxstyletheadfamily +\sphinxAtStartPar header2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell1\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell1\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell2\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell2\sphinxhyphen{}2 \\ -\hline\hskip0pt\relax +\hline +\sphinxAtStartPar cell3\sphinxhyphen{}1 -&\hskip0pt\relax +& +\sphinxAtStartPar cell3\sphinxhyphen{}2 \\ \hline diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 819e088a6..a67871f60 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -730,14 +730,14 @@ def test_footnote(app, status, warning): '\\end{footnote}') in result assert '\\begin{footnote}[3]\\sphinxAtStartFootnote\nnamed\n%\n\\end{footnote}' in result assert '\\sphinxcite{footnote:bar}' in result - assert ('\\bibitem[bar]{footnote:bar}\\hskip0pt\\relax\ncite\n') in result + assert ('\\bibitem[bar]{footnote:bar}\n\\sphinxAtStartPar\ncite\n') in result assert '\\sphinxcaption{Table caption \\sphinxfootnotemark[4]' in result assert ('\\hline%\n\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n' 'footnote in table caption\n%\n\\end{footnotetext}\\ignorespaces %\n' '\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n' 'footnote in table header\n%\n\\end{footnotetext}\\ignorespaces ' - '\\hskip0pt\\relax\n' - 'VIDIOC\\_CROPCAP\n&\\hskip0pt\\relax\n') in result + '\n\\sphinxAtStartPar\n' + 'VIDIOC\\_CROPCAP\n&\n\\sphinxAtStartPar\n') in result assert ('Information about VIDIOC\\_CROPCAP %\n' '\\begin{footnote}[6]\\sphinxAtStartFootnote\n' 'footnote in table not in header\n%\n\\end{footnote}\n\\\\\n\\hline\n' @@ -777,7 +777,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning): assert ('This is a reference to the code\\sphinxhyphen{}block in the footnote:\n' '{\\hyperref[\\detokenize{index:codeblockinfootnote}]' '{\\sphinxcrossref{\\DUrole{std,std-ref}{I am in a footnote}}}}') in result - assert ('&\\hskip0pt\\relax\nThis is one more footnote with some code in it %\n' + assert ('&\n\\sphinxAtStartPar\nThis is one more footnote with some code in it %\n' '\\begin{footnote}[11]\\sphinxAtStartFootnote\n' 'Third footnote in longtable\n') in result assert ('\\end{sphinxVerbatim}\n%\n\\end{footnote}.\n') in result @@ -818,14 +818,14 @@ def test_latex_show_urls_is_inline(app, status, warning): '(http://sphinx\\sphinxhyphen{}doc.org/\\textasciitilde{}test/)') in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{URL in term} ' '(http://sphinx\\sphinxhyphen{}doc.org/)}] ' - '\\leavevmode\\hskip0pt\\relax\nDescription' in result) + '\\leavevmode\n\\sphinxAtStartPar\nDescription' in result) assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] ' '\\leavevmode%\n\\begin{footnotetext}[6]\\sphinxAtStartFootnote\n' 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces ' - '\\hskip0pt\\relax\nDescription') in result + '\n\\sphinxAtStartPar\nDescription') in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist} ' '(http://sphinx\\sphinxhyphen{}doc.org/)}] ' - '\\leavevmode\\hskip0pt\\relax\nDescription') in result + '\\leavevmode\n\\sphinxAtStartPar\nDescription') in result assert '\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}' '{sphinx\\sphinxhyphen{}dev@googlegroups.com}') in result @@ -870,16 +870,16 @@ def test_latex_show_urls_is_footnote(app, status, warning): '{URL in term}\\sphinxfootnotemark[9]}] ' '\\leavevmode%\n\\begin{footnotetext}[9]\\sphinxAtStartFootnote\n' '\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n' - '\\end{footnotetext}\\ignorespaces \\hskip0pt\\relax\nDescription') in result + '\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result assert ('\\item[{Footnote in term \\sphinxfootnotemark[11]}] ' '\\leavevmode%\n\\begin{footnotetext}[11]\\sphinxAtStartFootnote\n' 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces ' - '\\hskip0pt\\relax\nDescription') in result + '\n\\sphinxAtStartPar\nDescription') in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}' '\\sphinxfootnotemark[10]}] ' '\\leavevmode%\n\\begin{footnotetext}[10]\\sphinxAtStartFootnote\n' '\\sphinxnolinkurl{http://sphinx-doc.org/}\n%\n' - '\\end{footnotetext}\\ignorespaces \\hskip0pt\\relax\nDescription') in result + '\\end{footnotetext}\\ignorespaces \n\\sphinxAtStartPar\nDescription') in result assert ('\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result) assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}' '{sphinx\\sphinxhyphen{}dev@googlegroups.com}\n') in result @@ -916,13 +916,13 @@ def test_latex_show_urls_is_no(app, status, warning): 'Footnote inside footnote\n%\n\\end{footnotetext}\\ignorespaces') in result assert '\\sphinxhref{http://sphinx-doc.org/~test/}{URL including tilde}' in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{URL in term}}] ' - '\\leavevmode\\hskip0pt\\relax\nDescription') in result + '\\leavevmode\n\\sphinxAtStartPar\nDescription') in result assert ('\\item[{Footnote in term \\sphinxfootnotemark[6]}] ' '\\leavevmode%\n\\begin{footnotetext}[6]\\sphinxAtStartFootnote\n' 'Footnote in term\n%\n\\end{footnotetext}\\ignorespaces ' - '\\hskip0pt\\relax\nDescription') in result + '\n\\sphinxAtStartPar\nDescription') in result assert ('\\item[{\\sphinxhref{http://sphinx-doc.org/}{Term in deflist}}] ' - '\\leavevmode\\hskip0pt\\relax\nDescription') in result + '\\leavevmode\n\\sphinxAtStartPar\nDescription') in result assert ('\\sphinxurl{https://github.com/sphinx-doc/sphinx}\n' in result) assert ('\\sphinxhref{mailto:sphinx-dev@googlegroups.com}' '{sphinx\\sphinxhyphen{}dev@googlegroups.com}\n') in result @@ -1357,7 +1357,7 @@ def test_latex_index(app, status, warning): '\\index{equation@\\spxentry{equation}}equation:\n' in result) assert ('\n\\index{Einstein@\\spxentry{Einstein}}' '\\index{relativity@\\spxentry{relativity}}' - '\\ignorespaces \\hskip0pt\\relax\nand') in result + '\\ignorespaces \n\\sphinxAtStartPar\nand') in result assert ('\n\\index{main \\sphinxleftcurlybrace{}@\\spxentry{' 'main \\sphinxleftcurlybrace{}}}\\ignorespaces ' in result) @@ -1406,7 +1406,7 @@ def test_latex_thebibliography(app, status, warning): result = (app.outdir / 'python.tex').read_text() print(result) assert ('\\begin{sphinxthebibliography}{AuthorYe}\n' - '\\bibitem[AuthorYear]{index:authoryear}\\hskip0pt\\relax\n' + '\\bibitem[AuthorYear]{index:authoryear}\n\\sphinxAtStartPar\n' 'Author, Title, Year\n' '\\end{sphinxthebibliography}\n' in result) assert '\\sphinxcite{index:authoryear}' in result @@ -1450,7 +1450,7 @@ def test_latex_labels(app, status, warning): r'\end{figure}' in result) assert (r'\caption{labeled figure}' '\\label{\\detokenize{index:figure3}}\n' - '\\begin{sphinxlegend}\\hskip0pt\\relax\n' + '\\begin{sphinxlegend}\n\\sphinxAtStartPar\n' 'with a legend\n\\end{sphinxlegend}\n' r'\end{figure}' in result) diff --git a/tests/test_markup.py b/tests/test_markup.py index aa643cdfc..f8fff1c2d 100644 --- a/tests/test_markup.py +++ b/tests/test_markup.py @@ -158,7 +158,7 @@ def get_verifier(verify, verify_re): ':pep:`8`', ('

PEP 8

'), - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' '\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}' '!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{http://www.python.org/dev/peps/pep-0008}' '{\\sphinxstylestrong{PEP 8}}') @@ -170,7 +170,7 @@ def get_verifier(verify, verify_re): ('

' 'PEP 8#id1

'), - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' '\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}' '!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref' '{http://www.python.org/dev/peps/pep-0008\\#id1}' @@ -182,7 +182,7 @@ def get_verifier(verify, verify_re): ':rfc:`2324`', ('

RFC 2324

'), - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' '\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}' '\\sphinxhref{http://tools.ietf.org/html/rfc2324.html}' '{\\sphinxstylestrong{RFC 2324}}') @@ -194,7 +194,7 @@ def get_verifier(verify, verify_re): ('

' 'RFC 2324#id1

'), - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' '\\index{RFC@\\spxentry{RFC}!RFC 2324\\#id1@\\spxentry{RFC 2324\\#id1}}' '\\sphinxhref{http://tools.ietf.org/html/rfc2324.html\\#id1}' '{\\sphinxstylestrong{RFC 2324\\#id1}}') @@ -205,14 +205,14 @@ def get_verifier(verify, verify_re): '``code sample``', ('

' 'code   sample

'), - r'\\hskip0pt\\relax\n\\sphinxcode{\\sphinxupquote{code sample}}', + r'\\sphinxAtStartPar\n\\sphinxcode{\\sphinxupquote{code sample}}', ), ( # interpolation of arrows in menuselection 'verify', ':menuselection:`a --> b`', ('

a \N{TRIANGULAR BULLET} b

'), - '\\hskip0pt\\relax\n\\sphinxmenuselection{a \\(\\rightarrow\\) b}', + '\\sphinxAtStartPar\n\\sphinxmenuselection{a \\(\\rightarrow\\) b}', ), ( # interpolation of ampersands in menuselection @@ -220,7 +220,7 @@ def get_verifier(verify, verify_re): ':menuselection:`&Foo -&&- &Bar`', ('

Foo ' '-&- Bar

'), - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' r'\sphinxmenuselection{\sphinxaccelerator{F}oo \sphinxhyphen{}' r'\&\sphinxhyphen{} \sphinxaccelerator{B}ar}'), ), @@ -230,7 +230,7 @@ def get_verifier(verify, verify_re): ':guilabel:`&Foo -&&- &Bar`', ('

Foo ' '-&- Bar

'), - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' r'\sphinxguilabel{\sphinxaccelerator{F}oo \sphinxhyphen{}\&\sphinxhyphen{} \sphinxaccelerator{B}ar}'), ), ( @@ -238,14 +238,14 @@ def get_verifier(verify, verify_re): 'verify', ':guilabel:`Foo`', '

Foo

', - '\\hskip0pt\\relax\n\\sphinxguilabel{Foo}', + '\\sphinxAtStartPar\n\\sphinxguilabel{Foo}', ), ( # kbd role 'verify', ':kbd:`space`', '

space

', - '\\hskip0pt\\relax\n\\sphinxkeyboard{\\sphinxupquote{space}}', + '\\sphinxAtStartPar\n\\sphinxkeyboard{\\sphinxupquote{space}}', ), ( # kbd role @@ -256,7 +256,7 @@ def get_verifier(verify, verify_re): '+' 'X' '

'), - '\\hskip0pt\\relax\n\\sphinxkeyboard{\\sphinxupquote{Control+X}}', + '\\sphinxAtStartPar\n\\sphinxkeyboard{\\sphinxupquote{Control+X}}', ), ( # kbd role @@ -267,7 +267,7 @@ def get_verifier(verify, verify_re): '+' '^' '

'), - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' '\\sphinxkeyboard{\\sphinxupquote{Alt+\\textasciicircum{}}}'), ), ( @@ -283,7 +283,7 @@ def get_verifier(verify, verify_re): '-' 's' '

'), - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' '\\sphinxkeyboard{\\sphinxupquote{M\\sphinxhyphen{}x M\\sphinxhyphen{}s}}'), ), ( @@ -291,7 +291,7 @@ def get_verifier(verify, verify_re): 'verify', ':kbd:`-`', '

-

', - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' '\\sphinxkeyboard{\\sphinxupquote{\\sphinxhyphen{}}}'), ), ( @@ -299,7 +299,7 @@ def get_verifier(verify, verify_re): 'verify', ':kbd:`Caps Lock`', '

Caps Lock

', - ('\\hskip0pt\\relax\n' + ('\\sphinxAtStartPar\n' '\\sphinxkeyboard{\\sphinxupquote{Caps Lock}}'), ), ( @@ -308,7 +308,7 @@ def get_verifier(verify, verify_re): ':option:`--with-option`', ('

' '--with-option

$'), - (r'\\hskip0pt\\relax\n' + (r'\\sphinxAtStartPar\n' r'\\sphinxcode{\\sphinxupquote{\\sphinxhyphen{}\\sphinxhyphen{}with\\sphinxhyphen{}option}}$'), ), ( @@ -316,7 +316,7 @@ def get_verifier(verify, verify_re): 'verify', '"John"', '

“John”

', - "\\hskip0pt\\relax\n“John”", + "\\sphinxAtStartPar\n“John”", ), ( # ... but not in literal text @@ -324,21 +324,21 @@ def get_verifier(verify, verify_re): '``"John"``', ('

' '"John"

'), - '\\hskip0pt\\relax\n\\sphinxcode{\\sphinxupquote{"John"}}', + '\\sphinxAtStartPar\n\\sphinxcode{\\sphinxupquote{"John"}}', ), ( # verify classes for inline roles 'verify', ':manpage:`mp(1)`', '

mp(1)

', - '\\hskip0pt\\relax\n\\sphinxstyleliteralemphasis{\\sphinxupquote{mp(1)}}', + '\\sphinxAtStartPar\n\\sphinxstyleliteralemphasis{\\sphinxupquote{mp(1)}}', ), ( # correct escaping in normal mode 'verify', 'Γ\\\\∞$', None, - '\\hskip0pt\\relax\nΓ\\textbackslash{}\\(\\infty\\)\\$', + '\\sphinxAtStartPar\nΓ\\textbackslash{}\\(\\infty\\)\\$', ), ( # in verbatim code fragments @@ -354,7 +354,7 @@ def get_verifier(verify, verify_re): 'verify_re', '`test `_', None, - r'\\hskip0pt\\relax\n\\sphinxhref{https://www.google.com/~me/}{test}.*', + r'\\sphinxAtStartPar\n\\sphinxhref{https://www.google.com/~me/}{test}.*', ), ( # description list: simple From 17642a5e6bbcccc5616da381c10a068c9e09b6d7 Mon Sep 17 00:00:00 2001 From: jfbu Date: Fri, 29 Jan 2021 13:10:21 +0100 Subject: [PATCH 3/3] Add \nobreak inside \sphinxAtStartPar Else, a non-hyphenatable long word as first word in a narrow column in a longtable/tabular (with column type e.g. p{1cm} from tabularcolumns directive) gets shifted downwards vertically in PDF output. Memo: 1. I did not find other cases where such a vertical shift may occur (I tried with deeply nested lists and artificial words such as 'A'*32) with LaTeX mark-up produced by Sphinx, 2. but with the support of hlist directive via PR #8779 using multicols environment, there is again this situation of downwards shift of non-hyphenatable long first words. But it occurs whether or not \sphinxAtStartPar is used (\nobreak does not modify this). --- sphinx/texinputs/sphinx.sty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 33d3cc445..f040fde7f 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -412,7 +412,7 @@ \DisableKeyvalOption{sphinx}{mathnumfig} % To allow hyphenation of first word in narrow contexts; no option, % customization to be done via 'preamble' key -\newcommand*\sphinxAtStartPar{\hskip\z@skip} +\newcommand*\sphinxAtStartPar{\nobreak\hskip\z@skip} % No need for the \hspace{0pt} trick (\hskip\z@skip) with luatex \ifdefined\directlua\let\sphinxAtStartPar\@empty\fi % user interface: options can be changed midway in a document!