Skip to content

Commit

Permalink
Fix EOL removals from conditionals in the table latex templates
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
jfbu committed Aug 6, 2022
1 parent d6dd300 commit 5edd786
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions sphinx/templates/latex/longtable.tex_t
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -54,7 +54,7 @@

\endlastfoot
<%= ''.join(table.body) %>
<%- if table.booktabs -%>
<% if table.booktabs -%>
\bottomrule
<% endif -%>
\end{longtable}\sphinxatlongtableend\end{savenotes}
14 changes: 7 additions & 7 deletions sphinx/templates/latex/tabular.tex_t
Expand Up @@ -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}
14 changes: 7 additions & 7 deletions sphinx/templates/latex/tabulary.tex_t
Expand Up @@ -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}

0 comments on commit 5edd786

Please sign in to comment.