git.iko.soy/typeable/pandoc
on master help sign in
Add booktabs package for LaTeX tables

[ci skip]

commitfdaeec0c48d742489ddf0ec0c0261ca9c53f989b authorJose Luis Duran <jlduran@gmail.com> dateMon 2 Dec 2013, 09:55 (13 years ago) parent1213192
4 files changed+52−52
README+1−1 data/templates+1−1 src/Text/Pandoc/Writers/LaTeX.hs+5−5 tests/tables.latex+45−45
README+1−1
@@ -108,7 +108,7 @@ to PDF:
108108Production of a PDF requires that a LaTeX engine be installed (see
109109`--latex-engine`, below), and assumes that the following LaTeX packages are
110110available: `amssymb`, `amsmath`, `ifxetex`, `ifluatex`, `listings` (if the
111−`--listings` option is used), `fancyvrb`, `longtable`, `url`,
111+`--listings` option is used), `fancyvrb`, `longtable`, `booktabs`, `url`,
112112`graphicx`, `hyperref`, `ulem`, `babel` (if the `lang` variable is set),
113113`fontspec` (if `xelatex` or `lualatex` is used as the LaTeX engine), `xltxtra`
114114and `xunicode` (if `xelatex` is used).
data/templates+1−1

Submodule changed.

