# A conflict between caption & longtable packages raises the “overfull \hbox” warning!

Note: This is not a duplicate, as I've already searched most of the suggested duplicates in search of an answer, but it proved to be of no avail! Therefore, please help!

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}

\captionsetup{%
font={sf,up},
labelfont={bf},
singlelinecheck=true,
justification=centerfirst,
labelformat=tabulab,
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
\midrule
\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 \\
\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
\midrule
\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 \\
\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!

• That is a seriously impressive first post on here. Show-off. :) – henry May 20 '15 at 12:33
• Thank you @henry! .. no show-off, I just wanted to attract @david's attention to it and that's why made it as proper as possible according to my limited knowledge. :) – Amar May 20 '15 at 13:49

Turns out that caption package version is not expecting \LTleft to be set to 0pt.

setting

\setlength\LTleft{0pt plus \textwidth}
\setlength\LTright{0pt plus \textwidth}


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)

• Thank you @david! I changed my code according to your suggestions and also removed the center environment and presto! All of that overfull-ness just disappeared! Thanks once again, you saved me from a lot of head scratching! :) – Amar May 20 '15 at 13:46