答案1
以下是第一个示例的简单重现:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[>=Stealth]
\coordinate (x5) at (-3, 2);
\coordinate (x1) at ( 0, 2);
\coordinate (x3) at ( 3, 2);
\coordinate (x6) at (-3, -2);
\coordinate (x2) at ( 0, -2);
\coordinate (x4) at ( 3, -2);
\coordinate (r1) at (-5, 3);
\coordinate (r2) at (-5, 1);
\coordinate (r3) at (-5, -1);
\coordinate (r4) at (-5, -3);
\coordinate (r5) at ( 5, 3);
\coordinate (r6) at ( 5, 1);
\coordinate (r7) at ( 5, -1);
\coordinate (r8) at ( 5, -3);
\coordinate (o) at (-1.25, 0);
\node[circle, draw, inner sep=0.15em] (oc) at (o) {};
\node[anchor=north west] at (x1) {$x_1$};
\node[anchor=north west] at (x5) {$x_5$};
\node[anchor=north east] at (x3) {$x_3$};
\node[anchor=south west] at (x2) {$x_2$};
\node[anchor=south west] at (x6) {$x_6$};
\node[anchor=south east] at (x4) {$x_4$};
\node[anchor=east] at (r1) {3, 0};
\node[anchor=east] at (r2) {3, 2};
\node[anchor=east] at (r3) {0, 3};
\node[anchor=east] at (r4) {3, 2};
\node[anchor=west] at (r5) {2, 3};
\node[anchor=west] at (r6) {2, 2};
\node[anchor=west] at (r7) {2, 3};
\node[anchor=west] at (r8) {2, 2};
\node[anchor=north east] at (o) {Nature};
\draw[->] (oc.75) -- (x1) node[midway, anchor=east] {[.5]1};
\draw[->] (oc.285) -- (x2) node[midway, anchor=east] {[.5]2};
\draw[->] (x1) -- (x3) node[midway, anchor=south] {Average};
\draw[->] (x1) -- (x5) node[midway, anchor=south] {Hunk\vphantom{g}};
\draw[->] (x2) -- (x4) node[midway, anchor=north] {Average};
\draw[->] (x2) -- (x6) node[midway, anchor=north] {Hunk};
\draw[->] (x5) -- (r1) node[near end, anchor=south west] {Hunk};
\draw[->] (x5) -- (r2) node[near end, anchor=north west] {Average};
\draw[->] (x6) -- (r3) node[near end, anchor=south west] {Hunk};
\draw[->] (x6) -- (r4) node[near end, anchor=north west] {Average};
\draw[->] (x3) -- (r5) node[near end, anchor=south east] {Hunk};
\draw[->] (x3) -- (r6) node[near end, anchor=north east] {Average};
\draw[->] (x4) -- (r7) node[near end, anchor=south east] {Hunk};
\draw[->] (x4) -- (r8) node[near end, anchor=north east] {Average};
\draw[dashed] (x5) -- (x6) node[pos=0.45, anchor=east] {Tina} node[pos=0.45, anchor=west] {$h_{T2}$};
\draw[dashed] (x3) -- (x4) node[midway, anchor=west] {Tina} node[midway, anchor=east] {$h_{T1}$};
\draw[dashed] (x1) -- (x2) node[midway, anchor=west] {Gina} node[midway, anchor=east] {$h_G$};
\end{tikzpicture}
\end{document}
一些说明:
- 您可以调整坐标来移动各个节点 --- 我根据它们的标签命名了它们(
r1
...r8
是r
结果、o
是o
起点、是起点oc
ircle )。o
c
- 边缘标签大多已定位
midway
,但我手动移动了一个,pos=...
以使整个东西看起来更好(midway
相当于pos=0.5
FWIW)。 >=Stealth
将默认箭头提示更改为TiStealth
的提示arrows.meta
钾Z 库(必须加载该库才能正常工作)。- 我在其中一个边缘标签中使用了,
\vphantom{g}
以确保“Hunk”和“Average”的不同深度不会导致这些标签放置不均匀。
编辑:第二个是:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,calc}
\begin{document}
\begin{tikzpicture}[>=Stealth]
\coordinate (x5) at (-2, 2);
\coordinate (x1) at ( 0, 2);
\coordinate (x3) at ( 2, 2);
\coordinate (x6) at (-2, -2);
\coordinate (x2) at ( 0, -2);
\coordinate (x4) at ( 2, -2);
\coordinate (r1) at (-3, 3);
\coordinate (r2) at (-3, 1);
\coordinate (r3) at (-3, -1);
\coordinate (r4) at (-3, -3);
\coordinate (o) at ( 0, 0);
\coordinate (rl) at (-2.5, -0.5);
\node[anchor=north west] at (x1) {$x_u$};
\node[anchor=south west] at (x2) {$x_d$};
\node[anchor=south, yshift=0.75em] at (x1) {2};
\node[anchor=north] at (x2) {2};
\node[anchor=west] at (x3) {1, 1};
\node[anchor=west] at (x4) {1, 1};
\node[anchor=east] at (r1) {1, 2};
\node[anchor=east] at (r2) {0, 0};
\node[anchor=east] at (r3) {2, 0};
\node[anchor=east] at (r4) {1, 0};
\node[anchor=west, xshift=0.75em] at (o) {Nature};
\draw[->] (o) -- (x1) node[midway, anchor=east] {[.5]} node[midway, anchor=west] {U};
\draw[->] (o) -- (x2) node[midway, anchor=east] {[.5]} node[midway, anchor=west] {D};
\draw (x1) -- (x3) node[midway, anchor=south] {R};
\draw (x1) -- (x5) node[midway, anchor=south] {L};
\draw (x2) -- (x4) node[midway, anchor=north] {r};
\draw (x2) -- (x6) node[midway, anchor=north] {l};
\draw (x5) -- (r1) node[near end, anchor=south west] {t};
\draw (x5) -- (r2) node[near end, anchor=north west] {b};
\draw (x6) -- (r3) node[near end, anchor=south west] {t};
\draw (x6) -- (r4) node[near end, anchor=north west] {b};
\draw[rounded corners=0.25em] ($(x6) - (0.25,0.75)$) rectangle ($(x5) + (0.25,0.75)$);
\end{tikzpicture}
\end{document}
这是基于第一个,并且几乎同样简单;唯一的区别是calc
Ti钾Z 库用于计算矩形的坐标(信息集?我不太了解博弈论),这样如果坐标发生变化,矩形就会自动适应。我偶尔也会使用xshift=
和yshift=
来移动标签,以更紧密地匹配您的图片。
我希望这可以作为学习 Ti 的起点钾Z --- 就像 LaTeX 本身一样,它的学习曲线很陡峭,但一旦你掌握了它,它就是一个非常强大的工具。
答案2
再次尝试使用游戏包裹:
第一张图片:
\documentclass[tikz]{standalone}
\usepackage{istgame}
\begin{document}
\begin{istgame}
\setistNewNodeStyle{solid node}[null node]
\setistmathTF001
\setxtshowarrows[thick]
\xtShowArrows
\xtHideEndPoints
% game start
\setistgrowdirection'{east}
\xtdistance{10mm}{40mm}
\istroot(0)[chance node]<[xshift=2mm]200>{Nature}
\istb{[.5]1}[l]
\istb{[.5]2}[l]
\endist
% right part
\xtdistance{30mm}{20mm}
\istroot(Ra)(0-1)<-45>{$x_1$}
\istb{Average}[a] \endist
\istroot(Rb)(0-2)<45>{$x_2$}
\istb{Average}[b] \endist
\xtdistance{20mm}{20mm}
\istroot(T1a)(Ra-1)<-135>{$x_3$}
\istb{Hunk}[above,sloped]{2,3}
\istb{Average}[below,sloped]{2,2}
\endist
\istroot(T1b)(Rb-1)<135>{$x_4$}
\istb{Hunk}[above,sloped]{2,3}
\istb{Average}[below,sloped]{2,2}
\endist
\xtInfoset[dashed](0-1)(0-2){$h_G$}[l]
\xtInfosetOwner(0-1)(0-2){Gina}[r]
\xtInfoset[dashed](T1a)(T1b){$h_{T1}$}[l]
\xtInfosetOwner(T1a)(T1b){Tina}[r]
% left part
\setistgrowdirection{west}
\xtdistance{30mm}{20mm}
\istroot(La)(0-1) \istb{Hunk}[a] \endist
\istroot(Lb)(0-2) \istb{Hunk}[b] \endist
\xtdistance{20mm}{20mm}
\istroot(T2a)(La-1)<-45>{$x_5$}
\istb{Hunk}[above,sloped]{3,0}
\istb{Average}[below,sloped]{3,2}
\endist
\istroot(T2b)(Lb-1)<45>{$x_6$}
\istb{Hunk}[above,sloped]{0,3}
\istb{Average}[below,sloped]{3,2}
\endist
\xtInfoset[dashed](T2a)(T2b){$h_{T2}$}[r]
\xtInfosetOwner(T2a)(T2b){Tina}[l]
\end{istgame}
\end{document}
第二张图片:
\documentclass[tikz]{standalone}
\usepackage{istgame}
\begin{document}
\begin{istgame}
\setistNewNodeStyle{solid node}[null node]
\setistmathTF001
\xtdistance{20mm}{20mm}
\setistgrowdirection{west}
\istroot(0)[chance node]<0>{Nature}
\istB<grow=90>[->]{[.5]}[l]{U}[r]
\istB<grow=-90>[->]{[.5]}[l]{D}[r]
\endist
\istroot(a)(0-1)<90>{2}
\istb<grow=180>{L}[a]
\istb<grow=0>{R}[a]{1,1}[r]
\endist
\istroot(b)(0-2)<-90>{2}
\istb<grow=180>{l}[b]
\istb<grow=0>{r}[b]{1,1}[r]
\endist
\istroot(T2a)(a-1)
\istb{t}[a]{1,2}
\istb{b}[b]{0,0}
\endist
\istroot(T2b)(b-1)
\istb{t}[a]{2,0}
\istb{b}[b]{1,0}
\endist
\xtInfosetO[rounded corners=5pt](T2a)(T2b){1}(2em)
\xtOwner(a){$x_u$}[br]
\xtOwner(b){$x_d$}[ar]
\end{istgame}
\end{document}