src/Text/Pandoc/Writers/LaTeX.hs+5−5
@@ -453,12 +453,12 @@ blockToLaTeX (Header level (id',classes,_) lst) =
453453blockToLaTeX (Table caption aligns widths heads rows) = do
454454 headers <- if all null heads
455455 then return empty
456− else ($$ "\\hline\\noalign{\\medskip}") `fmap`
456+ else ($$ "\\midrule\\endhead") `fmap`
457457 (tableRowToLaTeX True aligns widths) heads
458458 captionText <- inlineListToLaTeX caption
459459 let capt = if isEmpty captionText
460460 then empty
461− else text "\\noalign{\\medskip}"
461+ else text "\\addlinespace"
462462 $$ text "\\caption" <> braces captionText
463463 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
464464 let colDescriptors = text $ concat $ map toColDescriptor aligns
@@ -466,10 +466,10 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
466466 return $ "\\begin{longtable}[c]" <>
467467 braces ("@{}" <> colDescriptors <> "@{}")
468468 -- the @{} removes extra space at beginning and end
469− $$ "\\hline\\noalign{\\medskip}"
469+ $$ "\\toprule\\addlinespace"
470470 $$ headers
471471 $$ vcat rows'
472− $$ "\\hline"
472+ $$ "\\bottomrule"
473473 $$ capt
474474 $$ "\\end{longtable}"
475475
@@ -506,7 +506,7 @@ tableRowToLaTeX header aligns widths cols = do
506506 (w * scaleFactor))) <>
507507 (halign a <> cr <> c <> cr) <> "\\end{minipage}"
508508 let cells = zipWith3 toCell widths aligns renderedCells
509− return $ hsep (intersperse "&" cells) $$ "\\\\\\noalign{\\medskip}"
509+ return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace"
510510
511511listItemToLaTeX :: [Block] -> State WriterState Doc
512512listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
tests/tables.latex+45−45
@@ -1,59 +1,59 @@
11Simple table with caption:
22
33\begin{longtable}[c]{@{}rlcl@{}}
4−\hline\noalign{\medskip}
4+\toprule\addlinespace
55Right & Left & Center & Default
6−\\\noalign{\medskip}
7−\hline\noalign{\medskip}
6+\\\addlinespace
7+\midrule\endhead
8812 & 12 & 12 & 12
9−\\\noalign{\medskip}
9+\\\addlinespace
1010123 & 123 & 123 & 123
11−\\\noalign{\medskip}
11+\\\addlinespace
12121 & 1 & 1 & 1
13−\\\noalign{\medskip}
14−\hline
15−\noalign{\medskip}
13+\\\addlinespace
14+\bottomrule
15+\addlinespace
1616\caption{Demonstration of simple table syntax.}
1717\end{longtable}
1818
1919Simple table without caption:
2020
2121\begin{longtable}[c]{@{}rlcl@{}}
22−\hline\noalign{\medskip}
22+\toprule\addlinespace
2323Right & Left & Center & Default
24−\\\noalign{\medskip}
25−\hline\noalign{\medskip}
24+\\\addlinespace
25+\midrule\endhead
262612 & 12 & 12 & 12
27−\\\noalign{\medskip}
27+\\\addlinespace
2828123 & 123 & 123 & 123
29−\\\noalign{\medskip}
29+\\\addlinespace
30301 & 1 & 1 & 1
31−\\\noalign{\medskip}
32−\hline
31+\\\addlinespace
32+\bottomrule
3333\end{longtable}
3434
3535Simple table indented two spaces:
3636
3737\begin{longtable}[c]{@{}rlcl@{}}
38−\hline\noalign{\medskip}
38+\toprule\addlinespace
3939Right & Left & Center & Default
40−\\\noalign{\medskip}
41−\hline\noalign{\medskip}
40+\\\addlinespace
41+\midrule\endhead
424212 & 12 & 12 & 12
43−\\\noalign{\medskip}
43+\\\addlinespace
4444123 & 123 & 123 & 123
45−\\\noalign{\medskip}
45+\\\addlinespace
46461 & 1 & 1 & 1
47−\\\noalign{\medskip}
48−\hline
49−\noalign{\medskip}
47+\\\addlinespace
48+\bottomrule
49+\addlinespace
5050\caption{Demonstration of simple table syntax.}
5151\end{longtable}
5252
5353Multiline table with caption:
5454
5555\begin{longtable}[c]{@{}clrl@{}}
56−\hline\noalign{\medskip}
56+\toprule\addlinespace
5757\begin{minipage}[b]{0.13\columnwidth}\centering
5858Centered Header
5959\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
@@ -63,8 +63,8 @@ Right Aligned
6363\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
6464Default aligned
6565\end{minipage}
66−\\\noalign{\medskip}
67−\hline\noalign{\medskip}
66+\\\addlinespace
67+\midrule\endhead
6868\begin{minipage}[t]{0.13\columnwidth}\centering
6969First
7070\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -74,7 +74,7 @@ row
7474\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
7575Example of a row that spans multiple lines.
7676\end{minipage}
77−\\\noalign{\medskip}
77+\\\addlinespace
7878\begin{minipage}[t]{0.13\columnwidth}\centering
7979Second
8080\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -84,16 +84,16 @@ row
8484\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
8585Here's another one. Note the blank line between rows.
8686\end{minipage}
87−\\\noalign{\medskip}
88−\hline
89−\noalign{\medskip}
87+\\\addlinespace
88+\bottomrule
89+\addlinespace
9090\caption{Here's the caption. It may span multiple lines.}
9191\end{longtable}
9292
9393Multiline table without caption:
9494
9595\begin{longtable}[c]{@{}clrl@{}}
96−\hline\noalign{\medskip}
96+\toprule\addlinespace
9797\begin{minipage}[b]{0.13\columnwidth}\centering
9898Centered Header
9999\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
@@ -103,8 +103,8 @@ Right Aligned
103103\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
104104Default aligned
105105\end{minipage}
106−\\\noalign{\medskip}
107−\hline\noalign{\medskip}
106+\\\addlinespace
107+\midrule\endhead
108108\begin{minipage}[t]{0.13\columnwidth}\centering
109109First
110110\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -114,7 +114,7 @@ row
114114\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
115115Example of a row that spans multiple lines.
116116\end{minipage}
117−\\\noalign{\medskip}
117+\\\addlinespace
118118\begin{minipage}[t]{0.13\columnwidth}\centering
119119Second
120120\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -124,27 +124,27 @@ row
124124\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
125125Here's another one. Note the blank line between rows.
126126\end{minipage}
127−\\\noalign{\medskip}
128−\hline
127+\\\addlinespace
128+\bottomrule
129129\end{longtable}
130130
131131Table without column headers:
132132
133133\begin{longtable}[c]{@{}rlcr@{}}
134−\hline\noalign{\medskip}
134+\toprule\addlinespace
13513512 & 12 & 12 & 12
136−\\\noalign{\medskip}
136+\\\addlinespace
137137123 & 123 & 123 & 123
138−\\\noalign{\medskip}
138+\\\addlinespace
1391391 & 1 & 1 & 1
140−\\\noalign{\medskip}
141−\hline
140+\\\addlinespace
141+\bottomrule
142142\end{longtable}
143143
144144Multiline table without column headers:
145145
146146\begin{longtable}[c]{@{}clrl@{}}
147−\hline\noalign{\medskip}
147+\toprule\addlinespace
148148\begin{minipage}[t]{0.13\columnwidth}\centering
149149First
150150\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -154,7 +154,7 @@ row
154154\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
155155Example of a row that spans multiple lines.
156156\end{minipage}
157−\\\noalign{\medskip}
157+\\\addlinespace
158158\begin{minipage}[t]{0.13\columnwidth}\centering
159159Second
160160\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -164,6 +164,6 @@ row
164164\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
165165Here's another one. Note the blank line between rows.
166166\end{minipage}
167−\\\noalign{\medskip}
168−\hline
167+\\\addlinespace
168+\bottomrule
169169\end{longtable}