0

I want to generate a table with fixed column width even though every line of it has \multicolumn.

I have seen this solution but it's not suitable for my needs since I need to be able to control each cell's border.

MWE:

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{*{2}{p{1cm}}*{2}{p{2cm}}}
&
&\multicolumn{2}{c}{strong}\\
&
&\multicolumn{1}{c}{work and steal}
&\multicolumn{1}{c}{work}\\
\cline{3-4}
\multirow{2}*{weak} 
&\multicolumn{1}{c|}{work}
&\multicolumn{1}{c|}{(x,y)} 
&\multicolumn{1}{c|}{(x,y)}\\
\cline{3-4}
&\multicolumn{1}{c|}{rest}
&\multicolumn{1}{c|}{(x,y)} 
&\multicolumn{1}{c|}{(x,y)}\\
\cline{3-4}
\end{tabular}
\end{document}

enter image description here

  • Why all those \multicolumns? – Bernard Feb 11 at 20:07
  • What should happen to "work and steal"? This is wider than 2cm. – leandriis Feb 11 at 20:08
  • Probably you are more satisfied with &work and steal &work\\ instead fo your current 2 multicolumns. If you insist on using the multicolumn commands, although I can't see any reason why, you can use &\multicolumn{1}{p{2cm}}{work and steal} &\multicolumn{1}{p{2cm}}{work}\\ . – leandriis Feb 11 at 20:09
  • 1
    Not all of the multicolumn commands are needed to expicitly control the borders of the table. Especially not the ones in the second row. – leandriis Feb 11 at 20:11
  • 2
    you are completely removing the p specification and replacing it by c so the column width is not specified. if you need multicolumn (which seems unlikely) use p again not c. a p column entry is a parbox so you can use \centering to center, or for a fixed width c column use array package and wc{2cm} – David Carlisle Feb 11 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.