From 9a18cf4b591364e7f0dc9b976628e91f8b31a6cf Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 2 Jan 2021 07:56:07 -0800 Subject: LaTeX writer: revert table line height increase in 2.11.3. In 2.11.3 we started adding `\addlinespace`, which produced less dense tables. This wasn't an intentional change; I misunderstood a comment in the discussion leading up to the change. This commit restores the earlier default table appearance. Note that if you want a less dense table, you can use something like `\def\arraystretch{1.5}` in your header. Closes #6996. --- src/Text/Pandoc/Writers/LaTeX/Table.hs | 2 +- test/command/2378.md | 6 ++-- test/command/5367.md | 6 ++-- test/tables.latex | 61 +++++++++++++++------------------- test/tables/nordics.latex | 18 +++++----- test/tables/planets.latex | 28 ++++++---------- test/tables/students.latex | 22 ++++++------ 7 files changed, 63 insertions(+), 80 deletions(-) diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs index 9dd66c8a3..8411d9f80 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Table.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs @@ -169,7 +169,7 @@ rowToLaTeX :: PandocMonad m -> LW m (Doc Text) rowToLaTeX blocksWriter celltype row = do cellsDocs <- mapM (cellToLaTeX blocksWriter celltype) (fillRow row) - return $ hsep (intersperse "&" cellsDocs) <> " \\\\ \\addlinespace" + return $ hsep (intersperse "&" cellsDocs) <> " \\\\" -- | Pads row with empty cells to adjust for rowspans above this row. fillRow :: [Ann.Cell] -> [Ann.Cell] diff --git a/test/command/2378.md b/test/command/2378.md index e81855367..59359c653 100644 --- a/test/command/2378.md +++ b/test/command/2378.md @@ -14,14 +14,14 @@ is used. \begin{longtable}[]{@{}ll@{}} \caption{a table}\tabularnewline \toprule -x & y\footnote{a footnote} \\ \addlinespace +x & y\footnote{a footnote} \\ \midrule \endfirsthead \toprule -x & y{} \\ \addlinespace +x & y{} \\ \midrule \endhead -1 & 2 \\ \addlinespace +1 & 2 \\ \bottomrule \end{longtable} ``` diff --git a/test/command/5367.md b/test/command/5367.md index 4dbcca771..2d3a5e52e 100644 --- a/test/command/5367.md +++ b/test/command/5367.md @@ -24,14 +24,14 @@ hello\footnote{doc footnote} >{\centering\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{0.17}}@{}} \caption[Sample table.]{Sample table.\footnote{caption footnote}}\tabularnewline \toprule -Fruit\footnote{header footnote} \\ \addlinespace +Fruit\footnote{header footnote} \\ \midrule \endfirsthead \toprule -Fruit{} \\ \addlinespace +Fruit{} \\ \midrule \endhead -Bans\footnote{table cell footnote} \\ \addlinespace +Bans\footnote{table cell footnote} \\ \bottomrule \end{longtable} diff --git a/test/tables.latex b/test/tables.latex index 38c571ba6..afa14d845 100644 --- a/test/tables.latex +++ b/test/tables.latex @@ -3,16 +3,16 @@ Simple table with caption: \begin{longtable}[]{@{}rlcl@{}} \caption{Demonstration of simple table syntax.}\tabularnewline \toprule -Right & Left & Center & Default \\ \addlinespace +Right & Left & Center & Default \\ \midrule \endfirsthead \toprule -Right & Left & Center & Default \\ \addlinespace +Right & Left & Center & Default \\ \midrule \endhead -12 & 12 & 12 & 12 \\ \addlinespace -123 & 123 & 123 & 123 \\ \addlinespace -1 & 1 & 1 & 1 \\ \addlinespace +12 & 12 & 12 & 12 \\ +123 & 123 & 123 & 123 \\ +1 & 1 & 1 & 1 \\ \bottomrule \end{longtable} @@ -20,12 +20,12 @@ Simple table without caption: \begin{longtable}[]{@{}rlcl@{}} \toprule -Right & Left & Center & Default \\ \addlinespace +Right & Left & Center & Default \\ \midrule \endhead -12 & 12 & 12 & 12 \\ \addlinespace -123 & 123 & 123 & 123 \\ \addlinespace -1 & 1 & 1 & 1 \\ \addlinespace +12 & 12 & 12 & 12 \\ +123 & 123 & 123 & 123 \\ +1 & 1 & 1 & 1 \\ \bottomrule \end{longtable} @@ -34,16 +34,16 @@ Simple table indented two spaces: \begin{longtable}[]{@{}rlcl@{}} \caption{Demonstration of simple table syntax.}\tabularnewline \toprule -Right & Left & Center & Default \\ \addlinespace +Right & Left & Center & Default \\ \midrule \endfirsthead \toprule -Right & Left & Center & Default \\ \addlinespace +Right & Left & Center & Default \\ \midrule \endhead -12 & 12 & 12 & 12 \\ \addlinespace -123 & 123 & 123 & 123 \\ \addlinespace -1 & 1 & 1 & 1 \\ \addlinespace +12 & 12 & 12 & 12 \\ +123 & 123 & 123 & 123 \\ +1 & 1 & 1 & 1 \\ \bottomrule \end{longtable} @@ -56,19 +56,15 @@ Multiline table with caption: >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.35}}@{}} \caption{Here's the caption. It may span multiple lines.}\tabularnewline \toprule -Centered Header & Left Aligned & Right Aligned & Default -aligned \\ \addlinespace +Centered Header & Left Aligned & Right Aligned & Default aligned \\ \midrule \endfirsthead \toprule -Centered Header & Left Aligned & Right Aligned & Default -aligned \\ \addlinespace +Centered Header & Left Aligned & Right Aligned & Default aligned \\ \midrule \endhead -First & row & 12.0 & Example of a row that spans multiple -lines. \\ \addlinespace -Second & row & 5.0 & Here's another one. Note the blank line between -rows. \\ \addlinespace +First & row & 12.0 & Example of a row that spans multiple lines. \\ +Second & row & 5.0 & Here's another one. Note the blank line between rows. \\ \bottomrule \end{longtable} @@ -80,14 +76,11 @@ Multiline table without caption: >{\raggedleft\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.16}} >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.35}}@{}} \toprule -Centered Header & Left Aligned & Right Aligned & Default -aligned \\ \addlinespace +Centered Header & Left Aligned & Right Aligned & Default aligned \\ \midrule \endhead -First & row & 12.0 & Example of a row that spans multiple -lines. \\ \addlinespace -Second & row & 5.0 & Here's another one. Note the blank line between -rows. \\ \addlinespace +First & row & 12.0 & Example of a row that spans multiple lines. \\ +Second & row & 5.0 & Here's another one. Note the blank line between rows. \\ \bottomrule \end{longtable} @@ -96,9 +89,9 @@ Table without column headers: \begin{longtable}[]{@{}rlcr@{}} \toprule \endhead -12 & 12 & 12 & 12 \\ \addlinespace -123 & 123 & 123 & 123 \\ \addlinespace -1 & 1 & 1 & 1 \\ \addlinespace +12 & 12 & 12 & 12 \\ +123 & 123 & 123 & 123 \\ +1 & 1 & 1 & 1 \\ \bottomrule \end{longtable} @@ -111,9 +104,7 @@ Multiline table without column headers: >{\raggedright\arraybackslash}p{(\columnwidth - 6\tabcolsep) * \real{0.35}}@{}} \toprule \endhead -First & row & 12.0 & Example of a row that spans multiple -lines. \\ \addlinespace -Second & row & 5.0 & Here's another one. Note the blank line between -rows. \\ \addlinespace +First & row & 12.0 & Example of a row that spans multiple lines. \\ +Second & row & 5.0 & Here's another one. Note the blank line between rows. \\ \bottomrule \end{longtable} diff --git a/test/tables/nordics.latex b/test/tables/nordics.latex index d1a0b4aed..1b5929bad 100644 --- a/test/tables/nordics.latex +++ b/test/tables/nordics.latex @@ -6,21 +6,19 @@ \caption{States belonging to the \emph{Nordics.}}\tabularnewline \toprule Name & Capital & \vtop{\hbox{\strut Population}\hbox{\strut (in 2018)}} & -\vtop{\hbox{\strut Area}\hbox{\strut (in -km\textsuperscript{2})}} \\ \addlinespace +\vtop{\hbox{\strut Area}\hbox{\strut (in km\textsuperscript{2})}} \\ \midrule \endfirsthead \toprule Name & Capital & \vtop{\hbox{\strut Population}\hbox{\strut (in 2018)}} & -\vtop{\hbox{\strut Area}\hbox{\strut (in -km\textsuperscript{2})}} \\ \addlinespace +\vtop{\hbox{\strut Area}\hbox{\strut (in km\textsuperscript{2})}} \\ \midrule \endhead -Denmark & Copenhagen & 5,809,502 & 43,094 \\ \addlinespace -Finland & Helsinki & 5,537,364 & 338,145 \\ \addlinespace -Iceland & Reykjavik & 343,518 & 103,000 \\ \addlinespace -Norway & Oslo & 5,372,191 & 323,802 \\ \addlinespace -Sweden & Stockholm & 10,313,447 & 450,295 \\ \addlinespace -Total & & 27,376,022 & 1,258,336 \\ \addlinespace +Denmark & Copenhagen & 5,809,502 & 43,094 \\ +Finland & Helsinki & 5,537,364 & 338,145 \\ +Iceland & Reykjavik & 343,518 & 103,000 \\ +Norway & Oslo & 5,372,191 & 323,802 \\ +Sweden & Stockholm & 10,313,447 & 450,295 \\ +Total & & 27,376,022 & 1,258,336 \\ \bottomrule \end{longtable} diff --git a/test/tables/planets.latex b/test/tables/planets.latex index 9457b6821..8238c43f3 100644 --- a/test/tables/planets.latex +++ b/test/tables/planets.latex @@ -3,34 +3,28 @@ \toprule \multicolumn{2}{l}{} & Name & Mass (10\^{}24kg) & Diameter (km) & Density (kg/m\^{}3) & Gravity (m/s\^{}2) & Length of day (hours) & Distance from Sun -(10\^{}6km) & Mean temperature (C) & Number of moons & Notes \\ \addlinespace +(10\^{}6km) & Mean temperature (C) & Number of moons & Notes \\ \midrule \endfirsthead \toprule \multicolumn{2}{l}{} & Name & Mass (10\^{}24kg) & Diameter (km) & Density (kg/m\^{}3) & Gravity (m/s\^{}2) & Length of day (hours) & Distance from Sun -(10\^{}6km) & Mean temperature (C) & Number of moons & Notes \\ \addlinespace +(10\^{}6km) & Mean temperature (C) & Number of moons & Notes \\ \midrule \endhead \multicolumn{2}{l}{\multirow{4}{*}{Terrestrial planets}} & Mercury & 0.330 & -4,879 & 5427 & 3.7 & 4222.6 & 57.9 & 167 & 0 & Closest to the -Sun \\ \addlinespace -& & Venus & 4.87 & 12,104 & 5243 & 8.9 & 2802.0 & 108.2 & 464 & 0 -& \\ \addlinespace -& & Earth & 5.97 & 12,756 & 5514 & 9.8 & 24.0 & 149.6 & 15 & 1 & Our -world \\ \addlinespace +4,879 & 5427 & 3.7 & 4222.6 & 57.9 & 167 & 0 & Closest to the Sun \\ +& & Venus & 4.87 & 12,104 & 5243 & 8.9 & 2802.0 & 108.2 & 464 & 0 & \\ +& & Earth & 5.97 & 12,756 & 5514 & 9.8 & 24.0 & 149.6 & 15 & 1 & Our world \\ & & Mars & 0.642 & 6,792 & 3933 & 3.7 & 24.7 & 227.9 & -65 & 2 & The red -planet \\ \addlinespace +planet \\ \multirow{4}{*}{Jovian planets} & \multirow{2}{*}{Gas giants} & Jupiter & 1898 -& 142,984 & 1326 & 23.1 & 9.9 & 778.6 & -110 & 67 & The largest -planet \\ \addlinespace -& & Saturn & 568 & 120,536 & 687 & 9.0 & 10.7 & 1433.5 & -140 & 62 -& \\ \addlinespace +& 142,984 & 1326 & 23.1 & 9.9 & 778.6 & -110 & 67 & The largest planet \\ +& & Saturn & 568 & 120,536 & 687 & 9.0 & 10.7 & 1433.5 & -140 & 62 & \\ & \multirow{2}{*}{Ice giants} & Uranus & 86.8 & 51,118 & 1271 & 8.7 & 17.2 & -2872.5 & -195 & 27 & \\ \addlinespace -& & Neptune & 102 & 49,528 & 1638 & 11.0 & 16.1 & 4495.1 & -200 & 14 -& \\ \addlinespace +2872.5 & -195 & 27 & \\ +& & Neptune & 102 & 49,528 & 1638 & 11.0 & 16.1 & 4495.1 & -200 & 14 & \\ \multicolumn{2}{l}{Dwarf planets} & Pluto & 0.0146 & 2,370 & 2095 & 0.7 & -153.3 & 5906.4 & -225 & 5 & Declassified as a planet in 2006. \\ \addlinespace +153.3 & 5906.4 & -225 & 5 & Declassified as a planet in 2006. \\ \bottomrule \end{longtable} diff --git a/test/tables/students.latex b/test/tables/students.latex index 680a539d3..87efb0851 100644 --- a/test/tables/students.latex +++ b/test/tables/students.latex @@ -3,21 +3,21 @@ >{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.50}}@{}} \caption{List of Students}\tabularnewline \toprule -Student ID & Name \\ \addlinespace +Student ID & Name \\ \midrule \endfirsthead \toprule -Student ID & Name \\ \addlinespace +Student ID & Name \\ \midrule \endhead -\multicolumn{2}{l}{Computer Science} \\ \addlinespace -3741255 & Jones, Martha \\ \addlinespace -4077830 & Pierce, Benjamin \\ \addlinespace -5151701 & Kirk, James \\ \addlinespace -\multicolumn{2}{l}{Russian Literature} \\ \addlinespace -3971244 & Nim, Victor \\ \addlinespace -\multicolumn{2}{l}{Astrophysics} \\ \addlinespace -4100332 & Petrov, Alexandra \\ \addlinespace -4100332 & Toyota, Hiroko \\ \addlinespace +\multicolumn{2}{l}{Computer Science} \\ +3741255 & Jones, Martha \\ +4077830 & Pierce, Benjamin \\ +5151701 & Kirk, James \\ +\multicolumn{2}{l}{Russian Literature} \\ +3971244 & Nim, Victor \\ +\multicolumn{2}{l}{Astrophysics} \\ +4100332 & Petrov, Alexandra \\ +4100332 & Toyota, Hiroko \\ \bottomrule \end{longtable} -- cgit v1.2.3