[Tex/LaTex] How to auto adjust the last table column width, and why is there Underfull \vbox badness on this table

badnesserrorslongtablememoirtables

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}

enter image description here

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

  1. Autofit a table to the column width
  2. Automatically adjusting the size table cells
  3. Tabular with p type columns to fill page width
  4. p,m and b columns in tables
  5. https://en.wikibooks.org/wiki/LaTeX/Tables

Best Answer

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
\endfirsthead
\multicolumn{2}{c}{\tablename~\thetable}: Formatação do texto (continued)\\
\hline
\endhead
\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} 

enter image description here