LaTeX table writer: Increase column width precision (#7466)

In some cases, the rounding performed by the LaTeX table
writer would introduce visible overrun outside the text
area.
This adds two more decimal places to the width values.
This commit is contained in:
Peter Fabinski 2021-08-03 17:34:39 -04:00 committed by GitHub
parent f938378d00
commit 8667ba2bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 21 deletions

View file

@ -102,7 +102,7 @@ colDescriptors (Ann.Table _attr _caption specs thead tbodies tfoot) =
toColDescriptor :: Int -> Alignment -> Double -> Text
toColDescriptor numcols align width =
T.pack $ printf
">{%s\\arraybackslash}p{(\\columnwidth - %d\\tabcolsep) * \\real{%0.2f}}"
">{%s\\arraybackslash}p{(\\columnwidth - %d\\tabcolsep) * \\real{%0.4f}}"
(T.unpack (alignCommand align))
((numcols - 1) * 2)
width

View file

@ -21,7 +21,7 @@ dolly[^5]
hello\footnote{doc footnote}
\begin{longtable}[]{@{}
>{\centering\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{0.17}}@{}}
>{\centering\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{0.1667}}@{}}
\caption[Sample table.]{Sample table.\footnote{caption footnote}}\tabularnewline
\toprule
\begin{minipage}[b]{\linewidth}\centering

View file

@ -15,7 +15,7 @@
</table>
^D
\begin{longtable}[]{@{}
>{\raggedright\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{1.00}}@{}}
>{\raggedright\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{1.0000}}@{}}
\toprule
\endhead
\begin{minipage}[t]{\linewidth}\raggedright

View file

@ -50,10 +50,10 @@ Right & Left & Center & Default \\
Multiline table with caption:
\begin{longtable}[]{@{}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.15}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.14}}
>{\raggedleft\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.16}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.35}}@{}}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1500}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1375}}
>{\raggedleft\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1625}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.3500}}@{}}
\caption{Here's the caption. It may span multiple lines.}\tabularnewline
\toprule
\begin{minipage}[b]{\linewidth}\centering
@ -87,10 +87,10 @@ Second & row & 5.0 & Here's another one. Note the blank line between rows. \\
Multiline table without caption:
\begin{longtable}[]{@{}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.15}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.14}}
>{\raggedleft\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.16}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.35}}@{}}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1500}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1375}}
>{\raggedleft\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1625}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.3500}}@{}}
\toprule
\begin{minipage}[b]{\linewidth}\centering
Centered Header
@ -122,10 +122,10 @@ Table without column headers:
Multiline table without column headers:
\begin{longtable}[]{@{}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.15}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.14}}
>{\raggedleft\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.16}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.35}}@{}}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1500}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1375}}
>{\raggedleft\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.1625}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.3500}}@{}}
\toprule
\endhead
First & row & 12.0 & Example of a row that spans multiple lines. \\

View file

@ -1,8 +1,8 @@
\begin{longtable}[]{@{}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.30}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.30}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.20}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.20}}@{}}
>{\centering\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.3000}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.3000}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.2000}}
>{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.2000}}@{}}
\caption{States belonging to the \emph{Nordics.}}\tabularnewline
\toprule
\begin{minipage}[b]{\linewidth}\centering

View file

@ -1,6 +1,6 @@
\begin{longtable}[]{@{}
>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.50}}
>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.50}}@{}}
>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.5000}}
>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.5000}}@{}}
\caption{List of Students}\tabularnewline
\toprule
\begin{minipage}[b]{\linewidth}\centering