1

I want to create a table with one column in the first row, followed by 4 columns in the second row. I have attached the image of the desired table structure. The image does not show a vertical line in the last column of row 2. I need a vertical line in the final table. Below is the code from wiki Latex Tables. However, the table structure is not the same. How to get the desired table structure?

\usepackage{multirow}

\begin{tabular}{cc|c|c|c|c|l} \cline{3-6} 

& & \multicolumn{4}{ c| }{Primes} \\ \cline{3-6} 
& & 2 & 3 & 5 & 7 \\ \cline{1-6}
\multicolumn{1}{ |c  }{\multirow{2}{*}{Powers} } & 
\multicolumn{1}{> |c| }{504} & 3 & 2 & 0 & 1 &     \\ \cline{2-6} 
\multicolumn{1}{ |c }{} & 
\multicolumn{1}{ |c| }{540} & 2 & 3 & 1 & 0 &     \\ \cline{1-6} 
\multicolumn{1}{ |c  }{\multirow{2}{*}{Powers}} & 
\multicolumn{1}{ |c| }{gcd} & 2 & 2 & 0 & 0 & min \\ \cline{2-6}
\multicolumn{1}{ |c }{}                        & 
\multicolumn{1}{ |c| }{lcm} & 3 & 3 & 1 & 1 & max \\ \cline{1-6} 
\end{tabular}

enter image description here

  • What are all these \ multicolumn{1}{|c|}` for? – Bernard Feb 3 at 21:08
3

Unnecessarily complicated. Try this way:

mwe

\documentclass{article}
\begin{document}
\begin{tabular}{|l|l|l|l|}\cline{1-1}
    11 \\\hline
    21 & 22 & 23 & 24\\\hline
\end{tabular}
\end{document}
| improve this answer | |
  • Thanks Fran. The catch is \cline{1-1}. Otherwise, it's a four-column table. – Tripti Agrawal Feb 3 at 21:13
  • 2
    @TriptiAgrawal The "trick" is also make only one cell in the first row, i.e. without add any &. The \cline only control the width of the first horizontal line, but not the vertical lines. – Fran Feb 3 at 21:19
  • Ok, Fran. I got it. – Tripti Agrawal Feb 3 at 21:30

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.