Min Width for tables #3
@ -39,14 +39,32 @@
 | 
				
			|||||||
\makeatother
 | 
					\makeatother
 | 
				
			||||||
<% set total_width = table.colwidths|sum %>
 | 
					<% set total_width = table.colwidths|sum %>
 | 
				
			||||||
<% set colspec_parts = [] %>
 | 
					<% set colspec_parts = [] %>
 | 
				
			||||||
 | 
					<% set min_widths = [] %>
 | 
				
			||||||
<% for width in table.colwidths %>
 | 
					<% for width in table.colwidths %>
 | 
				
			||||||
  <% set part = '>{{\\raggedright\\arraybackslash}}p{{{:.4f}\\textwidth}}'.format((width * 0.92) / total_width) %>
 | 
					  <% 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) %>
 | 
					  <% set colspec_parts = colspec_parts.append(part) %>
 | 
				
			||||||
<% endfor  %>
 | 
					<% endfor  %>
 | 
				
			||||||
<% set colspec_string = ''.join(colspec_parts) %>
 | 
					<% set colspec_string = ''.join(colspec_parts) %>
 | 
				
			||||||
\begin{longtable}{<%= colspec_string %>}
 | 
					\begin{longtable}{<%= colspec_string %>}
 | 
				
			||||||
<%- if table.caption -%>
 | 
					<%- if table.caption -%>
 | 
				
			||||||
\sphinxthelongtablecaptionisattop
 | 
					\sphinxthelongtablecaptionisattop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
 | 
					\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
 | 
				
			||||||
<% elif labels -%>
 | 
					<% elif labels -%>
 | 
				
			||||||
\noalign{\phantomsection<%= labels %>}%
 | 
					\noalign{\phantomsection<%= labels %>}%
 | 
				
			||||||
 | 
				
			|||||||
@ -39,14 +39,32 @@
 | 
				
			|||||||
\makeatother
 | 
					\makeatother
 | 
				
			||||||
<% set total_width = table.colwidths|sum %>
 | 
					<% set total_width = table.colwidths|sum %>
 | 
				
			||||||
<% set colspec_parts = [] %>
 | 
					<% set colspec_parts = [] %>
 | 
				
			||||||
 | 
					<% set min_widths = [] %>
 | 
				
			||||||
<% for width in table.colwidths %>
 | 
					<% for width in table.colwidths %>
 | 
				
			||||||
  <% set part = '>{{\\raggedright\\arraybackslash}}p{{{:.4f}\\textwidth}}'.format((width * 0.92) / total_width) %>
 | 
					  <% 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) %>
 | 
					  <% set colspec_parts = colspec_parts.append(part) %>
 | 
				
			||||||
<% endfor  %>
 | 
					<% endfor  %>
 | 
				
			||||||
<% set colspec_string = ''.join(colspec_parts) %>
 | 
					<% set colspec_string = ''.join(colspec_parts) %>
 | 
				
			||||||
\begin{longtable}{<%= colspec_string %>}
 | 
					\begin{longtable}{<%= colspec_string %>}
 | 
				
			||||||
<%- if table.caption -%>
 | 
					<%- if table.caption -%>
 | 
				
			||||||
\sphinxthelongtablecaptionisattop
 | 
					\sphinxthelongtablecaptionisattop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
 | 
					\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
 | 
				
			||||||
<% elif labels -%>
 | 
					<% elif labels -%>
 | 
				
			||||||
\noalign{\phantomsection<%= labels %>}%
 | 
					\noalign{\phantomsection<%= labels %>}%
 | 
				
			||||||
@ -76,7 +94,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
\endlastfoot
 | 
					\endlastfoot
 | 
				
			||||||
\sphinxtableatstartofbodyhook
 | 
					\sphinxtableatstartofbodyhook
 | 
				
			||||||
\raggedright
 | 
					 | 
				
			||||||
<%= ''.join(table.body) -%>
 | 
					<%= ''.join(table.body) -%>
 | 
				
			||||||
\sphinxbottomrule
 | 
					\sphinxbottomrule
 | 
				
			||||||
\end{longtable}
 | 
					\end{longtable}
 | 
				
			||||||
 | 
				
			|||||||
@ -39,14 +39,32 @@
 | 
				
			|||||||
\makeatother
 | 
					\makeatother
 | 
				
			||||||
<% set total_width = table.colwidths|sum %>
 | 
					<% set total_width = table.colwidths|sum %>
 | 
				
			||||||
<% set colspec_parts = [] %>
 | 
					<% set colspec_parts = [] %>
 | 
				
			||||||
 | 
					<% set min_widths = [] %>
 | 
				
			||||||
<% for width in table.colwidths %>
 | 
					<% for width in table.colwidths %>
 | 
				
			||||||
  <% set part = '>{{\\raggedright\\arraybackslash}}p{{{:.4f}\\textwidth}}'.format((width * 0.92) / total_width) %>
 | 
					  <% 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) %>
 | 
					  <% set colspec_parts = colspec_parts.append(part) %>
 | 
				
			||||||
<% endfor  %>
 | 
					<% endfor  %>
 | 
				
			||||||
<% set colspec_string = ''.join(colspec_parts) %>
 | 
					<% set colspec_string = ''.join(colspec_parts) %>
 | 
				
			||||||
\begin{longtable}{<%= colspec_string %>}
 | 
					\begin{longtable}{<%= colspec_string %>}
 | 
				
			||||||
<%- if table.caption -%>
 | 
					<%- if table.caption -%>
 | 
				
			||||||
\sphinxthelongtablecaptionisattop
 | 
					\sphinxthelongtablecaptionisattop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
 | 
					\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
 | 
				
			||||||
<% elif labels -%>
 | 
					<% elif labels -%>
 | 
				
			||||||
\noalign{\phantomsection<%= labels %>}%
 | 
					\noalign{\phantomsection<%= labels %>}%
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user