views:

48

answers:

1

I'm using TikX with LaTeX to draw a technical diagram. I'm trying to draw an irregular polygon around a group of named nodes in a tree. I've gotten as far as

\draw [rounded corners, thick] 
   (node cs:name=add,anchor=north) --
   (node cs:name=cvc,anchor=west) --
   (node cs:name=addrc,angle=200) --
   (node cs:name=addrc,angle=-20) --
   (node cs:name=cnst,anchor=east) --
   cycle;

But the polygon is too close to the nodes. How can I either enlarge the polygon or specify better coordinates to get a diagram where there is some separation between the polygon and the nodes it surrounds?

+2  A: 

One trick you could try is to make a new invisible "fake" nodes in the same locations as the original nodes. You can then play with the outer sep=10pt property for these nodes. (This avoids these changes affecting the rest of the picture).

\node at (cvc) [name=fakecvc,outer sep=10pt,inner sep=5pt]{};

Then draw your polygon around these bigger "fake" nodes. (maybe increasing the roundness will help? rounded corners=20pt)

Sometimes its also useful to manually transform points

\usetikzlibrary{calc}
($(node cs:name=d,anchor=north)+(-10pt,+5pt)$)
Niall Murphy
Two good tricks in one answer! Is the second `($...$)` syntax for a point in a `draw` command? (I am brand new to TikZ and while I like it, the 500-page manual is daunting.)
Norman Ramsey
The `($ $)` syntax can be used for any co-ordinate. However I think its probably best practice not to over use it and reserve it for cases when you really just need to nudge something. More examples are in section "12.4 Coordinate Calculations" of the Tikz 2.0 manual.In case you don't know, you can frequently find something close to what you want at http://www.texample.net/tikz/examples/ and then hack it into shape.
Niall Murphy
The fine control of `($...$)` is perfect. Thanks kindly.
Norman Ramsey