[Tex/LaTex] latex table too wide

tables

I'm new to Latex and that makes it hard to understand some of the code previously posted here. My table won't fit my a4 paper, because well, I don't know how to tell it to do so. I've tried using \begin{adustbox}... and although it does the job of keeping the table withing the margins it also decreases the size of the font to the point of it being almost impossible to read.
The table was generated through an excel add-in.

\begin{tabular}{|r|r|r|r|r|r|r|}
\hline
     N ref & Nome da Superfície & Destino da Superfície & Quantidade & Dimensões e precisão & Rugosidade Rz/Ra & Série Norma Ra \\
\hline
\multicolumn{ 1}{|r|}{1} & \multicolumn{ 1}{|r|}{Base} & \multicolumn{ 1}{|r|}{Superfície de encoste} & \multicolumn{ 1}{|r|}{1} &     140h12 & \multicolumn{ 1}{|r|}{Rz 20} & \multicolumn{ 1}{|r|}{Ra20} \\

\multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & Planicidade= 0,3 mm & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} \\
\hline
\multicolumn{ 1}{|r|}{2} & \multicolumn{ 1}{|r|}{Furos externos} & \multicolumn{ 1}{|r|}{Fixação usando parafusos} & \multicolumn{ 1}{|r|}{2} &   D=14 H14 & \multicolumn{ 1}{|r|}{Rz20} & \multicolumn{ 1}{|r|}{Ra20} \\

\multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & Perpendicularidade=0,2 & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} \\

\multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} &            & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} \\
\hline
\multicolumn{ 1}{|r|}{3} & \multicolumn{ 1}{|r|}{Furo Central com rosca} & \multicolumn{ 1}{|r|}{Ligação com um tubo que transporta fluido} & \multicolumn{ 1}{|r|}{1} &        G2  & \multicolumn{ 1}{|r|}{-} & \multicolumn{ 1}{|r|}{} \\

\multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & Dexterno = 59,614  & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} \\

\multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & Dinterno =56,856 & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} \\

\multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} &  P = 2,309 & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} \\

\multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & Fios por polegada = 11 & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} \\

\multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} &            & \multicolumn{ 1}{|r|}{} & \multicolumn{ 1}{|r|}{} \\
\hline
         4 & Chanfro do furo Central 2x45 & Facilitar a entrada do tubo, eliminar arresta agudas &          1 & 2 mm x 45o &          - &       Ra10 \\
\hline
\end{tabular}  

Best Answer

Some comments and observations:

  • All those \multicolumn{1}{|r|}{...} "wrappers" seem quite unnecessary, especially as you've set the 7 columns to be of type r ("right aligned").

  • Second, the r column type doesn't allow line breaks in the cells, and that's why the tabular environment is massively too wide. To allow automatic line-breaking, I suggest you change to a tabularx environment, as is shown in code below.

  • Do give the table a more open "look" by getting rid of all vertical lines. Trust me, they're not needed, and they won't be missed.

  • Finally, consider centering the cell contents instead of typesetting the flushright (aka raggedleft).

enter image description here

\documentclass[a4paper]{article}
\usepackage[portuguese]{babel} % is this right?
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tabularx,ragged2e,booktabs}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}
\begin{document}

\noindent% <-- important
\setlength\tabcolsep{3pt} % default: 6pt
\begin{tabularx}{\textwidth}{@{} l *{6}{C} @{}}
\toprule
N ref & Nome da Superfície & Destino da Superfície & Quantidade & Dimensões e precisão & Rugosidade Rz/Ra & Série Norma Ra \\
\midrule
1 & Base & Superfície de encoste & 1 
& 140h12; \newline Planicidade = 0,3 mm 
& Rz 20 & Ra20 \\
\midrule
2 & Furos externos & Fixação usando parafusos & 2 &   D=14\,H14; \newline Perpendi\-cularidade = 0,2 & Rz20 & Ra20 \\
\midrule
3 & Furo Central com rosca & Ligação com um tubo que transporta fluido & 1 
& G2 \newline Dexterno = 59,614; \newline Dinterno = 56,856; \newline P = 2,309; \newline Fios por polegada = 11  & -- &  \\
\midrule
4 & Chanfro do furo Central 2x45 & Facilitar a entrada do tubo, eliminar arresta agudas & 1 & 2\,mm x 45o &  -- &  Ra10 \\
\bottomrule
\end{tabularx} 
\end{document}
Related Question