1

enter image description here

I'm trying to create a table as shown in the attached picture. I declared the first row (or header) as multicolumn to get 2 columns and it works as expected. On the second row, I again declared multicolumn for both the columns so as to get 4 columns in all subsequent rows, but it doesn't work as expected. Can someone show me how to fix this? Thanks

   \documentclass{article}
 \begin{document}

    \begin{tabular}{ |c|c| } 
    \hline \multicolumn{2}{|c|}{Participation Factor Analysis} \\ 
    \hline \multicolumn{2}{|c|}{Modular}  & \multicolumn{2}{|c|}{SST} \\
     \hline lambda3 & lambda9  & lambda3 & lambda9 \\ 
    \hline val1 & val2 & val3 & val4 \\
    \hline 
    \end{tabular}

    \end{document}

Output

1 Answer 1

1

You're almost there: You simply need to (i) declare the tabular environment to have four rather than just two columns and (ii) use \multicolumn}{4}{|c|}{...} for the first header, as it needs to span all four columns.

\documentclass{article}
\begin{document}
\begin{tabular}{ |c|c|c|c| }
\hline 
\multicolumn{4}{|c|}{Participation Factor Analysis} \\
\hline 
\multicolumn{2}{|c|}{Modular}  & \multicolumn{2}{c|}{SST} \\
\hline 
lambda3 & lambda9  & lambda3 & lambda9 \\
\hline 
val1 & val2 & val3 & val4 \\
\hline
\end{tabular}
\end{document}
1
  • hi micro thank you very much. I was totally lost :)
    – linuxfan
    Jul 28, 2015 at 5:23

You must log in to answer this question.

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