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)
This commit is contained in:
John MacFarlane 2014-07-10 13:06:41 -07:00
parent 7d6da118d3
commit 66378062b6
2 changed files with 5 additions and 9 deletions

View file

@ -471,19 +471,18 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
captionText <- inlineListToLaTeX caption captionText <- inlineListToLaTeX caption
let capt = if isEmpty captionText let capt = if isEmpty captionText
then empty then empty
else text "\\addlinespace" else 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
modify $ \s -> s{ stTable = True } modify $ \s -> s{ stTable = True }
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
$$ capt
$$ "\\toprule\\addlinespace" $$ "\\toprule\\addlinespace"
$$ headers $$ headers
$$ vcat rows' $$ vcat rows'
$$ "\\bottomrule" $$ "\\bottomrule"
$$ capt
$$ "\\end{longtable}" $$ "\\end{longtable}"
toColDescriptor :: Alignment -> String toColDescriptor :: Alignment -> String

View file

@ -1,6 +1,7 @@
Simple table with caption: Simple table with caption:
\begin{longtable}[c]{@{}rlcl@{}} \begin{longtable}[c]{@{}rlcl@{}}
\caption{Demonstration of simple table syntax.}\\
\toprule\addlinespace \toprule\addlinespace
Right & Left & Center & Default Right & Left & Center & Default
\\\addlinespace \\\addlinespace
@ -12,8 +13,6 @@ Right & Left & Center & Default
1 & 1 & 1 & 1 1 & 1 & 1 & 1
\\\addlinespace \\\addlinespace
\bottomrule \bottomrule
\addlinespace
\caption{Demonstration of simple table syntax.}
\end{longtable} \end{longtable}
Simple table without caption: Simple table without caption:
@ -35,6 +34,7 @@ Right & Left & Center & Default
Simple table indented two spaces: Simple table indented two spaces:
\begin{longtable}[c]{@{}rlcl@{}} \begin{longtable}[c]{@{}rlcl@{}}
\caption{Demonstration of simple table syntax.}\\
\toprule\addlinespace \toprule\addlinespace
Right & Left & Center & Default Right & Left & Center & Default
\\\addlinespace \\\addlinespace
@ -46,13 +46,12 @@ Right & Left & Center & Default
1 & 1 & 1 & 1 1 & 1 & 1 & 1
\\\addlinespace \\\addlinespace
\bottomrule \bottomrule
\addlinespace
\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@{}}
\caption{Here's the caption. It may span multiple lines.}\\
\toprule\addlinespace \toprule\addlinespace
\begin{minipage}[b]{0.13\columnwidth}\centering \begin{minipage}[b]{0.13\columnwidth}\centering
Centered Header Centered Header
@ -86,8 +85,6 @@ Here's another one. Note the blank line between rows.
\end{minipage} \end{minipage}
\\\addlinespace \\\addlinespace
\bottomrule \bottomrule
\addlinespace
\caption{Here's the caption. It may span multiple lines.}
\end{longtable} \end{longtable}
Multiline table without caption: Multiline table without caption: