I have to draw the probability distribution function (PDF) in the following MWE multiple times in a figure as well as across multiple figures. I have read the following questions:
- Problem with overlay when a tikzpicture is inside another tikzpicture
- Nesting "tikzpicture" within "tikzpicture" elements - Good or bad practice?
- How to typeset a TikZ picture inside a node?
and think that I would like to avoid nesting if possible. This is a simple MWE and for this specific problem, I could use absolute positioning of all the elements. But it is cumbersome. Another option is prepare a PDF file and include the image in a node. Is there a better option?
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[node distance=2em]
\node(pdf){
\begin{tikzpicture}
\draw [step=0.25cm,lightgray,very thin] (0,0) grid (2.5,1.5);
\draw [draw,->,ultra thick] (0,0.0) -- (0,1.5);
\draw [draw,->,ultra thick] (0,0.0) -- (2.5,0);
\draw [fill=blue!20!white,ultra thick,overlay] (0.2,0) ..controls
(0.5,2.2) and (1,0.1) .. (2,0);
\end{tikzpicture}
};
\node [rectangle,draw, right=of pdf] (cfd) {Nonlinear Flow Solution};
\path[draw,->] (pdf) -- (cfd);
\end{tikzpicture}
\end{document}


newcommandwith\AtBeginDocument? – devendra Jan 04 '13 at 11:02lrboxcan be used inside the preamble, too, but you might want to add\normalfontin front of it to ensure that the normal font is already set up. It can also be used inside\AtBeginDocument{..}as long as you don't have any special content, like verbatim material, which isn't allowed in a macro argument. Not sure what you mean with "as a newcommand". – Martin Scharrer Jan 04 '13 at 11:07\pdffigureand use it in all the figures. I will also have to look into scaling this box for different figures. – devendra Jan 04 '13 at 11:11lrboxenvironment inside a macro definition then. Simply use\usebox\myboxeverywhere or define a macro which contains these two. Note that you will need a separate saveboxes if you want to have multiple inner pictures. – Martin Scharrer Jan 04 '13 at 11:23