TransWikia.com

Naming row and column in table

TeX - LaTeX Asked by DurgaDatta on June 3, 2021

I want to create the table like this (with row and column each names individually and also in a group):
enter image description here
I can create the table, but I do not know how to write those column and row names. How can I selectively remove the vertical line on table in some cells?

2 Answers

You can use multicolumn{1}{|c|}{($-1,C$)} to selectively remove/add vertical lines. Also, to merge two rows in a cell, you can use multirow.

documentclass{article}
usepackage{multirow}
begin{document}
begin{tabular}{*4c}
& &multicolumn{2}{c}{$p_{2}$}
& & $F$ &$D$ cline{3-4}
multirow{2}{*}{$p_{1}$}& $F$ & multicolumn{1}{|c|}{($1-C$,$1-C$)} & multicolumn{1}{c|}{($-C,1$)} cline{3-4}
& $D$ & multicolumn{1}{|c|}{($-1,C$)} &multicolumn{1}{c|}{($0,0$)}cline{3-4}
end{tabular}

end{document}

enter image description here

Correct answer by user11232 on June 3, 2021

With {NiceArray} of nicematrix.

documentclass{article}
usepackage{nicematrix}

begin{document}
NiceMatrixOptions{exterior-arraycolsep,cell-space-limits=3pt}
$begin{NiceArray}{cccc}
                   &   & Block{1-2}{p_2} 
                   &   & F         & D 
Block{2-1}{p_1} & F & Block[hvlines]{2-2}{}
                         (1-C,1-C) & (-C,1)  
                   & D & (-1,C)    & (0,0) 
end{NiceArray}$
end{document}

Output of the above code

Answered by F. Pantigny on June 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP