1

I am currently using Martin J. Osborne's package sgame to draw some matrix form games. However, I have a problem: I cannot center the matrices properly when adding extra rows to the matrix. The next picture shows that, when using \hbox to add an extra row, the centering is bad because LaTex seems not to consider the extra row given by \hbox (when \hbox is not used, the centering is correct). Therefore, the centering of the second matrix is ugly:

enter image description here

This is a MWE that reproduces this behaviour.

\documentclass[a4paper]{report}

\usepackage{amsmath, mathtools, amsthm}
\usepackage{sgame}

\renewcommand{\gamestretch}{1.5}
\gamemathtrue
\def\hangUnder#1{\hbox to 0pt {\raisebox{-5mm}[0pt][0pt]{#1}}}
\irpawcgltrue
\irplwcgltrue

\begin{document}


\begin{figure}[!htb]
\centering
\begin{game}{2}{2}[Player 1][Player 2]
  & $L$ & $R$\\
$H$ & 0,1 & 0,0\\
$L$ & 0,0 & 0,1
\end{game}
\medskip
\caption{Matching Pennies}\label{MPS6}
\end{figure}

\begin{figure}[!htb]
\centering
\begin{game}{2}{2}[Player 1][Player 2]
  & $L$ & $R$\\
$U$ & 0,1 & 0,0\hbox to 0pt{\hspace{7pt} $p$}\\
$D$ & 0,0\hangUnder{\hspace{-13pt}$q$} & 0,1\hangUnder{\hspace{-20pt}$1-q$} \hbox to 0pt{\hspace{7pt} $1-p$}
\end{game}
\medskip
\caption{Matching Pennies}\label{MPS3}
\end{figure}

\end{document}

What I would like is that the hboxes are considered when computing the horizontal center of the figure. Analogously, using \hangunder reduces the space between the figure and the caption unless I manually add some arbitrary vertical space with \vspace. I would like \hangunder to be considered when doing the computations, to avoid manually adding a vertical space. Thank you all! :)

  • 1
    \hbox isn't a command supported in latex documents use \makebox[0pt][l]{...} to make a 0 width box – David Carlisle Dec 8 '16 at 16:54
  • Thank you; I never understood what it means to be supported or not; but I'll keep your advise in mind and I'll change the hboxes. Though useful, your suggestion does not solve my question. – Héctor Dec 8 '16 at 16:57
  • well in this case I just mean that \hbox not being centred by \centering and similar latex constructs is by design – David Carlisle Dec 8 '16 at 17:37
  • Oh, I see. Thanks for your explanation. However, \makebox does not seem to do the trick I need. :'( – Héctor Dec 8 '16 at 17:58
1

You could consider just setting these constructions using a regular tabular:

enter image description here

\documentclass{article}

\begin{document}

\begin{figure}
  \centering
  \renewcommand{\arraystretch}{1.5}%

  \begin{tabular}{ r @{} c | c | c | }
    & \multicolumn{1}{c}{} & \multicolumn{2}{c}{Player 2} \\
    & \multicolumn{1}{c}{} & \multicolumn{1}{c}{$L$} & \multicolumn{1}{c}{$R$} \\
    \cline{3-4}
    & $H$ & 0,1 & 0,0 \\
    \cline{3-4}
    \raisebox{\arraystretch\dimexpr.5\normalbaselineskip}[0pt][0pt]{Player 1~} & $L$ & 0,0 & 0,1 \\
    \cline{3-4}
  \end{tabular}

  \caption{Matching pennies}

  \bigskip

  \begin{tabular}{ r @{} c | c | c | l }
    & \multicolumn{1}{c}{} & \multicolumn{2}{c}{Player 2} \\
    & \multicolumn{1}{c}{} & \multicolumn{1}{c}{$L$} & \multicolumn{1}{c}{$R$} \\
    \cline{3-4}
    & $H$ & 0,1 & 0,0 & $p$ \\
    \cline{3-4}
    \raisebox{\arraystretch\dimexpr.5\normalbaselineskip}[0pt][0pt]{Player 1~} & $L$ & 0,0 & 0,1 & $1-p$ \\
    \cline{3-4}
    \multicolumn{2}{c}{} & \multicolumn{1}{c}{$q$} & \multicolumn{1}{c}{\makebox[0pt]{$1-q$}}
  \end{tabular}

  \caption{Matching loonies}

\end{figure}

\end{document}
  • After waiting for a week; and given the absence of new replies, I accept yours as the best one (since it generates the desired output). However, I have chosen to keep the bad alignment to stick to the package I am using and not having to use tikz. – Héctor Dec 16 '16 at 17:27

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.