docs-templates/templates/tabular.tex.jinja

102 lines
3.1 KiB
Django/Jinja

\begin{savenotes}
\sphinxatlongtablestart
\sphinxthistablewithglobalstyle
<% if 'booktabs' in table.styles -%>
\sphinxthistablewithbooktabsstyle
<% endif -%>
<% if 'borderless' in table.styles -%>
\sphinxthistablewithborderlessstyle
<% endif -%>
<% if 'standard' in table.styles -%>
\sphinxthistablewithstandardstyle
<% endif -%>
<% if 'vlines' in table.styles -%>
\sphinxthistablewithvlinesstyle
<% endif -%>
<% if 'novlines' in table.styles -%>
\sphinxthistablewithnovlinesstyle
<% endif -%>
<% if 'colorrows' in table.styles -%>
\sphinxthistablewithcolorrowsstyle
<% endif -%>
<% if 'nocolorrows' in table.styles -%>
\sphinxthistablewithnocolorrowsstyle
<% endif -%>
\makeatletter
<%- if table.align == 'default' %>
\LTleft 0cm
\LTright 0cm
<%- elif table.align == 'center' %>
\LTleft \@totalleftmargin plus1fill
\LTright\dimexpr\columnwidth-\@totalleftmargin-\linewidth\relax plus1fill
<%- elif table.align == 'left' %>
\LTleft \@totalleftmargin
\LTright\dimexpr\columnwidth-\@totalleftmargin-\linewidth\relax plus1fill
<%- elif table.align == 'right' %>
\LTleft \@totalleftmargin plus1fill
\LTright\dimexpr\columnwidth-\@totalleftmargin-\linewidth\relax
<%- endif %>
\makeatother
<% set total_width = table.colwidths|sum %>
<% set colspec_parts = [] %>
<% set min_widths = [] %>
<% for width in table.colwidths %>
<% set computed_width = (width * 0.92) / total_width %>
<% set adjusted_width = computed_width if computed_width >= 0.1 else 0.1 %>
<% set min_widths = min_widths.append(adjusted_width) %>
<% endfor %>
<% set total_column_width = min_widths|sum %>
<% set normalized_widths = [] %>
<% if total_column_width > 0.92 %>
<% set normalization_factor = 0.92 / total_column_width %>
<% for min_width in min_widths %>
<% set temp = min_width * normalization_factor %>
<% set normalized_widths = normalized_widths.append(temp) %>
<% endfor %>
<% else %>
<% set normalized_widths = min_widths %>
<% endif %>
<% for width in normalized_widths %>
<% set part = '>{{\\raggedright\\arraybackslash}}p{{{:.4f}\\textwidth}}'.format(width) %>
<% set colspec_parts = colspec_parts.append(part) %>
<% endfor %>
<% set colspec_string = ''.join(colspec_parts) %>
\begin{longtable}{<%= colspec_string %>}
<%- if table.caption -%>
\sphinxthelongtablecaptionisattop
\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
<% elif labels -%>
\noalign{\phantomsection<%= labels %>}%
<% endif -%>
\sphinxtoprule
<%= ''.join(table.header) -%>
<%- if table.header -%>
\sphinxmidrule
<% endif -%>
\endfirsthead
\multicolumn{<%= table.colcount %>}{c}{\sphinxnorowcolor
\makebox[0pt]{\sphinxtablecontinued{\tablename\ \thetable{} \textendash{} <%= _('continued from previous page') %>}}%
}\\
\sphinxtoprule
<%= ''.join(table.header) -%>
<%- if table.header -%>
\sphinxmidrule
<% endif -%>
\endhead
\sphinxbottomrule
\multicolumn{<%= table.colcount %>}{r}{\sphinxnorowcolor
\makebox[0pt][r]{\sphinxtablecontinued{<%= _('continues on next page') %>}}%
}\\
\endfoot
\endlastfoot
\sphinxtableatstartofbodyhook
<%= ''.join(table.body) -%>
\sphinxbottomrule
\end{longtable}
\sphinxtableafterendhook
\sphinxatlongtableend
\end{savenotes}