Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

After some trial and error, and a little help from this stack overflow question I was able to put together this code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}

\begin{itemize}
    \item one length
    \tikz[remember picture] \node[coordinate, yshift=0.7em] (n1) {};
    \item another length
    \tikz[remember picture] \node[coordinate, yshift=-0.2em] (n2) {};
    \item the longest length
    \tikz[remember picture] \node[coordinate, yshift=-0.2em] (n3) {};
    \item short
    \tikz[remember picture] \node[coordinate, yshift=-0.2em] (n4) {};
\end{itemize}

\begin{tikzpicture}[overlay,remember picture]
    \path (n4) -| node[coordinate] (n5) {} (n3);
    \path (n1) -| node[coordinate] (n6) {} (n3);
    \draw[thick,decorate,decoration={brace, amplitude=4pt}] 
        (n6) -- (n5) node[midway, right=3pt]{brace text};
\end{tikzpicture}

\end{document}

which produces

side brace example

as desired. I am, however, a little unsure of why it works.

Do the path lines like \path (n4) -| node[coordinate] (n5) {} (n3); read like “make a node in the rectangular coordinate system that lines up with n4 in x and n3 in y”?

share|improve this question
    
Yes, you read that correctly. –  Caramdir Oct 6 '11 at 3:55
    
Instead of node [coordinate], you can just use coordinate. –  Jake Oct 6 '11 at 4:29
    
@Jake i knew node[coordinate] looked funny! –  asia1281 Oct 6 '11 at 16:16
add comment

1 Answer 1

up vote 5 down vote accepted

You're basically correct, but I usually think of this slightly differently: I would say the line reads like "Make a node at the halfway position of the rectangular path that goes from n4 to n5". The result is almost the same, but the distinction is that you're not just specifying a coordinate, but actually a full path, and you position a node on it.

The expressions

\path (0,0) -| node {X} (3,1);

and

\path (0,0) -| (3,1) node [pos=0.5] {X};

are equivalent, they both position a node at the coordinate (3,0). The position 0.5 is defined as the halfway point on linear paths, and as the corner in rectangular paths. Using the node keyword between the line type (--, |- or -|) and the second coordinate will place the node at position 0.5, using it between the first coordinate and the line type will place the node at position 0, and using it after the second coordinate will place the node at position 1.

The above expressions also both set the bounding box (and therefore the size of your picture) to include the points (0,0) and (3,1), because you defined the whole path from (0,0) to (3,1).

If you just want to position the node without altering the bounding box, you should use the syntax

\node at (0,0 -| 3,1) {X};

which specifies a coordinate in terms of the rectangular coordinate system between (0,0) and (3,1) without specifying the whole path.

share|improve this answer
    
ohhh, placement of the node keyword must be the reason it appeared to behave funny when i was setting it up. thanks. –  asia1281 Oct 6 '11 at 16:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.