TikZ
我在调整代码以获得对称输出矩阵时遇到了困难;我猜这*
是正确的块在某种程度上更高的原因?
\documentclass[a4paper,fontsize=12pt,a4paper,DIV=10,BCOR=10mm,twoside,titlepage=false,openany,pagesize]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\setkomafont{disposition}{\normalfont\bfseries}
\usepackage{tikz}
\usetikzlibrary{calc,matrix,positioning}
\begin{document}
\begin{figure}[h]
\centering
\caption{Collective action problem in the Prisoners' Dilemma}
\label{Collective action problem in the Prisoners' Dilemma}
\begin{tikzpicture}[element/.style={ minimum width=1.75cm,minimum height=0.85cm}]
\matrix (m) [matrix of nodes,nodes={element},column sep=-\pgflinewidth, row sep=-\pgflinewidth,]{
& Cooperate & Defect \\
Cooperate & |[draw]|3,3 & |[draw]|1,4 \\
Defect & |[draw]|4,1 & |[draw]|2,2* \\
};
\node[above=0.25cm] at ($(m-1-2)!0.5!(m-1-3)$){\textbf{Actor A}};
\node[rotate=90] at ($(m-2-1)!0.5!(m-3-1)+(-1.25,0)$){\textbf{Actor B}};
\node [below=1.5cm, align=flush center,text width=8cm]
{\begin{scriptsize}
Number left (right) of comma refers to A's (B's) preference ordering (1 = worst outcome; 4 = best outcome). * indicates the equilibrium.
\end{scriptsize}
};
\end{tikzpicture}
\end{figure}
\end{document}
答案1
你可以“假装” 不在*
这里(即:它不占用空间),只需放置\smash{\rlap{*}}
而不是 即可*
。这样,不仅所有单元格都具有相同的大小,而且 还将2.2
与 垂直对齐1.4
:
答案2
考虑阅读这,只需指定text height=1em
,element/.style
您就会获得:
答案3
您可以尝试设置节点的锚点element/.style={ anchor=north east,
或element/.style={ anchor=center,
。