5

I am trying to produce a figure which contains a cloud drawn around a set of images. The code I have so far is:

\node [draw, cloud, cloud puffs=20, aspect=2, inner sep=0cm] (pathways) 
 {\begin{tikzpicture}
   \node at (0,0) [inner sep = 0pt] (pathway) {\includegraphics[width=5cm]{png/WP716_74442.png}};
   \node at (2,1) [inner sep = 0pt] (pathway2) {\includegraphics[width=4cm]{png/WP716_74442.png}};
   \node at (1,2) [inner sep = 0pt] (pathway3) {\includegraphics[width=5cm]{png/WP716_74442.png}};
   \node at (4,2) [inner sep = 0pt] (pathway4) {\includegraphics[width=5cm]{png/WP706_74443.png}};
   \node [above left = of pathway2] (pathway5) {\includegraphics[width=4cm]{png/WP1591_73381.png}};
\end{tikzpicture}
};

This results in the following cloud:

TikZ cloud

There is to much white space to my liking. I prefer the line of the cloud the just barely touch the figures included. According to an answer here, I should use inner sep=0cm. However the white space surrounding the figures remain.

What I need is a cloud that is drawn around a set of figures in png format. What do I need to do, to get a smaller cloud (with less white space).

2
  • 3
    Did you try a negative inner sep value? Commented Jul 24, 2014 at 12:18
  • @PaulGessler Great that did it. Didn't know you could provide negative values.
    – Andra
    Commented Jul 24, 2014 at 12:24

1 Answer 1

8

The key inner sep may have negative values. So you can use this to adjust to your liking the size of the shape relative to the images. But, as noted by percusse in a comment, negative inner sep values can lead to nasty overlap and miscalculated bounding boxes that may show up if you have other things in the drawing. Note also that nesting tikzpictures is generally liable to cause problems (c.f. 1 2 3 4 5), but in this case it works fine.

A better approach would be to use the fit library, as I've shown here, which avoids the nested tikzpictures. This also has the benefit of requiring less drastic adjustments to inner sep. For example, in this code I was able to use inner sep=0pt and I think it fits close enough. As they say in many cookbooks, "season to taste."

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes,fit} % added fit library
\begin{document}
\begin{tikzpicture}
  % draw the named nodes
  \node (a) at (0,0) [inner sep = 0pt] {\includegraphics[width=5cm]{example-image-a}};
  \node (b) at (4,1) [inner sep = 0pt] {\includegraphics[width=5cm]{example-image-b}};
  % draw the cloud node, fitted to named nodes (a) and (b)
  \node [draw, inner sep=0pt, cloud, cloud puffs=20, aspect=2,fit=(a) (b)] {};
\end{tikzpicture}
\end{document}

enter image description here

1
  • 1
    May take negative values but shouldn't. Try \tikz{\node[draw] (a) at (0,0) [inner sep = -5pt] {\Huge A}; \draw (a) -- (5mm,0);}. It leads to miscalculated bounding boxes too.
    – percusse
    Commented Jul 24, 2014 at 13:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .