# How to auto adjust my last table column width, and why is there Underfull \vbox badness on this table?

Currently the table is throwing this warning, but I have no idea from where it is coming from:

\documentclass[
10pt,
a5paper,
twoside
]{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{ragged2e}
\usepackage{longtable}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.3pt}

\begin{document}
\frenchspacing

\begin{longtable}[!ht]{ | >{\RaggedRight}p{3cm} | p{5.5cm} | }

\hline
Tamanho da fonte & 10,5 para o texto incluindo os títulos das seções e subseções.
As citações com mais de três linhas as legendas das ilustrações
e tabelas, fonte 9,5. \\ \hline

\caption{Formatação do texto}
\label{tab:table}

\end{longtable}

\end{document}


test2.tex: Underfull \vbox (badness 10000) detected at line 95


The line 95 is \end{longtable}. Also I tried to remove the p{5.5cm} so the table last column width is automatically determined, but not the first column which must be p{3cm}. But if I do only | >{\RaggedRight}p{3cm} | p | it throws the error:

test2.tex:88: Missing number, treated as zero. [Tamanho da fonte& 1]
test2.tex:88: Illegal unit of measure (pt inserted). [Tamanho da fonte& 1]


# Related

• unrelated to the warning but [!ht] is incorrect input to longtable, the only allowed options are [l], [c] or [r] – David Carlisle Aug 19 '17 at 19:18

I suppose you want your table to be exactly full text width. You can do that with the ltablex package, which brings the longtable functionalities (and syntax) of longtable to tabularx.

I took the liberty to place the caption above the table: if table captions are usually placed above tables, it is to spare readers from having to skim through pages to find what it's all about. Furthermore, in long tables (which are not floats, by the way, so the option [!ht] is meaningless), the caption is called from within the table, in the first head code.

\documentclass[
10pt,
a5paper,
twoside
]{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage{ragged2e}
\usepackage{ltablex}
\keepXColumns
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.3pt}

\begin{document}
\frenchspacing
\setlength\extrarowheight{2pt}
\begin{tabularx}{\linewidth}{|>{\RaggedRight}p{3cm}|>{\arraybackslash}X|}
\caption{Formatação do texto}
\label{tab:table} \\
\hline
\multicolumn{2}{c}{\tablename~\thetable}: Formatação do texto (continued)\\
\hline
\hline
\multicolumn{2}{r}{\footnotesize to be continued}
\endfoot
\hline
\endlastfoot
Tamanho da fonte & 10,5 para o texto incluindo os títulos das seções e subseções.
As citações com mais de três linhas as legendas das ilustrações
e tabelas, fonte 9,5.
\end{tabularx}

\end{document}


• Thanks! You are right with table full text width. Also, there is not warning with your version. – user Aug 19 '17 at 19:04
• I checked before posting! I think the reason for the warning was your placing the caption as in ordinary tables. Long table requires a special syntax. – Bernard Aug 19 '17 at 19:26
• Why using the \setlength\extrarowheight{2pt} option or \keepXColumns on the global? – user Aug 22 '17 at 21:44
• Because the default vertical spacing is much too tight. \keepXColumns is here because most people want X columns to have their calculated width, as far as I know. In yhe present case, it doesn't change whatever to the layout. – Bernard Aug 22 '17 at 21:55
• Big thanks! This table is pretty awesome! Today I spent several hours trying different longtables implementations but the only one which worked very well with no warnings/badboxes at all was yours! – user Aug 23 '17 at 0:40