# Drawing figures in LaTeX

Can I make the figure which I just posted here in LaTeX?

• Yes,for sure you can. Read about tikz. For example texample.net/tikz/examples/tex-workflow Oct 7 '13 at 13:08
• Have a look at the tikz-cd package; it seems suitable for your purpose Oct 7 '13 at 13:32
• I'd use TikZ-matrices to place nodes for this. Oct 7 '13 at 13:58

Making use of Claudio Fiandrino's suggestion to use a matrix to typeset the diagrams as well as the subcaption package and some minipages, here's a way to implement the figure that you have in mind. Note the required %s in order to make sure that the first two minipages appear next to each other rather than on top of each other.

\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}


• It is suggestive to use the subfigure environment with a usual \caption command instead of a minipage with \subcaption. As alternative there is the \subcaptionbox command. Oct 7 '13 at 19:49
• Excellent job.. Thanks it works exactly the same way I wanted it Oct 8 '13 at 2:27

Here is some code that puts in an approximation of the upper left diagram. By playing with the parameters you can get a better approximation. Enlarge the boxes containing the characters and shrink slightly the boxes containing the frameboxes:

 \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/<->/[1a1b;] \arrow/<->/[1a2a;] \arrow/<->/[1a2b;] \arrow/<->/[2a2b;] \arrow/<->/[1b2b;] \efig$$
\end{document}

• Please, don't use  in LaTeX documents (at least not those you present here). Oct 7 '13 at 21:06
• What does option barr to package xy do? I couldn't find it documented. Aug 12 '17 at 14:39

after almost four years ... with use of subfigure environments and recent version of 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}
`