git.iko.soy/typeable/pandoc
on master help sign in
Add booktabs package for LaTeX tables
fdaeec0Jose Luis Duran
README+1−1
@@ -108,7 +108,7 @@ to PDF:
108Production of a PDF requires that a LaTeX engine be installed (see
108Production of a PDF requires that a LaTeX engine be installed (see
109`--latex-engine`, below), and assumes that the following LaTeX packages are
109`--latex-engine`, below), and assumes that the following LaTeX packages are
110available: `amssymb`, `amsmath`, `ifxetex`, `ifluatex`, `listings` (if the
110available: `amssymb`, `amsmath`, `ifxetex`, `ifluatex`, `listings` (if the
111−`--listings` option is used), `fancyvrb`, `longtable`, `url`,
111+`--listings` option is used), `fancyvrb`, `longtable`, `booktabs`, `url`,
112`graphicx`, `hyperref`, `ulem`, `babel` (if the `lang` variable is set),
112`graphicx`, `hyperref`, `ulem`, `babel` (if the `lang` variable is set),
113`fontspec` (if `xelatex` or `lualatex` is used as the LaTeX engine), `xltxtra`
113`fontspec` (if `xelatex` or `lualatex` is used as the LaTeX engine), `xltxtra`
114and `xunicode` (if `xelatex` is used).
114and `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) =
453blockToLaTeX (Table caption aligns widths heads rows) = do
453blockToLaTeX (Table caption aligns widths heads rows) = do
454 headers <- if all null heads
454 headers <- if all null heads
455 then return empty
455 then return empty
456− else ($$ "\\hline\\noalign{\\medskip}") `fmap`
456+ else ($$ "\\midrule\\endhead") `fmap`
457 (tableRowToLaTeX True aligns widths) heads
457 (tableRowToLaTeX True aligns widths) heads
458 captionText <- inlineListToLaTeX caption
458 captionText <- inlineListToLaTeX caption
459 let capt = if isEmpty captionText
459 let capt = if isEmpty captionText
460 then empty
460 then empty
461− else text "\\noalign{\\medskip}"
461+ else text "\\addlinespace"
462 $$ text "\\caption" <> braces captionText
462 $$ text "\\caption" <> braces captionText
463 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
463 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
464 let colDescriptors = text $ concat $ map toColDescriptor aligns
464 let colDescriptors = text $ concat $ map toColDescriptor aligns
@@ -466,10 +466,10 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
466 return $ "\\begin{longtable}[c]" <>
466 return $ "\\begin{longtable}[c]" <>
467 braces ("@{}" <> colDescriptors <> "@{}")
467 braces ("@{}" <> colDescriptors <> "@{}")
468 -- the @{} removes extra space at beginning and end
468 -- the @{} removes extra space at beginning and end
469− $$ "\\hline\\noalign{\\medskip}"
469+ $$ "\\toprule\\addlinespace"
470 $$ headers
470 $$ headers
471 $$ vcat rows'
471 $$ vcat rows'
472− $$ "\\hline"
472+ $$ "\\bottomrule"
473 $$ capt
473 $$ capt
474 $$ "\\end{longtable}"
474 $$ "\\end{longtable}"
475
475
@@ -506,7 +506,7 @@ tableRowToLaTeX header aligns widths cols = do
506 (w * scaleFactor))) <>
506 (w * scaleFactor))) <>
507 (halign a <> cr <> c <> cr) <> "\\end{minipage}"
507 (halign a <> cr <> c <> cr) <> "\\end{minipage}"
508 let cells = zipWith3 toCell widths aligns renderedCells
508 let cells = zipWith3 toCell widths aligns renderedCells
509− return $ hsep (intersperse "&" cells) $$ "\\\\\\noalign{\\medskip}"
509+ return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace"
510
510
511listItemToLaTeX :: [Block] -> State WriterState Doc
511listItemToLaTeX :: [Block] -> State WriterState Doc
512listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
512listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
tests/tables.latex+45−45
@@ -1,59 +1,59 @@
1Simple table with caption:
1Simple table with caption:
2
2
3\begin{longtable}[c]{@{}rlcl@{}}
3\begin{longtable}[c]{@{}rlcl@{}}
4−\hline\noalign{\medskip}
4+\toprule\addlinespace
5Right & Left & Center & Default
5Right & Left & Center & Default
6−\\\noalign{\medskip}
6+\\\addlinespace
7−\hline\noalign{\medskip}
7+\midrule\endhead
812 & 12 & 12 & 12
812 & 12 & 12 & 12
9−\\\noalign{\medskip}
9+\\\addlinespace
10123 & 123 & 123 & 123
10123 & 123 & 123 & 123
11−\\\noalign{\medskip}
11+\\\addlinespace
121 & 1 & 1 & 1
121 & 1 & 1 & 1
13−\\\noalign{\medskip}
13+\\\addlinespace
14−\hline
14+\bottomrule
15−\noalign{\medskip}
15+\addlinespace
16\caption{Demonstration of simple table syntax.}
16\caption{Demonstration of simple table syntax.}
17\end{longtable}
17\end{longtable}
18
18
19Simple table without caption:
19Simple table without caption:
20
20
21\begin{longtable}[c]{@{}rlcl@{}}
21\begin{longtable}[c]{@{}rlcl@{}}
22−\hline\noalign{\medskip}
22+\toprule\addlinespace
23Right & Left & Center & Default
23Right & Left & Center & Default
24−\\\noalign{\medskip}
24+\\\addlinespace
25−\hline\noalign{\medskip}
25+\midrule\endhead
2612 & 12 & 12 & 12
2612 & 12 & 12 & 12
27−\\\noalign{\medskip}
27+\\\addlinespace
28123 & 123 & 123 & 123
28123 & 123 & 123 & 123
29−\\\noalign{\medskip}
29+\\\addlinespace
301 & 1 & 1 & 1
301 & 1 & 1 & 1
31−\\\noalign{\medskip}
31+\\\addlinespace
32−\hline
32+\bottomrule
33\end{longtable}
33\end{longtable}
34
34
35Simple table indented two spaces:
35Simple table indented two spaces:
36
36
37\begin{longtable}[c]{@{}rlcl@{}}
37\begin{longtable}[c]{@{}rlcl@{}}
38−\hline\noalign{\medskip}
38+\toprule\addlinespace
39Right & Left & Center & Default
39Right & Left & Center & Default
40−\\\noalign{\medskip}
40+\\\addlinespace
41−\hline\noalign{\medskip}
41+\midrule\endhead
4212 & 12 & 12 & 12
4212 & 12 & 12 & 12
43−\\\noalign{\medskip}
43+\\\addlinespace
44123 & 123 & 123 & 123
44123 & 123 & 123 & 123
45−\\\noalign{\medskip}
45+\\\addlinespace
461 & 1 & 1 & 1
461 & 1 & 1 & 1
47−\\\noalign{\medskip}
47+\\\addlinespace
48−\hline
48+\bottomrule
49−\noalign{\medskip}
49+\addlinespace
50\caption{Demonstration of simple table syntax.}
50\caption{Demonstration of simple table syntax.}
51\end{longtable}
51\end{longtable}
52
52
53Multiline table with caption:
53Multiline table with caption:
54
54
55\begin{longtable}[c]{@{}clrl@{}}
55\begin{longtable}[c]{@{}clrl@{}}
56−\hline\noalign{\medskip}
56+\toprule\addlinespace
57\begin{minipage}[b]{0.13\columnwidth}\centering
57\begin{minipage}[b]{0.13\columnwidth}\centering
58Centered Header
58Centered Header
59\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
59\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
@@ -63,8 +63,8 @@ Right Aligned
63\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
63\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
64Default aligned
64Default aligned
65\end{minipage}
65\end{minipage}
66−\\\noalign{\medskip}
66+\\\addlinespace
67−\hline\noalign{\medskip}
67+\midrule\endhead
68\begin{minipage}[t]{0.13\columnwidth}\centering
68\begin{minipage}[t]{0.13\columnwidth}\centering
69First
69First
70\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
70\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -74,7 +74,7 @@ row
74\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
74\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
75Example of a row that spans multiple lines.
75Example of a row that spans multiple lines.
76\end{minipage}
76\end{minipage}
77−\\\noalign{\medskip}
77+\\\addlinespace
78\begin{minipage}[t]{0.13\columnwidth}\centering
78\begin{minipage}[t]{0.13\columnwidth}\centering
79Second
79Second
80\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
80\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -84,16 +84,16 @@ row
84\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
84\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
85Here's another one. Note the blank line between rows.
85Here's another one. Note the blank line between rows.
86\end{minipage}
86\end{minipage}
87−\\\noalign{\medskip}
87+\\\addlinespace
88−\hline
88+\bottomrule
89−\noalign{\medskip}
89+\addlinespace
90\caption{Here's the caption. It may span multiple lines.}
90\caption{Here's the caption. It may span multiple lines.}
91\end{longtable}
91\end{longtable}
92
92
93Multiline table without caption:
93Multiline table without caption:
94
94
95\begin{longtable}[c]{@{}clrl@{}}
95\begin{longtable}[c]{@{}clrl@{}}
96−\hline\noalign{\medskip}
96+\toprule\addlinespace
97\begin{minipage}[b]{0.13\columnwidth}\centering
97\begin{minipage}[b]{0.13\columnwidth}\centering
98Centered Header
98Centered Header
99\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
99\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
@@ -103,8 +103,8 @@ Right Aligned
103\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
103\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
104Default aligned
104Default aligned
105\end{minipage}
105\end{minipage}
106−\\\noalign{\medskip}
106+\\\addlinespace
107−\hline\noalign{\medskip}
107+\midrule\endhead
108\begin{minipage}[t]{0.13\columnwidth}\centering
108\begin{minipage}[t]{0.13\columnwidth}\centering
109First
109First
110\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
110\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -114,7 +114,7 @@ row
114\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
114\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
115Example of a row that spans multiple lines.
115Example of a row that spans multiple lines.
116\end{minipage}
116\end{minipage}
117−\\\noalign{\medskip}
117+\\\addlinespace
118\begin{minipage}[t]{0.13\columnwidth}\centering
118\begin{minipage}[t]{0.13\columnwidth}\centering
119Second
119Second
120\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
120\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -124,27 +124,27 @@ row
124\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
124\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
125Here's another one. Note the blank line between rows.
125Here's another one. Note the blank line between rows.
126\end{minipage}
126\end{minipage}
127−\\\noalign{\medskip}
127+\\\addlinespace
128−\hline
128+\bottomrule
129\end{longtable}
129\end{longtable}
130
130
131Table without column headers:
131Table without column headers:
132
132
133\begin{longtable}[c]{@{}rlcr@{}}
133\begin{longtable}[c]{@{}rlcr@{}}
134−\hline\noalign{\medskip}
134+\toprule\addlinespace
13512 & 12 & 12 & 12
13512 & 12 & 12 & 12
136−\\\noalign{\medskip}
136+\\\addlinespace
137123 & 123 & 123 & 123
137123 & 123 & 123 & 123
138−\\\noalign{\medskip}
138+\\\addlinespace
1391 & 1 & 1 & 1
1391 & 1 & 1 & 1
140−\\\noalign{\medskip}
140+\\\addlinespace
141−\hline
141+\bottomrule
142\end{longtable}
142\end{longtable}
143
143
144Multiline table without column headers:
144Multiline table without column headers:
145
145
146\begin{longtable}[c]{@{}clrl@{}}
146\begin{longtable}[c]{@{}clrl@{}}
147−\hline\noalign{\medskip}
147+\toprule\addlinespace
148\begin{minipage}[t]{0.13\columnwidth}\centering
148\begin{minipage}[t]{0.13\columnwidth}\centering
149First
149First
150\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
150\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -154,7 +154,7 @@ row
154\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
154\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
155Example of a row that spans multiple lines.
155Example of a row that spans multiple lines.
156\end{minipage}
156\end{minipage}
157−\\\noalign{\medskip}
157+\\\addlinespace
158\begin{minipage}[t]{0.13\columnwidth}\centering
158\begin{minipage}[t]{0.13\columnwidth}\centering
159Second
159Second
160\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
160\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
@@ -164,6 +164,6 @@ row
164\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
164\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
165Here's another one. Note the blank line between rows.
165Here's another one. Note the blank line between rows.
166\end{minipage}
166\end{minipage}
167−\\\noalign{\medskip}
167+\\\addlinespace
168−\hline
168+\bottomrule
169\end{longtable}
169\end{longtable}