Add booktabs package for LaTeX tables
[ci skip]
This commit is contained in:
parent
1213192cae
commit
fdaeec0c48
4 changed files with 52 additions and 52 deletions
2
README
2
README
|
@ -108,7 +108,7 @@ to PDF:
|
||||||
Production of a PDF requires that a LaTeX engine be installed (see
|
Production of a PDF requires that a LaTeX engine be installed (see
|
||||||
`--latex-engine`, below), and assumes that the following LaTeX packages are
|
`--latex-engine`, below), and assumes that the following LaTeX packages are
|
||||||
available: `amssymb`, `amsmath`, `ifxetex`, `ifluatex`, `listings` (if the
|
available: `amssymb`, `amsmath`, `ifxetex`, `ifluatex`, `listings` (if the
|
||||||
`--listings` option is used), `fancyvrb`, `longtable`, `url`,
|
`--listings` option is used), `fancyvrb`, `longtable`, `booktabs`, `url`,
|
||||||
`graphicx`, `hyperref`, `ulem`, `babel` (if the `lang` variable is set),
|
`graphicx`, `hyperref`, `ulem`, `babel` (if the `lang` variable is set),
|
||||||
`fontspec` (if `xelatex` or `lualatex` is used as the LaTeX engine), `xltxtra`
|
`fontspec` (if `xelatex` or `lualatex` is used as the LaTeX engine), `xltxtra`
|
||||||
and `xunicode` (if `xelatex` is used).
|
and `xunicode` (if `xelatex` is used).
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 713a8f63d5589ab9313869e47b03cf7f49e00e98
|
Subproject commit f643a076d8c2b0b21391fd6aa1dedb2dd84c7e63
|
|
@ -453,12 +453,12 @@ blockToLaTeX (Header level (id',classes,_) lst) =
|
||||||
blockToLaTeX (Table caption aligns widths heads rows) = do
|
blockToLaTeX (Table caption aligns widths heads rows) = do
|
||||||
headers <- if all null heads
|
headers <- if all null heads
|
||||||
then return empty
|
then return empty
|
||||||
else ($$ "\\hline\\noalign{\\medskip}") `fmap`
|
else ($$ "\\midrule\\endhead") `fmap`
|
||||||
(tableRowToLaTeX True aligns widths) heads
|
(tableRowToLaTeX True aligns widths) heads
|
||||||
captionText <- inlineListToLaTeX caption
|
captionText <- inlineListToLaTeX caption
|
||||||
let capt = if isEmpty captionText
|
let capt = if isEmpty captionText
|
||||||
then empty
|
then empty
|
||||||
else text "\\noalign{\\medskip}"
|
else text "\\addlinespace"
|
||||||
$$ text "\\caption" <> braces captionText
|
$$ text "\\caption" <> braces captionText
|
||||||
rows' <- mapM (tableRowToLaTeX False aligns widths) rows
|
rows' <- mapM (tableRowToLaTeX False aligns widths) rows
|
||||||
let colDescriptors = text $ concat $ map toColDescriptor aligns
|
let colDescriptors = text $ concat $ map toColDescriptor aligns
|
||||||
|
@ -466,10 +466,10 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
|
||||||
return $ "\\begin{longtable}[c]" <>
|
return $ "\\begin{longtable}[c]" <>
|
||||||
braces ("@{}" <> colDescriptors <> "@{}")
|
braces ("@{}" <> colDescriptors <> "@{}")
|
||||||
-- the @{} removes extra space at beginning and end
|
-- the @{} removes extra space at beginning and end
|
||||||
$$ "\\hline\\noalign{\\medskip}"
|
$$ "\\toprule\\addlinespace"
|
||||||
$$ headers
|
$$ headers
|
||||||
$$ vcat rows'
|
$$ vcat rows'
|
||||||
$$ "\\hline"
|
$$ "\\bottomrule"
|
||||||
$$ capt
|
$$ capt
|
||||||
$$ "\\end{longtable}"
|
$$ "\\end{longtable}"
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ tableRowToLaTeX header aligns widths cols = do
|
||||||
(w * scaleFactor))) <>
|
(w * scaleFactor))) <>
|
||||||
(halign a <> cr <> c <> cr) <> "\\end{minipage}"
|
(halign a <> cr <> c <> cr) <> "\\end{minipage}"
|
||||||
let cells = zipWith3 toCell widths aligns renderedCells
|
let cells = zipWith3 toCell widths aligns renderedCells
|
||||||
return $ hsep (intersperse "&" cells) $$ "\\\\\\noalign{\\medskip}"
|
return $ hsep (intersperse "&" cells) $$ "\\\\\\addlinespace"
|
||||||
|
|
||||||
listItemToLaTeX :: [Block] -> State WriterState Doc
|
listItemToLaTeX :: [Block] -> State WriterState Doc
|
||||||
listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
|
listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
Simple table with caption:
|
Simple table with caption:
|
||||||
|
|
||||||
\begin{longtable}[c]{@{}rlcl@{}}
|
\begin{longtable}[c]{@{}rlcl@{}}
|
||||||
\hline\noalign{\medskip}
|
\toprule\addlinespace
|
||||||
Right & Left & Center & Default
|
Right & Left & Center & Default
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline\noalign{\medskip}
|
\midrule\endhead
|
||||||
12 & 12 & 12 & 12
|
12 & 12 & 12 & 12
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
123 & 123 & 123 & 123
|
123 & 123 & 123 & 123
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
1 & 1 & 1 & 1
|
1 & 1 & 1 & 1
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline
|
\bottomrule
|
||||||
\noalign{\medskip}
|
\addlinespace
|
||||||
\caption{Demonstration of simple table syntax.}
|
\caption{Demonstration of simple table syntax.}
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
||||||
Simple table without caption:
|
Simple table without caption:
|
||||||
|
|
||||||
\begin{longtable}[c]{@{}rlcl@{}}
|
\begin{longtable}[c]{@{}rlcl@{}}
|
||||||
\hline\noalign{\medskip}
|
\toprule\addlinespace
|
||||||
Right & Left & Center & Default
|
Right & Left & Center & Default
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline\noalign{\medskip}
|
\midrule\endhead
|
||||||
12 & 12 & 12 & 12
|
12 & 12 & 12 & 12
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
123 & 123 & 123 & 123
|
123 & 123 & 123 & 123
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
1 & 1 & 1 & 1
|
1 & 1 & 1 & 1
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline
|
\bottomrule
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
||||||
Simple table indented two spaces:
|
Simple table indented two spaces:
|
||||||
|
|
||||||
\begin{longtable}[c]{@{}rlcl@{}}
|
\begin{longtable}[c]{@{}rlcl@{}}
|
||||||
\hline\noalign{\medskip}
|
\toprule\addlinespace
|
||||||
Right & Left & Center & Default
|
Right & Left & Center & Default
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline\noalign{\medskip}
|
\midrule\endhead
|
||||||
12 & 12 & 12 & 12
|
12 & 12 & 12 & 12
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
123 & 123 & 123 & 123
|
123 & 123 & 123 & 123
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
1 & 1 & 1 & 1
|
1 & 1 & 1 & 1
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline
|
\bottomrule
|
||||||
\noalign{\medskip}
|
\addlinespace
|
||||||
\caption{Demonstration of simple table syntax.}
|
\caption{Demonstration of simple table syntax.}
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
||||||
Multiline table with caption:
|
Multiline table with caption:
|
||||||
|
|
||||||
\begin{longtable}[c]{@{}clrl@{}}
|
\begin{longtable}[c]{@{}clrl@{}}
|
||||||
\hline\noalign{\medskip}
|
\toprule\addlinespace
|
||||||
\begin{minipage}[b]{0.13\columnwidth}\centering
|
\begin{minipage}[b]{0.13\columnwidth}\centering
|
||||||
Centered Header
|
Centered Header
|
||||||
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
|
||||||
|
@ -63,8 +63,8 @@ Right Aligned
|
||||||
\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
|
||||||
Default aligned
|
Default aligned
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline\noalign{\medskip}
|
\midrule\endhead
|
||||||
\begin{minipage}[t]{0.13\columnwidth}\centering
|
\begin{minipage}[t]{0.13\columnwidth}\centering
|
||||||
First
|
First
|
||||||
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
||||||
|
@ -74,7 +74,7 @@ row
|
||||||
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
||||||
Example of a row that spans multiple lines.
|
Example of a row that spans multiple lines.
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\begin{minipage}[t]{0.13\columnwidth}\centering
|
\begin{minipage}[t]{0.13\columnwidth}\centering
|
||||||
Second
|
Second
|
||||||
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
||||||
|
@ -84,16 +84,16 @@ row
|
||||||
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
||||||
Here's another one. Note the blank line between rows.
|
Here's another one. Note the blank line between rows.
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline
|
\bottomrule
|
||||||
\noalign{\medskip}
|
\addlinespace
|
||||||
\caption{Here's the caption. It may span multiple lines.}
|
\caption{Here's the caption. It may span multiple lines.}
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
||||||
Multiline table without caption:
|
Multiline table without caption:
|
||||||
|
|
||||||
\begin{longtable}[c]{@{}clrl@{}}
|
\begin{longtable}[c]{@{}clrl@{}}
|
||||||
\hline\noalign{\medskip}
|
\toprule\addlinespace
|
||||||
\begin{minipage}[b]{0.13\columnwidth}\centering
|
\begin{minipage}[b]{0.13\columnwidth}\centering
|
||||||
Centered Header
|
Centered Header
|
||||||
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[b]{0.12\columnwidth}\raggedright
|
||||||
|
@ -103,8 +103,8 @@ Right Aligned
|
||||||
\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[b]{0.30\columnwidth}\raggedright
|
||||||
Default aligned
|
Default aligned
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline\noalign{\medskip}
|
\midrule\endhead
|
||||||
\begin{minipage}[t]{0.13\columnwidth}\centering
|
\begin{minipage}[t]{0.13\columnwidth}\centering
|
||||||
First
|
First
|
||||||
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
||||||
|
@ -114,7 +114,7 @@ row
|
||||||
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
||||||
Example of a row that spans multiple lines.
|
Example of a row that spans multiple lines.
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\begin{minipage}[t]{0.13\columnwidth}\centering
|
\begin{minipage}[t]{0.13\columnwidth}\centering
|
||||||
Second
|
Second
|
||||||
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
||||||
|
@ -124,27 +124,27 @@ row
|
||||||
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
||||||
Here's another one. Note the blank line between rows.
|
Here's another one. Note the blank line between rows.
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline
|
\bottomrule
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
||||||
Table without column headers:
|
Table without column headers:
|
||||||
|
|
||||||
\begin{longtable}[c]{@{}rlcr@{}}
|
\begin{longtable}[c]{@{}rlcr@{}}
|
||||||
\hline\noalign{\medskip}
|
\toprule\addlinespace
|
||||||
12 & 12 & 12 & 12
|
12 & 12 & 12 & 12
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
123 & 123 & 123 & 123
|
123 & 123 & 123 & 123
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
1 & 1 & 1 & 1
|
1 & 1 & 1 & 1
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline
|
\bottomrule
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
||||||
Multiline table without column headers:
|
Multiline table without column headers:
|
||||||
|
|
||||||
\begin{longtable}[c]{@{}clrl@{}}
|
\begin{longtable}[c]{@{}clrl@{}}
|
||||||
\hline\noalign{\medskip}
|
\toprule\addlinespace
|
||||||
\begin{minipage}[t]{0.13\columnwidth}\centering
|
\begin{minipage}[t]{0.13\columnwidth}\centering
|
||||||
First
|
First
|
||||||
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
||||||
|
@ -154,7 +154,7 @@ row
|
||||||
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
||||||
Example of a row that spans multiple lines.
|
Example of a row that spans multiple lines.
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\begin{minipage}[t]{0.13\columnwidth}\centering
|
\begin{minipage}[t]{0.13\columnwidth}\centering
|
||||||
Second
|
Second
|
||||||
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.12\columnwidth}\raggedright
|
||||||
|
@ -164,6 +164,6 @@ row
|
||||||
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
\end{minipage} & \begin{minipage}[t]{0.30\columnwidth}\raggedright
|
||||||
Here's another one. Note the blank line between rows.
|
Here's another one. Note the blank line between rows.
|
||||||
\end{minipage}
|
\end{minipage}
|
||||||
\\\noalign{\medskip}
|
\\\addlinespace
|
||||||
\hline
|
\bottomrule
|
||||||
\end{longtable}
|
\end{longtable}
|
||||||
|
|
Loading…
Reference in a new issue