I have got a latex related problem:
Consider the following code including the preamble. It should be possible to run it standalone, provided all packages are available.
I'd like to have both longtables have the same spacing between the last \hline
and the caption as an ordinary table. Therefore I'm using the caption package and the \captionsetup
command (with 10pt). However, the first caption is located not below but on the \hline
.
When removing one of the table "rows" (a set of three lines), the caption is displayed correctly. Maybe it has thus to do with the length of the table. However, I am using similarly-styled tables with more than 600 elements in my document as well, where the caption spacing works.
I am not sure whether Problem with caption when using longtable could give an answer to my question, but I would like to keep the caption below the table if possible.
Any ideas on how to resolve this (\\
before the \caption
works, but the spacing is a bit too large) and why this problem occurs?
Thank you in advance!
\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{float}
\usepackage{parskip}
\usepackage{longtable}
\usepackage{upgreek}
\usepackage{rotating}
\usepackage{url}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[left=2.2cm,top=2cm,right=2.2cm,
bottom=2.0cm,bindingoffset=0.5cm,headsep=5pt]{geometry}
\usepackage{caption}
\usepackage{titlesec}
\captionsetup[table]{skip=10pt}
\titleformat*{\section}{\LARGE\bfseries}
\titleformat*{\subsection}{\Large\bfseries}
\titleformat*{\subsubsection}{\large\bfseries}
\LTcapwidth=\textwidth
\begin{document}
\tiny
\begin{longtable}{@{}l@{\hspace{1pt}}l@{\hspace{1pt}}
l@{\hspace{1pt}}l@{\hspace{1pt}}r@{\hspace{1pt}}r@{\hspace{1pt}}
r@{\hspace{1pt}}r@{\hspace{1pt}}r@{\hspace{1pt}}r@{\hspace{1pt}}
r@{\hspace{1pt}}r@{\hspace{1pt}}r@{\hspace{1pt}}r@{\hspace{1pt}}
r@{}}
XXX & XXX & XXX & XXX & XXX & XXX & XXX & XXX & XXX & XXX & XXX & XXX & XXX & XXX & XXX \\
\hline
XXX & XXX & XXX & single & 6100 & 1.6 & 0.30 & 4.9 & 0.32 & 0.25 & 0.38 & 0.32 & 0.31 & 0.34 & 0.31 \\
& & & & & & & & 0.34 & 0.36 & 0.34 & 0.24 & 0.44 & 0.38 & 0.30 \\
& & & & & & & & 0.33 & 0.30 & 0.36 & 0.28 & 0.38 & 0.36 & 0.31 \\
XXX & XXX & XXX & single & 4750 & 1.1 & 0.10 & 4.8 & 0.10 & 0.03 & 0.20 & 0.10 & 0.11 & 0.13 & 0.08 \\
& & & & & & & & 0.12 & 0.21 & 0.04 & 0.01 & 0.25 & 0.14 & 0.11 \\
& & & & & & & & 0.11 & 0.12 & 0.12 & 0.05 & 0.18 & 0.13 & 0.10 \\
XXX & XXX & XXX & single & 5450 & 1.3 & -0.10 & 3.6 & -0.12 & -0.22 & -0.04 & -0.10 & -0.14 & -0.09 & -0.16 \\
& & & & & & & & 0.14 & -0.12 & -0.15 & -0.25 & -0.01 & -0.01 & -0.21 \\
& & & & & & & & 0.13 & -0.17 & -0.09 & -0.18 & -0.08 & -0.05 & -0.18 \\
XXX & XXX & XXX & red & 5500 & 1.5 & -0.05 & 4.9 & -0.04 & -0.11 & 0.05 & -0.02 & -0.04 & -0.02 & -0.05 \\
& & & & & & & & 0.05 & -0.03 & -0.06 & -0.17 & 0.08 & 0.03 & -0.10 \\
& & & & & & & & 0.04 & -0.07 & -0.01 & -0.09 & 0.02 & 0.01 & -0.08 \\
XXX & XXX & XXX & red & 5850 & 1.2 & 0.10 & 3.1 & 0.15 & 0.07 & 0.21 & 0.16 & 0.13 & 0.20 & 0.13 \\
& & & & & & & & 0.13 & 0.13 & 0.13 & 0.02 & 0.24 & 0.21 & 0.01 \\
& & & & & & & & 0.14 & 0.10 & 0.17 & 0.09 & 0.19 & 0.21 & 0.07 \\
XXX & XXX & XXX & red & 5600 & 1.5 & 0.05 & 3.6 & 0.03 & -0.05 & 0.11 & 0.05 & 0.02 & 0.06 & 0.01 \\
& & & & & & & & 0.05 & 0.09 & 0.02 & -0.06 & 0.16 & 0.13 & -0.04 \\
& & & & & & & & 0.04 & 0.02 & 0.06 & -0.01 & 0.09 & 0.10 & -0.01 \\
XXX & XXX & XXX & red & 5200 & 1.7 & -0.05 & 4.9 & -0.06 & -0.15 & 0.02 & -0.06 & -0.07 & -0.04 & -0.07 \\
& & & & & & & & 0.04 & 0.00 & -0.07 & -0.17 & 0.10 & 0.06 & -0.10 \\
& & & & & & & & 0.05 & -0.07 & -0.03 & -0.11 & 0.02 & 0.01 & -0.08 \\
XXX & XXX & XXX & red & 5100 & 1.0 & 0.10 & 4.9 & 0.12 & 0.03 & 0.20 & 0.14 & 0.11 & 0.14 & 0.11 \\
& & & & & & & & 0.14 & 0.16 & 0.09 & 0.02 & 0.27 & 0.22 & 0.12 \\
& & & & & & & & 0.13 & 0.09 & 0.14 & 0.08 & 0.19 & 0.18 & 0.12 \\
XXX & XXX & XXX & red & 5150 & 0.8 & 0.05 & 4.9 & 0.07 & -0.02 & 0.15 & 0.08 & 0.05 & 0.08 & 0.06 \\
& & & & & & & & 0.08 & 0.14 & 0.04 & -0.03 & 0.20 & 0.10 & 0.06 \\
& & & & & & & & 0.07 & 0.06 & 0.09 & 0.03 & 0.13 & 0.09 & 0.06 \\
XXX & XXX & XXX & red & 6300 & 2.0 & -0.05 & 3.5 & 0.01 & -0.05 & 0.08 & 0.02 & 0.01 & 0.06 & -0.01 \\
& & & & & & & & 0.08 & -0.06 & -0.07 & -0.19 & -0.08 & -0.01 & -0.14 \\
& & & & & & & & 0.03 & -0.05 & 0.00 & -0.08 & -0.03 & 0.02 & -0.08 \\
XXX & XXX & XXX & single & 5600 & 1.5 & -0.15 & 4.9 & -0.17 & -0.24 & -0.09 & -0.15 & -0.18 & -0.16 & -0.18 \\
& & & & & & & & 0.18 & -0.17 & -0.18 & -0.29 & -0.06 & -0.11 & -0.22 \\
& & & & & & & & 0.17 & -0.20 & -0.13 & -0.22 & -0.12 & -0.13 & -0.20 \\
XXX & XXX & XXX & single & 5550 & 1.3 & -0.20 & 4.9 & -0.18 & -0.27 & -0.10 & -0.16 & -0.20 & -0.17 & -0.19 \\
& & & & & & & & 0.20 & -0.19 & -0.21 & -0.31 & -0.09 & -0.12 & -0.27 \\
& & & & & & & & 0.19 & -0.23 & -0.16 & -0.24 & -0.14 & -0.14 & -0.23 \\
XXX & XXX & XXX & single & 6450 & 1.5 & 0.20 & 2.0 & 0.20 & 0.14 & 0.26 & 0.23 & 0.18 & 0.25 & 0.14 \\
& & & & & & & & 0.19 & 0.17 & 0.21 & 0.10 & 0.28 & 0.21 & -0.02 \\
& & & & & & & & 0.19 & 0.15 & 0.23 & 0.16 & 0.23 & 0.23 & 0.06 \\
\hline
\caption[CapXXX1]{Test caption.\label{allsensitivity}}
\end{longtable}
\setlength\LTleft{\fill}
\setlength\LTright{\fill}
\large
\vspace{12cm}
\normalsize
\begin{longtable}{llrrrrr}
XXX & XXX & XXX & XXX & XXX & XXX & XXX\\
\hline
XXX & XXX & 1 & - & - & - & 1 \\
XXX & XXX & 3 & - & - & - & 3 \\
XXX & XXX & 1 & - & - & - & 1 \\
XXX & XXX & 3 & - & - & - & 3 \\
XXX & XXX & 4 & - & - & - & 4 \\
XXX & XXX & 2 & 26 & - & 24 & 52 \\
XXX & XXX & 8 & - & 2 & - & 10 \\
XXX & XXX & 2 & - & 2 & - & 4 \\
XXX & XXX & - & - & 3 & - & 3 \\
XXX & XXX & - & - & 8 & - & 8 \\
XXX & XXX & - & - & 3 & - & 3 \\
\hline
\caption[CapXXX2]{Test caption 2.\label{XXX2}}
\end{longtable}
\large
\end{document}
longtable
is not a float,\caption
is redefined within it. From documentation: The caption is\multicolumn{\LT@cols}{c}{⟨a parbox with the table’s caption⟩}
@{\hspace{1pt}}
directives? Why not just execute\setlength\tabcolsep{0.5pt
and omit all@{\hspace{1pt}}
instructions?