From 5edd78642d48b7c6eb22e1994e223e5a5201efa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20B?= <2589111+jfbu@users.noreply.github.com> Date: Sat, 6 Aug 2022 19:31:48 +0200 Subject: [PATCH] Fix EOL removals from conditionals in the table latex templates This business of conditionals and EOLs is a can of worms. I spend time on this but it is expected to completely remove these conditionals from the templates and use \sphinxtoprule, \sphinxmidrule, \sphinxbottomrule mark-up rather. MEMO: I saw an \hline in a tabulary in tests which does not come from template but from table body, so this should be tracked and modified where it originates (presumably sphinx/writes/latex.py). --- sphinx/templates/latex/longtable.tex_t | 14 +++++++------- sphinx/templates/latex/tabular.tex_t | 14 +++++++------- sphinx/templates/latex/tabulary.tex_t | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sphinx/templates/latex/longtable.tex_t b/sphinx/templates/latex/longtable.tex_t index 862a9eae5d7..a1c8e9b7fb9 100644 --- a/sphinx/templates/latex/longtable.tex_t +++ b/sphinx/templates/latex/longtable.tex_t @@ -10,19 +10,19 @@ <%- if table.caption -%> \sphinxthelongtablecaptionisattop \caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust] -<%- if table.booktabs -%> +<% if table.booktabs -%> \toprule <% else -%> \hline <% endif -%> <% elif labels -%> -<%- if table.booktabs -%> +<% if table.booktabs -%> \toprule\noalign{\phantomsection<%= labels %>}% <% else -%> \hline\noalign{\phantomsection<%= labels %>}% <% endif -%> <% else -%> -<%- if table.booktabs -%> +<% if table.booktabs -%> \toprule <% else -%> \hline @@ -33,18 +33,18 @@ \multicolumn{<%= table.colcount %>}{c}% {\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} <%= _('continued from previous page') %>}}}\\ -<%- if table.booktabs -%> +<% if table.booktabs -%> \toprule <% else -%> \hline <% endif -%> <%= ''.join(table.header) %> -<%- if table.header and table.booktabs -%> +<% if table.header and table.booktabs -%> \midrule <% endif -%> \endhead -<%- if table.booktabs -%> +<% if table.booktabs -%> \bottomrule <% else -%> \hline @@ -54,7 +54,7 @@ \endlastfoot <%= ''.join(table.body) %> -<%- if table.booktabs -%> +<% if table.booktabs -%> \bottomrule <% endif -%> \end{longtable}\sphinxatlongtableend\end{savenotes} diff --git a/sphinx/templates/latex/tabular.tex_t b/sphinx/templates/latex/tabular.tex_t index e1cb39311b2..5002b35e997 100644 --- a/sphinx/templates/latex/tabular.tex_t +++ b/sphinx/templates/latex/tabular.tex_t @@ -19,19 +19,19 @@ \phantomsection<%= labels %>\nobreak <% endif -%> \begin{tabular}[t]<%= table.get_colspec() -%> -<%- if table.booktabs -%> +<% if table.booktabs -%> \toprule -<%- else -%> +<% else -%> \hline -<%- endif -%> +<% endif -%> <%= ''.join(table.header) %> -<%- if table.header and table.booktabs -%> +<%- if table.header and table.booktabs %> \midrule -<%- endif -%> +<% endif -%> <%=- ''.join(table.body) %> -<%- if table.booktabs -%> +<% if table.booktabs -%> \bottomrule -<%- endif -%> +<% endif -%> \end{tabular} \par \sphinxattableend\end{savenotes} diff --git a/sphinx/templates/latex/tabulary.tex_t b/sphinx/templates/latex/tabulary.tex_t index 15a8f058a8f..917ecfbe644 100644 --- a/sphinx/templates/latex/tabulary.tex_t +++ b/sphinx/templates/latex/tabulary.tex_t @@ -19,19 +19,19 @@ \phantomsection<%= labels %>\nobreak <% endif -%> \begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%> -<%- if table.booktabs -%> +<% if table.booktabs -%> \toprule -<%- else -%> +<% else -%> \hline -<%- endif -%> +<% endif -%> <%= ''.join(table.header) %> -<%- if table.header and table.booktabs -%> +<%- if table.header and table.booktabs %> \midrule -<%- endif -%> +<% endif -%> <%=- ''.join(table.body) %> -<%- if table.booktabs -%> +<% if table.booktabs -%> \bottomrule -<%- endif -%> +<% endif -%> \end{tabulary} \par \sphinxattableend\end{savenotes}