1

I'm having an issue with this code

\begin{table}[H]
\begin{longtable}{| p{4cm} | p{2cm} | p{7cm} |}
    \hline
    \multicolumn{3}{| p{14cm} |}{\cellcolor{lightgray} \centering \textbf{Iniciar sesión}}
    \\\hline
    \cellcolor{lightgray} \centering \textbf{Descripción} & \multicolumn{2}{| p{9cm} |}{}
    \\\hline
    \cellcolor{lightgray} \centering \textbf{Actor} & \multicolumn{2}{| p{9cm} |}{}
    \\\hline
    \cellcolor{lightgray} \centering \textbf{Pre-condición} & \multicolumn{2}{| p{9cm} |}{}
    \\\hline
    \cellcolor{lightgray} & \centering \textbf{Paso} & \textbf{}
    \\\cline{2-3}
    \cellcolor{lightgray} \centering \multirow{-2}{*}{\textbf{Secuencia normal}} & \centering \textbf{1.} & 
    \\\hline
    \cellcolor{lightgray} \centering \textbf{Post-condición} & \multicolumn{2}{| p{9cm} |}{}
    \\\hline
    \cellcolor{lightgray} \centering \textbf{Excepciones} & \multicolumn{2}{| p{9cm} |}{}
    \\\hline
\end{longtable}
\end{table}

Table

As shown the vertical line of "Secuencia normal" box is thiner than the other ones that are above and below, does anyone know how to fix this?

  • you can not have a longtable inside a table delete the outer environment – David Carlisle Jun 24 '15 at 14:00
  • delete the | on the left pf every column except the first (otherwise you get two touching rules: to the right of one column and l;eft of the next) – David Carlisle Jun 24 '15 at 14:01
  • You may simplify you code, replacing the tabular preamble: {| p{4cm} | p{2cm} | p{7cm} |} with {|>{\columncolor{lightgray}} p{4cm} | p{2cm} | p{7cm} |}, and removing \cellcolor{lightgray} from all rows except the first. – Bernard Jun 24 '15 at 16:32
2

You were doubling some vertical rules inside the \multicolumns and this was giving you thicker rules:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{array}

\begin{document}

\begin{longtable}{| >{\centering}p{4cm} | p{2cm} | p{7cm} |}
    \hline
    \multicolumn{3}{| >{\centering}p{14cm} |}{\cellcolor{lightgray} \textbf{Iniciar sesión}}
    \\\hline
    \cellcolor{lightgray}  \textbf{Descripción} & \multicolumn{2}{ p{9cm} |}{}
    \\\hline
    \cellcolor{lightgray} \textbf{Actor} & \multicolumn{2}{ p{9cm} |}{}
    \\\hline
    \cellcolor{lightgray} \textbf{Pre-condición} & \multicolumn{2}{ p{9cm} |}{}
    \\\hline
    \cellcolor{lightgray} & \textbf{Paso} & \textbf{}
    \\\cline{2-3}
    \cellcolor{lightgray} \centering \multirow{-2}{*}{\textbf{Secuencia normal}} & \centering \textbf{1.} & 
    \\\hline
    \cellcolor{lightgray}  \textbf{Post-condición} & \multicolumn{2}{ p{9cm} |}{}
    \\\hline
    \cellcolor{lightgray} \textbf{Excepciones} & \multicolumn{2}{ p{9cm} |}{}
    \\\hline
\end{longtable}

\end{document}

enter image description here

Remarks

  • Don't use longtable inside table.

  • I used the >{...} syntax from the array package to add \centering to the first column.

  • The booktabs package can give you better looking tbales (with no vertical rules).

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.