mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-25 01:36:45 +00:00
LaTeX writer: Provide a way to use table instead of longtable.
When the `float` class is attached to a table, a standard floating `table` will be generated instead of a `longtable`. Placement can be specified via the `latex-placement` attribute. This will help, especially, those who use two-column layouts, since `longtable` is incompatible with these. Small change to the default LaTeX template: the `caption` package is included and a default spacing set between the caption and the table. Closes #1023.
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
```
|
||||
% pandoc -t latex
|
||||
: Here's the caption.
|
||||
It may span multiple lines. {.float #ident latex-placement="ht"}
|
||||
|
||||
---------------------------------------------------------------
|
||||
Centered Left Right
|
||||
Header Aligned Aligned Default aligned
|
||||
---------- --------- ----------- ---------------------------
|
||||
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.
|
||||
---------------------------------------------------------------
|
||||
^D
|
||||
\begin{table}[ht]
|
||||
\centering
|
||||
\caption{Here's the caption. It may span multiple
|
||||
lines.}\label{ident}\tabularnewline
|
||||
\begin{tabular}{@{}
|
||||
>{\centering\arraybackslash}p{(\linewidth - 6\tabcolsep) * \real{0.1667}}
|
||||
>{\raggedright\arraybackslash}p{(\linewidth - 6\tabcolsep) * \real{0.1528}}
|
||||
>{\raggedleft\arraybackslash}p{(\linewidth - 6\tabcolsep) * \real{0.1806}}
|
||||
>{\raggedright\arraybackslash}p{(\linewidth - 6\tabcolsep) * \real{0.3889}}@{}}
|
||||
\toprule\noalign{}
|
||||
\begin{minipage}[b]{\linewidth}\centering
|
||||
Centered Header
|
||||
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
|
||||
Left Aligned
|
||||
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedleft
|
||||
Right Aligned
|
||||
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
|
||||
Default aligned
|
||||
\end{minipage} \\
|
||||
\midrule\noalign{}
|
||||
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\noalign{}
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -t latex
|
||||
: Simple table with no column headers {.float #ident}
|
||||
|
||||
------- ------ ---------- -------
|
||||
12 12 12 12
|
||||
123 123 123 123
|
||||
1 1 1 1
|
||||
------- ------ ---------- -------
|
||||
^D
|
||||
\begin{table}[]
|
||||
\centering
|
||||
\caption{Simple table with no column
|
||||
headers}\label{ident}\tabularnewline
|
||||
\begin{tabular}{@{}rlcr@{}}
|
||||
\toprule\noalign{}
|
||||
12 & 12 & 12 & 12 \\
|
||||
123 & 123 & 123 & 123 \\
|
||||
1 & 1 & 1 & 1 \\
|
||||
\bottomrule\noalign{}
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -t latex
|
||||
+--------------------+---------------------+---------------+---------------+
|
||||
| Name^[In English.] | Capital | Population\ | Area\ |
|
||||
| | | (in 2018) | (in km^2^) |
|
||||
+:==================:+:====================+:==============+:==============+
|
||||
| Denmark | Copenhagen | 5,809,502 | 43,094 |
|
||||
+--------------------+---------------------+---------------+---------------+
|
||||
| Finland | Helsinki | 5,537,364 | 338,145 |
|
||||
+--------------------+---------------------+---------------+---------------+
|
||||
| Iceland^[Brrr.] | 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 |
|
||||
+====================+=====================+===============+===============+
|
||||
|
||||
: States belonging to the *Nordics.* {#nordics source="wikipedia" .float}
|
||||
^D
|
||||
\begin{table}[]
|
||||
\centering
|
||||
\caption{States belonging to the
|
||||
\emph{Nordics.}}\label{nordics}\tabularnewline
|
||||
\begin{tabular}{@{}
|
||||
>{\centering\arraybackslash}p{(\linewidth - 6\tabcolsep) * \real{0.2727}}
|
||||
>{\raggedright\arraybackslash}p{(\linewidth - 6\tabcolsep) * \real{0.2857}}
|
||||
>{\raggedright\arraybackslash}p{(\linewidth - 6\tabcolsep) * \real{0.2078}}
|
||||
>{\raggedright\arraybackslash}p{(\linewidth - 6\tabcolsep) * \real{0.2078}}@{}}
|
||||
\toprule\noalign{}
|
||||
\begin{minipage}[b]{\linewidth}\centering
|
||||
Name\footnotemark{}
|
||||
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
|
||||
Capital
|
||||
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
|
||||
Population\\
|
||||
(in 2018)\strut
|
||||
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
|
||||
Area\\
|
||||
(in km\textsuperscript{2})\strut
|
||||
\end{minipage} \\
|
||||
\midrule\noalign{}
|
||||
Denmark & Copenhagen & 5,809,502 & 43,094 \\
|
||||
Finland & Helsinki & 5,537,364 & 338,145 \\
|
||||
Iceland\footnotemark{} & Reykjavik & 343,518 & 103,000 \\
|
||||
Norway & Oslo & 5,372,191 & 323,802 \\
|
||||
Sweden & Stockholm & 10,313,447 & 450,295 \\
|
||||
\midrule\noalign{}
|
||||
Total & & 27,376,022 & 1,258,336 \\
|
||||
\bottomrule\noalign{}
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
\addtocounter{footnote}{-1}
|
||||
\footnotetext{In English.}
|
||||
\addtocounter{footnote}{1}
|
||||
\footnotetext{Brrr.}
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user