答案1
这个想法是使用 \multicolumn 命令(在表中添加垂直线)和 \cline 命令(添加水平线)的组合:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{ c c c c }
& & \multicolumn{2}{c}{Giocatore 2} \\
& & Sinistra & Centro \\ \cline{3-4}
\multirow{2}{*}{Giocatore 1} & Su & \multicolumn{1}{|c|}{1, 0} & \multicolumn{1}{|c|}{1, 2} \\ \cline{3-4}
& Giu & \multicolumn{1}{|c|}{0, 3} & \multicolumn{1}{|c|}{0, 1}\\ \cline{3-4}
\end{tabular}
\end{document}
该代码生成下表:
处理 LaTex 表格格式时,此 Overleaf 链接非常有用:https://www.overleaf.com/learn/latex/Tables
答案2
这是一个解决方案,它对第 1 列和第 2 列使用左对齐,对第 3 列和第 4 列使用固定宽度居中对齐。请注意,没有换行符,通过建设,在字符串“Giocatore 1”中。
\documentclass{article}
\usepackage[italian]{babel}
\addto\extrasitalian{\renewcommand\figurename{Fig.}}
\usepackage[T1]{fontenc}
\usepackage{newtxtext,newtxmath} % optional, to match font used in OP's screenshot
\usepackage{array} % for 'w' column type
\usepackage[labelfont=sc]{caption} % small caps
\usepackage{multirow} % for '\multirow' macro
\counterwithin{figure}{section} % just for this example
%% Two handy shortcut macros:
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\newcommand\mr[2][2]{\multirow{#1}{*}{#2}}
\begin{document}
\setcounter{section}{1} % just for this example
\stepcounter{figure}
\begin{figure}[htbp]
\centering
\renewcommand\arraystretch{1.5} % default is '1'
\begin{tabular}{@{} l l | w{c}{2cm} | w{c}{2cm} | }
& \mc{} & \multicolumn{2}{c}{Giocatore 2} \\
& \mc{} & \mc{Sinistra} & \mc{Destra} \\ \cline{3-4}
\mr{Giocatore 1} & Su & 1, 0 & 1, 2 \\ \cline{3-4}
& Giù & 0, 3 & 0, 1 \\ \cline{3-4}
\end{tabular}
\caption{} % generate caption with just a number, no text
\end{figure}
\end{document}
答案3
与。{NiceTabular}
nicematrix
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\begin{NiceTabular}{cccc}
& & \Block{1-2}{Giocatore 2} \\
& & Sinistra & Destra \\
\Block{2-1}{Giocatore 1} & Su & \Block[hvlines]{2-2}{}
$1,0$ & $1,2$ \\
& Giù & $0,3$ & $0,1$ \\
\end{NiceTabular}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。