1

I'm new to Latex and, in order to make a table, I'm using the CTAN Excel to Latex package. The generated code is as follows:

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{rcccccc}
    \toprule
    \multicolumn{1}{c}{Local} & Tipo de Lâmpada & Tipo de Luminária & Quantidade & P\_lamp (W) & Equipamentos auxiliares & Comando \\
    \midrule
    \multicolumn{1}{l}{Armazém de Fio e Malha} & VMAP  & Para lâmpada de descarga & 8     & 250   & B+C   & I \\
    \multicolumn{1}{l}{Armazém de Malha - Armazém Principal} & FT (T8) & Industriais salientes, com abas refletoras & 29    & 58    & A+B+C & I \\
    \multicolumn{1}{l}{Cantina} & FT (T8) & Saliente e estanque & 12    & 58    & A+B+C & I+CL \\
    \multicolumn{1}{l}{Confeção} & FT (T8) & Industriais suspensas, com abas refletoras & 203   & 58    & A+B+C & I \\
    \multicolumn{1}{l}{Gabinetes} & FT (T8) & De encastrar & 68    & 18    & A+B+C & CL \\
    \multicolumn{1}{l}{Laboratório Físico-Químico} & FT (T8) & De encastrar & 120   & 18    & A+B+C & I+CL \\
    \multicolumn{1}{l}{Preparação de malha crua} & VMAP  & Para lâmpada de descarga & 17    & 250   & B+C   & I \\
    \multicolumn{1}{l}{Tinturaria} & VMAP  & Para lâmpada de descarga (suspensas) & 61    & 250   & B+C   & I \\
    \multicolumn{1}{l}{Tricotagem Nova} & VMAP  & Para lâmpada de descarga & 27    & 250   & B+C   & I \\
    \multicolumn{1}{l}{Tricotagem Velha} & FT (T8) & Industriais salientes, com abas refletoras & 22    & 58    & A+B+C & I+CL+CE \\
    \bottomrule
    \end{tabular}
  \label{tab:addlabel}
\end{table}

And the result is this:

enter image description here

As you can see, it exceeds the page width. I read something about using the tabularx package. I already added it to the preamble but everything stays the same! Could someone please help me? Thank you in advance!

1 Answer 1

1

Instead of using a tabular environment, I would like to suggest you use a tabularx environment, and column types that automatically wrap the contents of "long" cells.

enter image description here

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set text block parameters

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[portuguese]{babel}

\usepackage{tabularx,booktabs,ragged2e,caption}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\newcolumntype{C}{>{\Centering\arraybackslash}X}

\begin{document}

\begin{table}

  \caption{Add caption}
    \begin{tabularx}{\textwidth}{@{} L CC cc C c @{}}
    \toprule
    Local & Tipo de Lâmpada & Tipo de Luminária & Quantidade & P\_lamp (W) & Equipamentos auxiliares & Comando \\
    \midrule
     Armazém de Fio e Malha & VMAP  & Para lâmpada de descarga & 8     & 250   & B+C   & I \\
     Armazém de Malha--Armazém Principal & FT (T8) & Industriais salientes, com abas refletoras & 29    & 58    & A+B+C & I \\
     Cantina & FT (T8) & Saliente e estanque & 12    & 58    & A+B+C & I+CL \\
     Confeção & FT (T8) & Industriais suspensas, com abas refletoras & 203   & 58    & A+B+C & I \\
     Gabinetes & FT (T8) & De encastrar & 68    & 18    & A+B+C & CL \\
     Laboratório Físico-Químico & FT (T8) & De encastrar & 120   & 18    & A+B+C & I+CL \\
     Preparação de malha crua & VMAP  & Para lâmpada de descarga & 17    & 250   & B+C   & I \\
     Tinturaria & VMAP  & Para lâmpada de descarga (suspensas) & 61    & 250   & B+C   & I \\
     Tricotagem Nova & VMAP  & Para lâmpada de descarga & 27    & 250   & B+C   & I \\
     Tricotagem Velha & FT (T8) & Industriais salientes, com abas refletoras & 22    & 58    & A+B+C & I+CL+CE \\
    \bottomrule
    \end{tabularx}
  \label{tab:addlabel}
\end{table}
\end{document}
1
  • That is exactly what I was looking for! But now I understand that it does not look as perceptible as I would want it to be. I'm going to have to rethink the table structure and figure out another way to show what I want. Thank you very much!
    – João Lima
    May 20, 2015 at 14:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .