1

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}  
  • 3
    Welcome to TeX.SE! Please tell us how wide the margins of your document are. – Mico Jun 10 '18 at 18:39
  • 4
    please extend your code snippet to small but complete document. without knowing your page layout is almost impossible to help you. for sure your question is duplicate ... – Zarko Jun 10 '18 at 18:41
  • 5
    What is the purpose of the redundant \multicolumn{1}{|r|}? Do you know column type p, what about X columns of package tabularx? – Heiko Oberdiek Jun 10 '18 at 18:45
4

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}
  • Thank you very much, can you please recomend a book about latex? – adriano junior Jun 11 '18 at 18:02
  • @adrianojunior - You're most welcome! Do check out the posting What are good learning resources for a LaTeX beginner? For what it's worth, my favorite book for LaTeX beginners is George Grätzer's More Math into LaTeX, Springer, 5th ed. 2016. As the title indicates, a good chunk of the book is about typesetting mathematics with LaTeX. However, there's plenty of other material covered as well. In fact, I can pretty much guarantee that if you work diligently through the entire book, you'll be an accomplished and confident LaTeX user. :-) – Mico Jun 11 '18 at 19:53
3
  • automatic translation from excel to latex always gives awful result (you will not be always lucky that someone here redesign your such tables for you)
  • an alternative solution, which employ the packages rotating and makecell, to nice Mico answer can be:

enter image description here

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\usepackage{booktabs, makecell, tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

    \begin{document}
\begin{table}
\setlength\tabcolsep{3pt}
\settowidth\rotheadsize{Rugosidad}
\begin{tabularx}{\linewidth}{@{}
                             c
          >{\hsize=0.2\hsize}L
          >{\hsize=0.3\hsize}L
                             c
          >{\hsize=0.5\hsize}L
                             cc
                             @{}}
    \toprule
\rothead{N ref}
    &   \rothead{Nome da Superfície}
        &   \rothead{Destino da Superfície}
            &   \rothead{Quantidade}
                &   \rothead{Dimensões e precisão}
                    &   \rothead{Rugosidade Rz/Ra}
                        &   \rothead{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
            Perpendicularidade=0,2    & Rz20 & Ra20     \\
     \midrule
3   & Furo Central com rosca & Ligação com um tubo que transporta fluido & 1
        &   G2
            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{table}
\end{document}
  • Thank you, I use excel extensively, how do you recommend I translate the table? Or do you recommend I do it manually? – adriano junior Jun 11 '18 at 18:00
  • as you can see, as @Mico as me more or less completely rewrote your table code. conclusion i left to you. – Zarko Jun 11 '18 at 18:04

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.