I am trying to create graphs side by side in a row, but I must accept that I have no idea how to do it. Following is based on my understanding. I am using tikz package for making Bayesian graphs.
\documentclass[11pt]{report}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{caption,subcaption}% http://ctan.org/pkg/{caption,subcaption}
\usetikzlibrary{positioning}
\usetikzlibrary{bayesnet}
\begin{document}
\begin{figure}
\begin{subfigure}
\centering
\tikz{ %
\node[latent] (phi) {$\phi$};
\node[latent, above = of phi] (y) {$\mathbf{y}$};
\edge {phi} {y};
}
\end{subfigure}
\begin{subfigure}
\centering
\tikz{ %
\node[latent] (a) {$\alpha$};
\node[latent, above = of phi] (b) {$\beta$};
\edge {a} {b};
}
\end{subfigure}
\begin{subfigure}
\centering
\tikz{ %
\node[latent] (t) {$\theta$};
\node[latent, above = of phi] (g) {$\gamma$};
\edge {t} {g};
}
\end{subfigure}
\end{figure}
\end{document}
Please suggest me how it could be performed.
Edit:
As suggested in the comments to the question, I made the following changes, what I could not follow is how linewidth works. And what if I want equal distance between then in a row?
\documentclass[11pt]{report}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{caption,subcaption}% http://ctan.org/pkg/{caption,subcaption}
\usetikzlibrary{positioning}
\usetikzlibrary{bayesnet}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.2\linewidth}
\centering
\tikz{ %
\node[latent] (phi) {$\phi$};
\node[latent, above = of phi] (y) {$\mathbf{y}$};
\edge {phi} {y};
}
\caption{\label{fig:fig1}}
\end{subfigure}
\begin{subfigure}[b]{0.4\linewidth}
\centering
\tikz{ %
\node[latent] (a) {$\alpha$};
\node[latent, above = of phi] (b) {$\beta$};
\edge {a} {b};
}
\caption{\label{fig:fig1}}
\end{subfigure}
\begin{subfigure}[b]{.5\linewidth}
\centering
\tikz{ %
\node[latent] (t) {$\theta$};
\node[latent, above = of phi] (g) {$\gamma$};
\edge {t} {g};
}
\caption{\label{fig:fig1}}
\end{subfigure}
\end{figure}
\end{document}





subfigureenvironment, e.g.\begin{subfigure}{0.3\linewidth}, and empty lines means a paragraph break also within afigure, so if you want twosubfigures side by side you need to remove all empty lines between them. – Torbjørn T. Dec 20 '17 at 11:32subfigureenvironments are superfluous. – Torbjørn T. Dec 20 '17 at 11:34\linewidthis the width of the text block,0.3\linewidthis 30% of that. You can also use a specific length, e.g.5cm. – Torbjørn T. Dec 20 '17 at 11:570.3\linewidth. – Torbjørn T. Dec 20 '17 at 12:45