0

Hello i am an absolute Latex beginner and need help creating a payoff matrix with three values in each cell orderd in a diagonal. I tried with the tikz package, but it didn't work. Can someone help me please? enter image description here

2

You certainly can do that with TikZ but here is no need for it. (EDIT: Fixed spacing, big thanks to @Troy!)

\documentclass{article}
\usepackage{array,graphicx,multirow}
\begin{document}
\begin{tabular}{*2{@{\,}r@{\,}}|c|c|}
\multicolumn{2}{c}{}& \multicolumn{2}{c}{Player 1}\\
\multicolumn{2}{c}{}& \multicolumn{1}{l}{A} & \multicolumn{1}{r}{B}\\
\cline{3-4}
\multirow{2}{*}{\rotatebox[origin = r]{90}{Player 2}}
& B &\begin{tabular}{*3{@{}c@{}}}
& & 4\\
& (3) & \\
1 & & 
\end{tabular} & 
\begin{tabular}{*3{@{}c@{}}}
& & 5\\
& (1) & \\
2 & & 
\end{tabular}\\
\cline{3-4}
& A &\begin{tabular}{*3{@{}c@{}}}
& & 6\\
& (5) & \\
1 & & 
\end{tabular} & 
\begin{tabular}{*3{@{}c@{}}}
& & 2\\
& (3) & \\
2 & & 
\end{tabular}\\
\cline{3-4}
\end{tabular}
\end{document}

enter image description here

Just for completeness: a TikZ version. For this purpose, it is IMHO overkill, but if you intend adding features that might be the better choice.

\documentclass{article}
\usepackage{tikz,array}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}
    \matrix (mat) [matrix of nodes,ampersand replacement=\&,nodes={draw,inner sep=4pt},
    column sep=-\pgflinewidth,row sep=-\pgflinewidth]{
       {\begin{tabular}{*3{@{}c@{}}}
& & 4\\
& (3) & \\
1 & & 
\end{tabular}} \& {\begin{tabular}{*3{@{}c@{}}}
& & 5\\
& (1) & \\
2 & & 
\end{tabular}} \\
       {\begin{tabular}{*3{@{}c@{}}}
& & 6\\
& (5) & \\
1 & & 
\end{tabular}} \& {\begin{tabular}{*3{@{}c@{}}}
& & 2\\
& (3) & \\
2 & & 
\end{tabular}} \\
     };
\node [above=1pt of mat-1-1.north west,anchor=south west] (A1) {A};
\node [above=1pt of mat-1-2.north east,anchor=south east] (B1) {B};
\node [left=1pt of mat-1-1,anchor=east] (A2) {A};
\node [left=1pt of mat-2-1,anchor=east] (B2) {B};
\path ([yshift=4pt]A1.north) -- ([yshift=4pt]B1.north) node[midway]{Player 1};
\path ([xshift=-4pt]B2.west) -- ([xshift=-4pt]A2.west) node[midway,rotate=90]{Player 2};
\end{tikzpicture}
\end{document}

enter image description here

2

with tabular and defining new command which set main cells content:

\documentclass{article}
\usepackage{graphicx}
\usepackage{array,cellspace,multirow}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\newcommand\mc[3]{\hfill #1\par          % cell's content at top right
                       (#2)\par          % cell's content on the midle
                         #3\hfill\mbox{}}% cell's content at bottom left

\begin{document}
\begin{tabular}{cc | *{2}{>{\centering\arraybackslash}S{m{12mm}}|}}
\multicolumn{2}{c}{}    &   \multicolumn{2}{c}{Player 1}    \\
\multicolumn{2}{c}{}    &   \multicolumn{1}{c}{A}
                        &   \multicolumn{1}{c}{B}           \\
    \cline{3-4}
\multirow{4}{*}{\rotatebox[origin = c]{90}{Player 2}}
    &   A   &   \mc{4}{3}{1}    &   \mc{5}{1}{2}            \\
    \cline{3-4}
    &   B   &   \mc{6}{5}{1}    &   \mc{2}{3}{2}            \\
    \cline{3-4}
\end{tabular}
\end{document}

enter image description here

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.