[Tex/LaTex] How to set the width of a column using multirow command with tabularx, sidewaystable and longtable

longtablemultirowrotatingtablestabularx

I'd like to ask for a very big favor:
I need to do a long table (more than 1 page) which needs to be in 90 degrees (sidewaystable) and well, I need to stablish the width of the columns while using multirow.

At the moment I can only do multirow thingy and sidewaystable, but I need to modify the width of the columns, this problem comes when I use multirow See picture.

So, as you can see in picture 1, the text on the first column should be centered for the length of the 10 rows of the last column. It actually is, but I want it to say:

Combate de\\incendios\\forestales (look picture 2)

Then, the same thing happens with the second column, where "Evaluación del sector" happens to use more space than the one I need.

The other thing is that I also would like to set the width of the columns of "N", so it doesn't use that much of space…

And, the last thing, this is just 1/10 of the complete table, I mean, there are more than 100 rows in the "Peligro" column, and the first column "Combate de incendios forestales" goes in the center of all of them… So, I need to use the longtable package, which I tried, but it didn't work (It is very possible that I did not do it good, so if you can tell me where should I put the command..)

My code:

\begin{sidewaystable}
  \centering
  \caption{Add caption}
    \begin{tabularx}{\columnwidth}{p{1.5cm}p{2cm}cX}
    \toprule
    Procedimiento & Actividad & N     & Peligro \\
    \midrule
    \multicolumn{1}{c}{\multirow{10}[4]{*}{Combate de incendios forestales}} & \multicolumn{1}{c}{\multirow{5}[2]{*}{Evaluación del sector}} & \multicolumn{1}{c}{1} & No tomar en cuenta la información técnica o de la situación del incendio. \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{2} & No considerar la geografía del sector  \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{3} & Omitir algunas variables meteorológicas \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{4} & Que la información anterior no llegue en el momento necesario  \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{5} & La existencia de fallas en los sistemas de recepción de los datos anteriormente nombrados \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{\multirow{5}[2]{*}{Activar la alarma}} & \multicolumn{1}{c}{6} & Que no sea realmente una emergencia \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{7} & Que el personal no esté bien capacitados en cuanto al modo de actuar en una emergencia \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{8} & Que la alarma no funcione \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{9} & No tener redundancias en el sistema por si funciona solo en base a electricidad y se corta la luz \\
    \multicolumn{1}{c}{} & \multicolumn{1}{c}{} & \multicolumn{1}{c}{10} & No tener material disponible para ir a combatir el incendio \\
    \bottomrule

    \end{tabularx}%
  \label{tab:addlabel}%
\end{sidewaystable}

And.. the last thing so you can have a simple idea.. I'd like it to be just like:
See picture

Of course, with the LaTeX tables style, the lines in this picture are just to give you an idea…

Finally, I'm using TexMAKER on Windows 7.

Is out there anyone that can help me?

Id be very grateful!!!
Thanks!

Best Answer

Here is a solution, using the makecell package, which allows for line breaks in cells. I took the opportunity to simplify your code and automate the numbers in the third column. For a tabularx spreading across pages, I loaded the ltablex package, which brings the functionalities of long table to tabularx.

\documentclass[a4paper]{article}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}

\usepackage{geometry}

\usepackage{array, mathtools}
\usepackage{ltablex, multirow, makecell, booktabs, caption}
\usepackage{rotating}

\begin{document}

\begin{sidewaystable}
  \centering\newcounter{rowctr}\setcounter{rowctr}{0}
  \begin{tabularx}{\columnwidth}{cc >{\stepcounter{rowctr}\therowctr}cX}
    \caption{Add caption}\\
    \toprule
    Procedimiento & Actividad & \multicolumn{1}{c}{N} & Peligro \\
    \midrule
    \endfirsthead
    \multicolumn{4}{c}{\footnotesize Table \thetable\enspace (continued)}\\
    \toprule
    Procedimiento & Actividad & \multicolumn{1}{c}{N} & Peligro \\
    \midrule
    \endhead
    \bottomrule
    \multicolumn{4}{r}{\footnotesize To be continued}
    \endfoot
    \bottomrule
    \endlastfoot
    \multirowcell{10}{Combate de & & & \\ incendios \\forestales} & \multirowcell{5}{Evaluación \\ del sector} & & No tomar en cuenta la información técnica o de la situación del incendio. \\
                                 & & & No considerar la geografía del sector \\
                                 & & & Omitir algunas variables meteorológicas \\
                                 & & & Que la información anterior no llegue en el momento necesario \\
                                 & & & La existencia de fallas en los sistemas de recepción de los datos anteriormente nombrados \\
    \cmidrule{2-4}
                                 & \multirowcell{5}{Activar la & & \\ alarma} & & Que no sea realmente una emergencia \\
                                 & & & Que el personal no esté bien capacitados en cuanto al modo de actuar en una emergencia \\
                                 & & & Que la alarma no funcione \\
                                 & & & No tener redundancias en el sistema por si funciona solo en base a electricidad y se corta la luz \\
                                 & & & No tener material disponible para ir a combatir el incendio \\
    \bottomrule

  \end{tabularx}%
  \label{tab:addlabel}%
A\end{sidewaystable}

\end{document} 

enter image description here

As for your last request, the code can be modified to obtain what you want, but you can't use booktabs for that (vertical rules wouldn't cross horizontal rules), and it wouldn't look very professional…

Related Question