How to use $: As you can see, the syntax uses the TEX math symbol $ to indicate that a “mathematical computation”. The red circle is placed from (a).
I add 2*(1,1) at the coordinates of (a) so I get 1+2 and 1+2 (it's like addition of vectors)

How to use !: I want to get a coordinate of point between (a) and (b). If I want the middle I use ($(a)!.5!(b)$). I use (...) to search coordinates. Then I use $..$ to make a calculation. Finally, I use !number! to get a point on the line (a)--(b). It's like to use pos =.5.

Oh! So foo!.5!bar works quite similarly to that construction in xcolor colour specifications, except that it uses fractions rather than percentages. Neat.
– SeamusMar 1 '11 at 13:34

@Seamus: you can also use number > 1 and you can use negative number for example ($(a)!-.5!(b)$) or ($(a)!25!(b)$) . It's like a barycenter.
– Alain MatthesMar 1 '11 at 13:46

@Altermundus it seems that the ! can also have the name of a node in the middle (see example in question). What does this mean?
– SeamusMar 1 '11 at 13:50

2

@Seamus: I update my answer : it's more complicated. When you write ($(a)!(c)!(b)$) you use a projection modifier. It also gives a point on a line from the ⟨first coordinate⟩ to the ⟨second coordinate⟩. However, the ⟨number⟩ or ⟨dimension⟩ is replaced by a ⟨projection coordinate ⟩. In my example, (d) is the orthogonal projection of (c) on the line (a)--(b). The result is always a point of (a)--(b).
– Alain MatthesMar 1 '11 at 14:07

@Altermundus: I've tried to mark you inline code with backticks `. However, since I don't fully understand your answer, I'm not sure if I did it correctly. In particular, I don't quite understand the sequence of "because"s in #2.
– Hendrik VogtMar 1 '11 at 14:15

This is a nice solution. However: I think the TikZ solution I'm trying to modify is easier to manipulate (adding an extra item in the braces would work without modification) and also I'm more interested in learning about TikZ than I am to the solution of the actual problem itself.
– SeamusMar 1 '11 at 14:02

11

I see, you like to shoot with canon balls on sparrows ...
– user2478Mar 1 '11 at 14:05

8

as a way of learning how to use canons, it's good practice.
– SeamusMar 1 '11 at 14:38

After let \p1=(topbrace), one can access its x and y coordinates with \x1 and \y1. So it is easier to find the right place for the brace (note that the anchors are placed on the baseline, hence the +0.8em in the top point). If you place a node immediately after -- it is place in the middle of the line. We want it to be a bit to the right of that.

That is clever. I was just thinking that Andrew Stacey's solution to the original question would be a lot easier if you didn't have to do the projecting on to the right node and instead you could just fetch the x coordinates of each anchor. Very nice!
– SeamusMar 1 '11 at 17:39

I think @Altermundus gave an excellent description of what was going on in Andrew's earlier answer, so I think I will accept that answer. However, I think this is a better solution to the original problem I linked to in my question...
– SeamusMar 1 '11 at 17:40

@Seamus, I was planning to add that to my answer to the linked question, but had to leave. I'll do that later.
– CaramdirMar 1 '11 at 19:03

@Seamus: Thinking through that once more, I realized that this solution stops working when putting a brace from the first to the third line in the example (as the longer second line is not taken into account). But you can change the first point in Andrew's code to something like ($(right)!(topbrace.north)!($(right)-(0,1)$) + (0,0.8em)$) and add a node in the same position as in my example.
– CaramdirMar 2 '11 at 2:01