博弈论表格排列

博弈论表格排列

我正在尝试组织一个表格,但是我无法让它看起来像我想要的那样。我希望所有内容都用线包裹起来,直到标签 Player 1 和 Player 2。以下是我写的内容:

\begin{center}
\begin{tabular}{ccc|c|c|c|}
      & \multicolumn{1}{c}{\omega_1} 
      & \multicolumn{2}{c}{\color{blue}Player 2}\\
      & \multicolumn{1}{c}{} 
      & \multicolumn{1}{c}{$p$}
      & \multicolumn{1}{c}{$1-p$}\\
      \cline{3-4} 
      & \multicolumn{1}{c}{} 
      & \multicolumn{1}{c}{$a_2$}  
      & \multicolumn{1}{c}{$b_2$} \\
        \cline{3-4} 
      \multirow{2}*{\color{red}Player 1}
      \multirow{1}*{q}
      \multirow{2}*{1-q}
        & $a_1$ 
             & $\textbf{(\color{red}{0}\color{black},\color{blue}{0}\color{black})}$ 
             & $(\color{red}{6}\color{black},\color{blue}{-3}\color{black})$ \\
            \cline{3-4}
        & $b_1$ 
              & $(\color{red}{-3} \color{black},\color{blue}{6}\color{black})$ 
              & $(\color{red}{5} \color{black},\color{blue}{5}\color{black})$ \\
        \cline{3-4}
    \end{tabular}
\end{center}

在这方面,我也需要在 a_1 和 a_2 标签前面加上标签 q 和 1-q,就像组织 p 和 1-p 一样。

组织好这些之后,我需要做一个概率树,在分支上标记概率值,然后在两端显示两个表(假设两个相同的表,p=1/2)

**编辑:根据要求,这是我的代码的完整示例:

\documentclass[12pt, a4 paper]{article}

          \usepackage{multicol} %Needed for \PDgame
          \usepackage{multirow}
          \usepackage{wrapfig}
          \usepackage{tabu}
          \usepackage{mathtools}
          \usepackage{graphicx}
          \usepackage[english]{babel}
          \usepackage[utf8]{inputenc}
          \usepackage{amsmath,amssymb}
          \usepackage{parskip}
          \usepackage{graphicx}
          \usepackage{tabu}
          \usepackage{mathtools}
          \usepackage{graphicx}
          \usepackage{verbatim}
          \usepackage{subcaption}
          \usepackage{indentfirst}
          % Margins
         \usepackage[inner=2.0cm,outer=2.0cm,top=2.5cm,bottom=2.5cm]{geometry}
          % Colour table cells
          \usepackage[table]{xcolor}
          % Get larger line spacing in table
          \newcommand{\tablespace}{\\[1.25mm]}
          \newcommand\Tstrut{\rule{0pt}{2.6ex}}         % = `top' strut
          \newcommand\tstrut{\rule{0pt}{2.0ex}}         % = `top' strut
          \newcommand\Bstrut{\rule[-0.9ex]{0pt}{0pt}}   % = `bottom' strut


           \setlength{\marginparwidth}{2cm}
           \begin{document}
           \begin{center}
           \begin{tabular}{cc|c|c|}
           & \multicolumn{1}{c}{$\omega_1$} 
           & \multicolumn{2}{c}{\color{blue}Player 2}\\
           & \multicolumn{1}{c}{} 
           & \multicolumn{1}{c}{$a_2$}  
           & \multicolumn{1}{c}{$b_2$} \\
           \cline{3-4} 
           \multirow{2}*{\color{red}Player 1}  
           & $a_1$ 
           & $\textbf{(\color{red}{0}\color{black},\color{blue} 
           {0}\color{black})}$ 
           & $(\color{red}{6}\color{black},\color{blue}{-3}\color{black})$ \\
           \cline{3-4}
           & $b_1$ 
           & $(\color{red}{-3} \color{black},\color{blue}{6}\color{black})$ 
           & $(\color{red}{5} \color{black},\color{blue}{5}\color{black})$ \\
           \cline{3-4}
           \end{tabular}
           \end{center}


            \begin{center}
            \begin{tabular}{ccc|c|c|c|}
  & \multicolumn{1}{c}{$\omega_1$} 
  & \multicolumn{2}{c}{\color{blue}Player 2}\\
  & \multicolumn{1}{c}{} 
  & \multicolumn{1}{c}{$p$}
  & \multicolumn{1}{c}{$1-p$}\\
  \cline{3-4} 
  & \multicolumn{1}{c}{} 
  & \multicolumn{1}{c}{$a_2$}  
  & \multicolumn{1}{c}{$b_2$} \\
    \cline{3-4} 
  \multirow{2}*{\color{red}Player 1}
  \multirow{1}*{q}
  \multirow{2}*{1-q}
    & $a_1$ 
         & $\textbf{(\color{red}{0}\color{black},\color{blue}{0}\color{black})}$ 
         & $(\color{red}{6}\color{black},\color{blue}{-3}\color{black})$ \\
        \cline{3-4}
    & $b_1$ 
          & $(\color{red}{-3} \color{black},\color{blue}{6}\color{black})$ 
          & $(\color{red}{5} \color{black},\color{blue}{5}\color{black})$ \\
    \cline{3-4}
\end{tabular}
\end{center}



\end{document}

答案1

{NiceTabular}这是使用 来制作该表的一种方法nicematrix。我不确定是否完全理解了您想要的规则。

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}

\begin{NiceTabular}{ccccc}
 & & & \Block{1-2}{\color{blue}Player 2} \\
 & & & $p$ & $1-p$ \\
 & & & $a_2$ & $b_2$ \\
\Block{2-1}{\color{red}Player 1} 
& $q$ & $a_1$ & $({\color{red}0},{\color{blue}0})$ & $({\color{red}6},{\color{blue}-3})$ \\
& $1-q$ & $b_1$ & $({\color{red}-3},{\color{blue}6})$ & $({\color{red}5},{\color{blue}5})$ 
\CodeAfter
\tikz \foreach \x in {3,...,6} { \draw (\x-|3) -- (\x-|6) (3-|\x) -- (6-|\x) ; } ;
\end{NiceTabular}


\end{document}

您需要多次编译(因为nicematrix使用 PGF/Tikz 节点)。

上述代码的输出

答案2

这只是对代码进行稍微修复的一个版本,没有使用 TikZ;输出在视觉上与 F. Pantigny 的答案非常相似:

\documentclass{article}
\usepackage{xcolor}
\usepackage{multirow}
\begin{document}
    \begin{center}
        \begin{tabular}{cc|c|c|c|}
            & \multicolumn2c{} & \multicolumn2c{\color{blue}Player 2} \\
            & \multicolumn2c{} & \multicolumn1c{$p$} & \multicolumn1c{$1-p$} \\
            \cline{3-5}
            &&& $a_2$ & $b_2$ \\
            \cline{3-5}
            \multirow2*{\color{red}Player 1} &$q$ & $a_1$
            & $\textbf{(\color{red}{0}\color{black}, \color{blue}{0}\color{black})}$ 
            & $(\color{red}{6}\color{black}, \color{blue}{-3}\color{black})$ \\
            \cline{3-5}
            & $1 - q$ & $b_1$ 
            & $(\color{red}{-3} \color{black}, \color{blue}{6}\color{black})$ 
            & $(\color{red}{5} \color{black}, \color{blue}{5}\color{black})$ \\
            \cline{3-5}
        \end{tabular}
    \end{center}
\end{document}

相关内容