# coordinate along decorated path

I'm using the brace decoration from the TikZ decorations.pathreplacing library to draw a brace around some nodes. Now I would like to connect the tip of the brace to another path (use case: labelling terms in an equation). First, I used the LaTeX command \overbrace, but realised it would be difficult to connect a tikz-path to the tip. It should be easier using the TikZ decoration brace. However, if I place node[midway] along the path, the node is placed midway along the unaltered path, not midway along the decorated path. Below is code along with the undesired output.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\node (spam) at (1, 1) {Spam};
\node (eggs) at (4, 1) {Eggs};
\draw[decoration={brace,amplitude=5mm}, decorate] (spam.north) -- (eggs.north) coordinate[midway] (mid);
\draw (mid) -- ++(0,1);
\end{tikzpicture}
\end{document}


Of course, in the present example, I could simply replace the second \draw-command by \draw (mid) ++(0,5mm) -- ++(0,1);. But I would like something more stable that I don't need to tweak by hand, and maybe even work for arbitrary decorated paths.

So, my question is:

• How do I place a coordinate at some point along a decorated path?

UPDATE 2012-12-17: To show the use case, I add a picture of the solution here.

-
If you need edge like brace, you need to consider some examples in the pgfmanual something like edge from parent path= {(\tikzparentnode.south) .. controls +(0,-1) and +(0,1) .. (\tikzchildnode.north)}] . (see Making Trees Grow) –  Alain Matthes Dec 16 '11 at 15:17
Thanks Altermundus. I've added a picture of what the slide looks like now. If you think there could be a better approach than my current one, I'd be happy to hear it. I'd like to use the mathmode \overbrace but have no idea how I would dynamically connect a path to its tip... –  gerrit Dec 17 '11 at 17:53

This is a funny one! :)

You can accomplish this by realizing that the decoration is a path in itself.

What you just then need to do is access that path!

You can do this by applying a postaction on the path and decorate it again!

But as the decoration is in a separate key directory you need to explicitly tell to use /tikz/postaction. You can then access any coordinate however you wish, i choose to use the decoration library markings.

So here it is:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usepgflibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\node (spam) at (1, 1) {Spam};
\node (eggs) at (4, 1) {Eggs};
\node (bacon) at (4, 3) {Bacon};
\draw[decoration={brace,amplitude=5mm}, decorate] (spam.north) -- (eggs.north) coordinate[midway] (mid);
\draw (mid) -- ++(0,1);
\draw[decoration={brace,amplitude=5mm,
/tikz/postaction={
decoration={
markings,
mark=at position 0.45 with \coordinate (Mb);,
mark=at position 0.5 with \coordinate (M);,
mark=at position 0.55 with \coordinate (Ma);
},decorate
}
},decorate] (spam.north) -- (bacon.north);
\draw[red] (Mb) circle (2pt);
\draw[blue] (M) circle (2pt);
\draw[green] (Ma) circle (2pt);
\end{tikzpicture}
\end{document}


An the output becomes:

-

The brace is not the path, it's an object placed along the path (spam.north) -- (eggs.north). See the answer of zeroth to use the path of the brace.It's the correct answer.

Another possibility is to use the current bounding box just after the decoration but it's possible only if the box is symmetric. it's why I used minimum width=1.5cm.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\node[minimum width=1.5cm] (spam) at (1, 1) {Spam};
\node[minimum width=1.5cm] (eggs) at (4, 1) {Eggs};
\draw[decoration={brace,amplitude=5mm}, decorate] (spam.north) -- (eggs.north); % coordinate[midway] (mid);
\draw (current bounding box.north) -- ++(0,1);
\end{tikzpicture}
\end{document}


-