我可以用 LaTeX 制作刚刚发布在这里的图形吗?
答案1
利用 Claudio Fiandrino 的建议,使用matrix
来排版图表以及subcaption
包和一些minipage
s,这是一种实现您心中的图形的方法。请注意必需的%
s,以确保前两个minipage
s 彼此相邻而不是彼此重叠。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{minipage}[b]{.4\linewidth}
\centering
\begin{tikzpicture}
\matrix[name=M, matrix of nodes, column sep=1cm, row sep=1cm]{
\node[draw,minimum size=1cm]{IQ}; & \node[draw,minimum size=1cm]{Z}; \\
\node[draw,minimum size=1cm]{JP}; & \node[draw,minimum size=1cm]{R}; \\
};
\draw[<->] (M-1-2) edge (M-2-2);
\draw[<->] (M-1-1) edge (M-2-1);
\draw[<->] (M-1-1) edge (M-2-2);
\draw[<->] (M-2-1) edge (M-2-2);
\end{tikzpicture}
\subcaption{MNAR Mechanism}\label{fig:1a}
\end{minipage}%
%
\begin{minipage}[b]{.4\linewidth}
\centering
\begin{tikzpicture}
\matrix[name=M, matrix of nodes, column sep=1cm, row sep=1cm]{
\node[draw,minimum size=1cm]{IQ}; & \node[draw,minimum size=1cm]{Z}; \\
\node[draw,minimum size=1cm]{JP}; & \node[draw,minimum size=1cm]{R}; \\
};
\draw[<->] (M-1-2) edge (M-2-2);
\draw[<->] (M-1-1) edge (M-2-1);
\draw[<->] (M-1-1) edge (M-2-2);
\end{tikzpicture}
\subcaption{MAR Mechanism}\label{fig:1b}
\end{minipage}
\begin{minipage}[b]{.4\linewidth}
\centering
\begin{tikzpicture}
\matrix[name=M, matrix of nodes, column sep=1cm, row sep=1cm]{
\node[draw,minimum size=1cm]{IQ}; & \node[draw,minimum size=1cm]{Z}; \\
\node[draw,minimum size=1cm]{JP}; & \node[draw,minimum size=1cm]{R}; \\
};
\draw[<->] (M-1-2) edge (M-2-2);
\draw[<->] (M-1-1) edge (M-2-1);
\end{tikzpicture}
\subcaption{MCAR Mechanism}\label{fig:1b}
\end{minipage}
\caption{Figures}\label{fig:1}
\end{figure}
\end{document}
答案2
以下是一些代码,用于近似左上图。通过调整参数,您可以获得更好的近似值。放大包含字符的框并稍微缩小包含框架框的框:
\documentclass{article}
\usepackage[barr,pdf]{xy}
\begin{document}
$$\bfig
\node 1a(0,0)[\framebox{IQ}]
\node 1b(400,0)[\framebox{Z}]
\node 2a(0,-400)[\framebox{JP}]
\node 2b(400,-400)[\framebox{R}]
\arrow/<->/[1a`1b;]
\arrow/<->/[1a`2a;]
\arrow/<->/[1a`2b;]
\arrow/<->/[2a`2b;]
\arrow/<->/[1b`2b;]
\efig$$
\end{document}
答案3
经过近四年的时间...使用subfigure
环境和最新版本tikz
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, matrix}
\usepackage{subcaption}
\usepackage[active,floats,tightpage]{preview}% only for figure test
\setlength\PreviewBorder{1em}
\begin{document}
\begin{figure}
\tikzset{
> = Stealth,
Matrix/.style = {matrix of nodes,
nodes={draw, minimum size=10mm},
column sep=1cm, row sep=1cm}
}
\centering
\begin{subfigure}[t]{0.32\linewidth}
\centering
\begin{tikzpicture}
\matrix (m) [Matrix]
{
IQ & Z \\
JP & R \\
};
\draw[<->] (m-1-2) edge (m-2-2)
(m-1-1) edge (m-2-1)
(m-1-1) edge (m-2-2)
(m-2-1) edge (m-2-2);
\end{tikzpicture}
\caption{MNAR Mechanism}
\label{fig:1a}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.32\linewidth}
\centering
\begin{tikzpicture}
\matrix (m) [Matrix]
{
IQ & Z \\
JP & R \\
};
\draw[<->] (m-1-2) edge (m-2-2)
(m-1-1) edge (m-2-1)
(m-1-1) edge (m-2-2);
\end{tikzpicture}
\caption{NAR Mechanism}
\label{fig:1b}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.32\linewidth}
\centering
\begin{tikzpicture}
\matrix (m) [Matrix]
{
IQ & Z \\
JP & R \\
};
\draw[<->] (m-1-2) edge (m-2-2)
(m-1-1) edge (m-2-1);
\end{tikzpicture}
\caption{MCAR Mechanism}
\label{fig:1c}
\end{subfigure}
\end{figure}
\end{document}