Problem: Overfull \hbox (416.83289pt too wide) detected
.. warning message with longtable
, at the \caption{}
line.
Possible explanation (IMHO) : The caption package
clashes with the \caption{}
definition set by the longtable package
; which is nothing but —\multicolumn{\LT@cols}{c}{<a \parbox of width \LTcapwidth , with the table's caption>}
inside a box of width 0pt
, so that it never affects the column widths (ref.- longtable documentation
). If this turns out to be true (according to experts), then it is surprising, because according to both package documentations, these packages are supposed to be compatible.
My Workaround (which is unacceptable to me) : Either remove the entire \caption{}
line or remove the caption package
along with the corresponding \captionsetup{}
configuration. It is unacceptable because, in my thesis there are several other figures, tables, listings, etc. for which the caption package
& the \captionsetup{}
configuration has worked beautifully!
MWE's : 1. with caption package
& 2. without caption package
Note: I've used showframe
& \documentclass[draft]{<class>}
to point out the problematic line/s in the output.
MWE 1 : with caption package
:
\documentclass[11pt,a4paper,oneside,draft]{report}
\usepackage[top=1in,bottom=1.5in,left=1.5in,right=1in]{geometry}
\usepackage{showframe}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{caption} % This is throwing a "400+ pt overfull hbox error" for longtables!
\usepackage{lipsum}
% A group of packages required for tables
\usepackage{array}
\usepackage{booktabs}
\usepackage{longtable}
\DeclareCaptionLabelSeparator{periodQuad}{. \quad} % DIY customisation of labelsep
\DeclareCaptionLabelFormat{tabulab}{\textbullet\quad #1 #2}
\DeclareCaptionStyle{periodQuad}[labelsep=period]{labelsep=periodQuad}
\captionsetup{%
font={sf,up},
labelfont={bf},
singlelinecheck=true,
justification=centerfirst,
labelformat=tabulab,
labelsep=periodQuad,
position=bottom
}%
\providecommand{\negsci}[1]{\ensuremath{\hspace*{0.5pt}\text{\sc{e}\hspace*{0.5pt}{-}}{#1}}}
\begin{document}
\lipsum[9]
\vspace*{-2em}
{ % Begin group --- % To keep the effect local!
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\LTpost{-14ex}
\begin{center}
\renewcommand*{\arraystretch}{1.6}
%\begin{longtable}{ccccc}
\begin{longtable}{@{\extracolsep{\fill}}ccccc@{}}
\caption[Parameter Values for the model]{Parameter Values for the model\label{tab:mod_pars}}\medskip\\
% Gives (./longtableMWE.tex Overfull \hbox (416.83289pt too wide) detected .. ERROR!
\midrule
Equation & Parameter & Value & Units & Reference \\
\midrule
\endfirsthead
\midrule
\endhead
\addlinespace[4pt]\multicolumn{5}{r}{\textcolor{gray}{\footnotesize(\textit{Continued on next page $\ldots$})}}
\endfoot
\endlastfoot
16 & Adenine Total & 4.81 & mM & 2-6, \& 23-25 \\
31, 36 & Calcium ions & {6.0}\negsci{03}{} & mM & 56, 23, 55, 12 \\
34 & Carbon dioxide & 1.63 & mM & 9, 11, 4, 8 \\
13, 17, 3, 6 & CoA Total & 2.7 & mM & 5, 11 \\
20 & Bicarbonate & 21.2 & mM & 7, 23, 42, 63 \\
52, 16, 23 & Cytosolic Malate & 0.47 & mM & \textemdash \\
\midrule\addlinespace[5em]
\end{longtable}
\end{center}
} % End group --- % To keep the effect local!
\lipsum[8]
\cleardoublepage
\end{document}
Output for MWE 1 : with caption package
:
MWE 2 : without caption package
:
\documentclass[11pt,a4paper,oneside,draft]{report}
\usepackage[top=1in,bottom=1.5in,left=1.5in,right=1in]{geometry}
\usepackage{showframe}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{amsmath}
%\usepackage{caption} % This is throwing a "400+ pt overfull hbox error" for longtables!
\usepackage{lipsum}
% A group of packages required for tables
\usepackage{array}
\usepackage{booktabs}
\usepackage{longtable}
% For formatting the numbers in scientific format
\providecommand{\negsci}[1]{\ensuremath{\hspace*{0.5pt}\text{\sc{e}\hspace*{0.5pt}{-}}{#1}}}
\begin{document}
\lipsum[9]
\vspace*{-1em}
{ % Begin group --- % To keep the effect local!
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\setlength\LTpost{-14ex}
\begin{center}
\renewcommand*{\arraystretch}{1.6}
%\begin{longtable}{ccccc}
\begin{longtable}{@{\extracolsep{\fill}}ccccc@{}}
\caption[Parameter Values for the model]{Parameter Values for the model\label{tab:mod_pars}}\\
% Gives (./longtableMWE.tex Overfull \hbox (416.83289pt too wide) detected .. ERROR!
\midrule
Equation & Parameter & Value & Units & Reference \\
\midrule
\endfirsthead
\midrule
\endhead
\addlinespace[4pt]\multicolumn{5}{r}{\textcolor{gray}{\footnotesize(\textit{Continued on next page $\ldots$})}}
\endfoot
\endlastfoot
16 & Adenine Total & 4.81 & mM & 2-6, \& 23-25 \\
31, 36 & Calcium ions & {6.0}\negsci{03}{} & mM & 56, 23, 55, 12 \\
34 & Carbon dioxide & 1.63 & mM & 9, 11, 4, 8 \\
13, 17, 3, 6 & CoA Total & 2.7 & mM & 5, 11 \\
20 & Bicarbonate & 21.2 & mM & 7, 23, 42, 63 \\
52, 16, 23 & Cytosolic Malate & 0.47 & mM & \textemdash \\
\midrule\addlinespace[5em]
\end{longtable}
\end{center}
} % End group --- % To keep the effect local!
\lipsum[8]
\cleardoublepage
\end{document}
Output for MWE 2 : without caption package
:
Therefore, between these 2 outputs, we can clearly see where the overfull \hbox error
occurs and how it disappears when the caption package
is removed. I wish to use both the longtable
as well as the caption
packages in my thesis and therefore this workaround is useless for me. Could anyone please help me troubleshoot this error, without removing caption package
? Also, the overfull \hbox
error is large enough (almost 400+ pt
!) to not be overlooked! Any help/ suggestions/ pointers will be most appreciated. Thanks!
Best Answer
Turns out that
caption
package version is not expecting\LTleft
to be set to 0pt.setting
centres the caption without affecting the table (as the fill glue in extracolsep cancels out this finite stretch)
You should also remove the
center
environment which does not affect the alignment but just adds spurious vertical space (which is probably why you set\LTpost
negative)