git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Put table captions above tables.

The standard seems to be captions above tables. (See http://tex.stackexchange.com/questions/3243/why-should-a-table-caption-be-placed-above-the-table)

commit66378062b622b0815a1a2ddce5d557e3ad13330c authorJohn MacFarlane <jgm@berkeley.edu> dateThu 10 Jul 2014, 13:06 (12 years ago) parent7d6da11
2 files changed+5−9
src/Text/Pandoc/Writers/LaTeX.hs+2−3 tests/tables.latex+3−6
src/Text/Pandoc/Writers/LaTeX.hs+2−3
@@ -471,19 +471,18 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
471471 captionText <- inlineListToLaTeX caption
472472 let capt = if isEmpty captionText
473473 then empty
474− else text "\\addlinespace"
475− $$ text "\\caption" <> braces captionText
474+ else text "\\caption" <> braces captionText <> "\\\\"
476475 rows' <- mapM (tableRowToLaTeX False aligns widths) rows
477476 let colDescriptors = text $ concat $ map toColDescriptor aligns
478477 modify $ \s -> s{ stTable = True }
479478 return $ "\\begin{longtable}[c]" <>
480479 braces ("@{}" <> colDescriptors <> "@{}")
481480 -- the @{} removes extra space at beginning and end
481+ $$ capt
482482 $$ "\\toprule\\addlinespace"
483483 $$ headers
484484 $$ vcat rows'
485485 $$ "\\bottomrule"
486− $$ capt
487486 $$ "\\end{longtable}"
488487
489488toColDescriptor :: Alignment -> String
tests/tables.latex+3−6
@@ -1,6 +1,7 @@
11Simple table with caption:
22
33\begin{longtable}[c]{@{}rlcl@{}}
4+\caption{Demonstration of simple table syntax.}\\
45\toprule\addlinespace
56Right & Left & Center & Default
67\\\addlinespace
@@ -12,8 +13,6 @@ Right & Left & Center & Default
12131 & 1 & 1 & 1
1314\\\addlinespace
1415\bottomrule
15−\addlinespace
16−\caption{Demonstration of simple table syntax.}
1716\end{longtable}
1817
1918Simple table without caption:
@@ -35,6 +34,7 @@ Right & Left & Center & Default
3534Simple table indented two spaces:
3635
3736\begin{longtable}[c]{@{}rlcl@{}}
37+\caption{Demonstration of simple table syntax.}\\
3838\toprule\addlinespace
3939Right & Left & Center & Default
4040\\\addlinespace
@@ -46,13 +46,12 @@ Right & Left & Center & Default
46461 & 1 & 1 & 1
4747\\\addlinespace
4848\bottomrule
49−\addlinespace
50−\caption{Demonstration of simple table syntax.}
5149\end{longtable}
5250
5351Multiline table with caption:
5452
5553\begin{longtable}[c]{@{}clrl@{}}
54+\caption{Here's the caption. It may span multiple lines.}\\
5655\toprule\addlinespace
5756\begin{minipage}[b]{0.13\columnwidth}\centering
5857Centered Header
@@ -86,8 +85,6 @@ Here's another one. Note the blank line between rows.
8685\end{minipage}
8786\\\addlinespace
8887\bottomrule
89−\addlinespace
90−\caption{Here's the caption. It may span multiple lines.}
9188\end{longtable}
9289
9390Multiline table without caption: