[Tex/LaTex] Table : Overfull hbox

tables

When I compile the following code, I get the error overfull hbox and I cannot see the right end of the table. Does anyone know how to fix it ?

\begin{center}
\begin{tabular*}{\textwidth}{c @{\extracolsep{\fill}} ccc}
 \multicolumn{4}{c}{\textbf{Tolérances d'ajustement}} \\
 \hline
Alésage & Arbre &Appariement & Raisons\\
 \hline
Manivelle&Axe&&\\
Roulements&Axes& M7 - js5&Charges faibles et variables, petit diamètrem bague exterieure ne coulisse pas, logement en une pièce\\
Cloches&Roulements&H7 - p6&Transmission de petits couples sans sécurité supplémentaire\\
Bielle&Coussinet&H7 - p6&\\
Coussinet&Axes bielle &IT7 - f7&\\
Palier & Tourillon&H7-p6&\\
Palier&Maneton&H7 - p6&\\
Plateau&pales & H8 - h7& Jeu pour colle\\
Pied helice&Fixation helice&H7 - js6& incertain\\
Opercule& Axe bielle& H7 - k6&  incertain  \\
Palier & Goupille &M6 - m6& serrage leger\\
Engrenages&Axes&H7 - p6&\\

 \hline
\end{tabular*}
\end{center}

Best Answer

Material in a column of type c does not get line-broken automatically. Thus, even though you've set \textwidth as the first argument of the tabular* environment, there's no guarantee that the combined width of the four columns won't, in fact, exceed \textwidth. That's what's happening in your code.

Instead of using a tabular* environment, I suggest you use a tabularx environment, with an overall width of \textwidth and with a modified form of the X column type for the final column. The specific modification used in the code below typesets the column material ragged-right while still permitting hyphenation.

Some additional suggestions:

  • Use the macros of the booktabs package -- specifically, \toprule, \midrule, and \bottomrule -- instead of the basic \hline instruction.

  • Use l instead of c as the column type for the first three columns.

  • Load the caption package and apply some extra mark-up to distinguish more clearly what the logical parts of the table are (caption vs. body).

enter image description here

\documentclass{article}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tabularx,ragged2e,booktabs,caption}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X} % modified 'X' column type
\begin{document}

\begin{table}[ht!]
\captionsetup{font=bf,skip=0.5\baselineskip}
\caption*{Tolérances d'ajustement}
\begin{tabularx}{\textwidth}{@{}lllL@{}}
\toprule
Alésage & Arbre &Appariement & Raisons\\
\midrule
Manivelle&Axe&&\\
Roulements&Axes& M7 - js5&Charges faibles et variables, petit diamètrem bague extérieure ne coulisse pas, logement en une pièce\\
Cloches&Roulements&H7 - p6&Transmission de petits couples sans sécurité supplémentaire\\
Bielle&Coussinet&H7 - p6&\\
Coussinet&Axes bielle &IT7 - f7&\\
Palier & Tourillon&H7 - p6&\\
Palier&Maneton&H7 - p6&\\
Plateau&pales & H8 - h7& Jeu pour colle\\
Pied helice&Fixation helice&H7 - js6& incertain\\
Opercule& Axe bielle& H7 - k6&  incertain  \\
Palier & Goupille &M6 - m6& serrage léger\\
Engrenages&Axes&H7 - p6&\\
\bottomrule
\end{tabularx}
\end{table}

\end{document}
Related Question