aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-01-04 13:57:41 -0800
committerJohn MacFarlane <[email protected]>2023-01-04 13:57:41 -0800
commit7a82686adcf6efd68b32c5e471b3059be5085165 (patch)
tree19419f47079b351a1f57ae03485452f2fd5987a3
parentc4995fea41c305d94fc929fc1aca165bf6d592d6 (diff)
Use `\toprule\noalign{}` instead of `\toprule()` in LaTeX tables.
And similar for `\midrule` and `\bottomrule`. This facilitates redefining `\toprule`, `\midrule`, and `\bottomrule` without needing to gobble the ()s. Closes #8223.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX/Table.hs10
-rw-r--r--test/command/2378.md10
-rw-r--r--test/command/5367.md10
-rw-r--r--test/command/7272.md4
-rw-r--r--test/command/8219.md4
-rw-r--r--test/tables.latex50
-rw-r--r--test/tables/nordics.latex12
-rw-r--r--test/tables/planets.latex10
-rw-r--r--test/tables/students.latex10
9 files changed, 60 insertions, 60 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Table.hs b/src/Text/Pandoc/Writers/LaTeX/Table.hs
index 72c20b66e..fe4d0cd75 100644
--- a/src/Text/Pandoc/Writers/LaTeX/Table.hs
+++ b/src/Text/Pandoc/Writers/LaTeX/Table.hs
@@ -58,9 +58,9 @@ tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do
head' <- do
let mkHead = headToLaTeX blksToLaTeX colCount
case (not $ isEmpty capt, not $ isEmptyHead thead) of
- (False, False) -> return "\\toprule()"
+ (False, False) -> return "\\toprule\\noalign{}"
(False, True) -> mkHead thead
- (True, False) -> return (capt $$ "\\toprule()" $$ "\\endfirsthead")
+ (True, False) -> return (capt $$ "\\toprule\\noalign{}" $$ "\\endfirsthead")
(True, True) -> do
-- avoid duplicate notes in head and firsthead:
firsthead <- mkHead thead
@@ -73,7 +73,7 @@ tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do
else do
lastfoot <- mapM (rowToLaTeX blksToLaTeX colCount BodyCell) $
footRows tfoot
- pure $ "\\midrule()" $$ vcat lastfoot
+ pure $ "\\midrule\\noalign{}" $$ vcat lastfoot
modify $ \s -> s{ stTable = True }
notes <- notesToLaTeX <$> gets stNotes
return
@@ -83,7 +83,7 @@ tableToLaTeX inlnsToLaTeX blksToLaTeX tbl = do
$$ head'
$$ "\\endhead"
$$ foot'
- $$ "\\bottomrule()"
+ $$ "\\bottomrule\\noalign{}"
$$ "\\endlastfoot"
$$ vcat rows'
$$ "\\end{longtable}"
@@ -184,7 +184,7 @@ headToLaTeX blocksWriter colCount (Ann.TableHead _attr headerRows) = do
rowsContents <-
mapM (rowToLaTeX blocksWriter colCount HeaderCell . headerRowCells)
headerRows
- return ("\\toprule()" $$ vcat rowsContents $$ "\\midrule()")
+ return ("\\toprule\\noalign{}" $$ vcat rowsContents $$ "\\midrule\\noalign{}")
-- | Converts a row of table cells into a LaTeX row.
rowToLaTeX :: PandocMonad m
diff --git a/test/command/2378.md b/test/command/2378.md
index 6c4e81bd2..2944df09d 100644
--- a/test/command/2378.md
+++ b/test/command/2378.md
@@ -13,15 +13,15 @@ is used.
^D
\begin{longtable}[]{@{}ll@{}}
\caption{a table}\tabularnewline
-\toprule()
+\toprule\noalign{}
x & y\footnote{a footnote} \\
-\midrule()
+\midrule\noalign{}
\endfirsthead
-\toprule()
+\toprule\noalign{}
x & y{} \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
1 & 2 \\
\end{longtable}
diff --git a/test/command/5367.md b/test/command/5367.md
index 1ee7ce749..205ccf098 100644
--- a/test/command/5367.md
+++ b/test/command/5367.md
@@ -23,19 +23,19 @@ hello\footnote{doc footnote}
\begin{longtable}[]{@{}
>{\centering\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{0.1667}}@{}}
\caption[Sample table.]{Sample table.\footnote{caption footnote}}\tabularnewline
-\toprule()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Fruit\footnote{header footnote}
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endfirsthead
-\toprule()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Fruit{}
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
Bans\footnote{table cell footnote} \\
\end{longtable}
diff --git a/test/command/7272.md b/test/command/7272.md
index 56cd1c3bc..ea11b6f9d 100644
--- a/test/command/7272.md
+++ b/test/command/7272.md
@@ -16,9 +16,9 @@
^D
\begin{longtable}[]{@{}
>{\raggedright\arraybackslash}p{(\columnwidth - 0\tabcolsep) * \real{1.0000}}@{}}
-\toprule()
+\toprule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
\begin{minipage}[t]{\linewidth}\raggedright
{ text\\
diff --git a/test/command/8219.md b/test/command/8219.md
index 0d1ed8b1d..57617e522 100644
--- a/test/command/8219.md
+++ b/test/command/8219.md
@@ -6,10 +6,10 @@
^D
\begin{longtable}[]{@{}ll@{}}
\caption{}\label{test}\tabularnewline
-\toprule()
+\toprule\noalign{}
\endfirsthead
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
one & two \\
\end{longtable}
diff --git a/test/tables.latex b/test/tables.latex
index 3ee3db7cc..eed12de44 100644
--- a/test/tables.latex
+++ b/test/tables.latex
@@ -2,15 +2,15 @@ Simple table with caption:
\begin{longtable}[]{@{}rlcl@{}}
\caption{Demonstration of simple table syntax.}\tabularnewline
-\toprule()
+\toprule\noalign{}
Right & Left & Center & Default \\
-\midrule()
+\midrule\noalign{}
\endfirsthead
-\toprule()
+\toprule\noalign{}
Right & Left & Center & Default \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
12 & 12 & 12 & 12 \\
123 & 123 & 123 & 123 \\
@@ -20,11 +20,11 @@ Right & Left & Center & Default \\
Simple table without caption:
\begin{longtable}[]{@{}rlcl@{}}
-\toprule()
+\toprule\noalign{}
Right & Left & Center & Default \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
12 & 12 & 12 & 12 \\
123 & 123 & 123 & 123 \\
@@ -35,15 +35,15 @@ Simple table indented two spaces:
\begin{longtable}[]{@{}rlcl@{}}
\caption{Demonstration of simple table syntax.}\tabularnewline
-\toprule()
+\toprule\noalign{}
Right & Left & Center & Default \\
-\midrule()
+\midrule\noalign{}
\endfirsthead
-\toprule()
+\toprule\noalign{}
Right & Left & Center & Default \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
12 & 12 & 12 & 12 \\
123 & 123 & 123 & 123 \\
@@ -58,7 +58,7 @@ Multiline table with caption:
>{\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()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Centered Header
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
@@ -68,9 +68,9 @@ Right Aligned
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
Default aligned
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endfirsthead
-\toprule()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Centered Header
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
@@ -80,9 +80,9 @@ Right Aligned
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
Default aligned
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
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. \\
@@ -95,7 +95,7 @@ Multiline table without caption:
>{\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()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Centered Header
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
@@ -105,9 +105,9 @@ Right Aligned
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
Default aligned
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
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. \\
@@ -116,9 +116,9 @@ Second & row & 5.0 & Here's another one. Note the blank line between rows. \\
Table without column headers:
\begin{longtable}[]{@{}rlcr@{}}
-\toprule()
+\toprule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
12 & 12 & 12 & 12 \\
123 & 123 & 123 & 123 \\
@@ -132,9 +132,9 @@ Multiline table without column headers:
>{\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()
+\toprule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
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. \\
diff --git a/test/tables/nordics.latex b/test/tables/nordics.latex
index b40e97c54..4cb0944fd 100644
--- a/test/tables/nordics.latex
+++ b/test/tables/nordics.latex
@@ -4,7 +4,7 @@
>{\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.}}\label{nordics}\tabularnewline
-\toprule()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Name
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
@@ -16,9 +16,9 @@ Population\\
Area\\
(in km\textsuperscript{2})\strut
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endfirsthead
-\toprule()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Name
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
@@ -30,11 +30,11 @@ Population\\
Area\\
(in km\textsuperscript{2})\strut
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endhead
-\midrule()
+\midrule\noalign{}
Total & & 27,376,022 & 1,258,336 \\
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
Denmark & Copenhagen & 5,809,502 & 43,094 \\
Finland & Helsinki & 5,537,364 & 338,145 \\
diff --git a/test/tables/planets.latex b/test/tables/planets.latex
index d8b9f5ae8..ac7b7d911 100644
--- a/test/tables/planets.latex
+++ b/test/tables/planets.latex
@@ -1,20 +1,20 @@
\begin{longtable}[]{@{}cclrrrrrrrrl@{}}
\caption{Data about the planets of our solar system.}\tabularnewline
-\toprule()
+\toprule\noalign{}
\multicolumn{2}{@{}>{\centering\arraybackslash}p{(\columnwidth - 22\tabcolsep) * \real{0.0000} + 2\tabcolsep}}{%
} & 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 \\
-\midrule()
+\midrule\noalign{}
\endfirsthead
-\toprule()
+\toprule\noalign{}
\multicolumn{2}{@{}>{\centering\arraybackslash}p{(\columnwidth - 22\tabcolsep) * \real{0.0000} + 2\tabcolsep}}{%
} & 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 \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
\multicolumn{2}{@{}>{\centering\arraybackslash}p{(\columnwidth - 22\tabcolsep) * \real{0.0000} + 2\tabcolsep}}{%
\multirow{4}{*}{Terrestrial planets}} & Mercury & 0.330 & 4,879 & 5427 & 3.7 &
diff --git a/test/tables/students.latex b/test/tables/students.latex
index e216d5f63..802b00c60 100644
--- a/test/tables/students.latex
+++ b/test/tables/students.latex
@@ -2,23 +2,23 @@
>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.5000}}
>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{0.5000}}@{}}
\caption{List of Students}\label{students}\tabularnewline
-\toprule()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Student ID
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Name
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endfirsthead
-\toprule()
+\toprule\noalign{}
\begin{minipage}[b]{\linewidth}\centering
Student ID
\end{minipage} & \begin{minipage}[b]{\linewidth}\centering
Name
\end{minipage} \\
-\midrule()
+\midrule\noalign{}
\endhead
-\bottomrule()
+\bottomrule\noalign{}
\endlastfoot
\multicolumn{2}{@{}>{\raggedright\arraybackslash}p{(\columnwidth - 2\tabcolsep) * \real{1.0000} + 2\tabcolsep}@{}}{%
Computer Science} \\