我真的很想将单元格内容垂直居中,但我不知道该怎么做。有人能帮我吗?谢谢!
\documentclass[a4paper, fontsize=11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[onehalfspacing]{setspace}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{multirow,array}
\usepackage{arydshln}
\begin{document}\begin{table}
\setlength{\extrarowheight}{10pt}
\begin{tabular}{*{5}{c|}}
\multicolumn{2}{c}{} & \multicolumn{3}{c}{Spieler $2$} \\ \cline{3-5}
\multicolumn{1}{c}{} & & $s_{21}$ & $s_{22}$ & $s_{23}$ \\ \cline{2-5}
\multirow{2}*{Spieler $1$}
& $s_{11}$ & $(\tfrac{1}{4},\tfrac{1}{2})$ & $(x,y)$ & $(x,y)$ \\ \cline{2-5}
& $s_{12}$ & $(x,y)$ & $(x,y)$ & $(x,y)$ \\ \cline{2-5}
\end{tabular}
\end{table}
\end{document}
答案1
我不确定这是否是你要找的:
上面的表格图片是通过您的代码获得的,其中我擦除\setlength{\extrarowheight}{10pt}
(仅添加单元格内容上方的空间)并添加\renewcommand\arraystretch{1.5}
。因此,完整的代码(在数学表达式的设置上有一些变化)是:
\documentclass[a4paper, fontsize=11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[onehalfspacing]{setspace}
\usepackage{amsmath,amssymb}
\usepackage{multirow,array}
\usepackage{arydshln}
\begin{document}
\begin{table}
\renewcommand\arraystretch{1.5}
\begin{tabular}{*{5}{>{$}c<{$}|}}
\multicolumn{2}{c}{} & \multicolumn{3}{c}{Spieler 2} \\ \cline{3-5}
\multicolumn{1}{c}{} & & s_{21} & s_{22} & s_{23} \\ \cline{2-5}
\multirow{2}*{Spieler 1}
& s_{11} & \left(\frac{1}{4},\frac{1}{2}\right) & (x,y) & (x,y) \\ \cline{2-5}
& s_{12} & (x,y) & (x,y) & (x,y) \\ \cline{2-5}
\end{tabular}
\end{table}
\end{document}
答案2
我建议使用这样的版本:
\documentclass[a4paper, fontsize=11pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[onehalfspacing]{setspace}
\usepackage{amsmath,array,booktabs}
\begin{document}
\begin{table}
\begin{tabular}{*{4}{c}}
\toprule
Spieler $1$ & \multicolumn{3}{c}{Spieler $2$}\\\cmidrule(l){2-4}
& $s_{21}$ & $s_{22}$ & $s_{23}$ \\\cmidrule(r){1-1}
\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(l){4-4}
$s_{11}$ & $(\tfrac{1}{4},\tfrac{1}{2})$ & $(x,y)$ & $(x,y)$ \\
$s_{12}$ & $(x,y)$ & $(x,y)$ & $(x,y)$ \\
\bottomrule
\end{tabular}
\end{table}
\end{document}