Given two points, the following code draws a brace connecting them and labels it.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (4,0);
\draw[decorate,decoration={brace,amplitude=10pt,raise=1pt,mirror},yshift=0pt] (a) -- (b) node [midway,yshift=-15pt]{$x$};
\fill (a) circle (2pt);
\fill (b) circle (2pt);
\end{tikzpicture}
\end{document}
This yields:

However, if the line connecting a and b is not axis-parallel, we can have something like the following:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (4,2);
\draw[decorate,decoration={brace,amplitude=10pt,raise=1pt,mirror},yshift=0pt] (a) -- (b) node [midway,yshift=-15pt]{$x$};
\fill (a) circle (2pt);
\fill (b) circle (2pt);
\end{tikzpicture}
\end{document}
which yields: 
How can the x label be automatically located in this case in the "right" place? If there's no automatic way, I guess one has to use a combination of xshift and yshift and take into account the raise and amplitude of the brace. When I tried to tweak these I failed... What's the smart way out here?


@anchorand the@anchor@prime? When which is used? – Dror Jan 31 '13 at 21:28@anchor@primeis used when theswapoption is active. – Jake Jan 31 '13 at 21:31