1

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}
  • Welcome to tex.SE. If you include code in your questions/answers, please format it as code (e.g. by using the {} button from the menu above the field where you enter your text. See the ? button at the right of that menu bar for more help on formatting your text using markdown. – ph0t0nix May 28 '16 at 15:08
3

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}
  • PS I've fixed up a couple of perceived typos, but there may be more corrections that ought to be applied. For instance, should diamètrem be changed to diamètre? – Mico May 28 '16 at 15:56
1

Latex does not automatically line break in tables. As your last column contains very long text elements, the resulting table is very wide. However you can force line breaks by using a column of a fixed width, e.g. p{4.2cm}.

\documentclass{article}

\begin{document}

\begin{center}
    \begin{tabular*}{\textwidth}{c @{\extracolsep{\fill}} ccp{4.2cm}}
        \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}

\end{document}

enter image description here

1

Very close to @Mico's solution. I kept the centred first three columns if you like themm, added some vertical padding between row with \extrarowheight , to differentiate rows from lines in multiline cells, and corrected some typos/missing accents:

    \documentclass[a4paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern}
\usepackage[showframe]{geometry}
\usepackage{ragged2e, array, tabularx, booktabs}
\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight\arraybackslash}m{#1}}

    \begin{document}

\begin{center}
\setlength\extrarowheight{3pt}
\begin{tabularx}{\linewidth}{ccc X}
 \multicolumn{4}{c}{\textbf{Tolérances d'ajustement}} \\[1ex]
 \toprule
Alésage & Arbre &Appariement & Raisons \\
 \midrule
Manivelle & Axe & & \\
Roulements & Axes & M7-js5 & Charges faibles et variables, petit diamètre 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 hélice & Fixation hélice & H7-js6 & incertain \\
Opercule & Axe bielle & H7-k6 & incertain \\
Palier & Goupille & M6-m6 & serrage léger \\
Engrenages & Axes & H7-p6\\
 \bottomrule
\end{tabularx}
\end{center}

    \end{document} 

enter image description here

  • I knew I'd missed a few typos... – Mico May 28 '16 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.