# I want a figure to be positioned above a tikzpicture

I have a picture which needs to be placed above another figure that I drew using tikzpicture. The pictures are being positioned side by side.

\documentclass{standalone}

\usepackage{tikz}

\begin{document}
\includegraphics[scale=1]{m4.pdf}
\begin{tikzpicture}

\node(A0) at (0,0) {p = 0};
\node(A1) at (10,0) {p = 1};

\path[->] (A0) edge node [below] {Increasing Ramdomness} (A1);

\end{tikzpicture}
\end{document}


The output is:

I want it to be like:

• Welcome to TeX.SE. You only need to put the picture in a node, \node at (5,3) {\includegraphics[scale=1]{m4.pdf}};. However, I do not have your picture, so I do not know if (5,3) works, you may need to use different coordinates. – marmot Nov 16 '18 at 5:01
• @CarLaTeX I dunno, how would anyone benefit from this? It is, at least by some standards, a duplicate of this question. And this answer will always give you an idea which coordinates are to be used. (I would probably just draw these graphs with TikZ.) – marmot Nov 16 '18 at 5:49
• @CarLaTeX Morally I agree but thanks to the tikz-pgf gold badge I can no longer just vote to close a question as a duplicate. – marmot Nov 16 '18 at 5:57
• @marmot Close vote retracted since there's an answer – CarLaTeX Nov 16 '18 at 6:33

Just load the optional preview package of the standalone class, and I quote (page 9):

If enabled this option loads the preview package with the tightpage option and wraps the content into a preview environment. This crops the content to its natural size plus a specified border.

\documentclass[preview]{standalone}

\usepackage{tikz}
\usepackage{mwe}
\begin{document}
\includegraphics[scale=1]{example-image-a}
\begin{tikzpicture}

\node(A0) at (0,0) {p = 0};
\node(A1) at (10,0) {p = 1};

\path[->] (A0) edge node [below] {Increasing Ramdomness} (A1);

\end{tikzpicture}
\end{document}


By default standalone processes the content in restricted horizontal mode which means like inside \hbox{..} or \mbox{..}. This means there can't be line breaks like in paragraphs. If you like to have line breaks / paragraphs you need to either provide the varwidth class option or the preview class option. The first uses a varwidth environment from the varwidth package around the content. The second switches the cropping code from standalones own code to the preview package, which also allows paragraphs.

In this specific case you could also just place the \includegraphics inside a TikZ \node to place it as part of the picture on top of the other material.

You can also do something like below.

\documentclass[tikz]{standalone}
\usepackage{mwe}
\begin{document}

\begin{tikzpicture}
\node at (0,0) {\includegraphics[width=4cm]{example-image-a}};
\node at (4,0) {\includegraphics[width=4cm]{example-image-b}};
\node at (8,0) {\includegraphics[width=4cm]{example-image-a}};
\node(A0) at (0,-2) {p = 0};
\node(A1) at (8,-2) {p = 1};
\path[->] (A0) edge node [below] {Increasing Ramdomness} (A1);
\end{tikzpicture}
\end{document}


• By the way, Ramdomness must be fixed to Randomness. However, it is left as it is for the sake of originality. – Artificial Odorless Armpit Nov 21 '18 at 7:41