tikz: set appropriate x value for a node
Posted
by basweber
on Stack Overflow
See other posts from Stack Overflow
or by basweber
Published on 2010-05-05T22:21:10Z
Indexed on
2010/05/05
22:28 UTC
Read the original article
Hit count: 386
This question resulted from the question here
I want to produce a curly brace which spans some lines of text. The problem is that I have to align the x coordinate manually, which is not a clean solution.
Currently I use
\begin{frame}{Example}
\begin{itemize}
\item The long Issue 1
\tikz[remember picture] \node[coordinate,yshift=0.7em] (n1) {}; \\
spanning 2 lines
\item Issue 2
\tikz[remember picture] \node[coordinate, xshift=1.597cm] (n2) {};
\item Issue 3
\end{itemize}
\visible<2->{
\begin{tikzpicture}[overlay,remember picture]
\draw[thick,decorate,decoration={brace,amplitude=5pt}]
(n1) -- (n2) node[midway, right=4pt] {One and two are cool};
\end{tikzpicture}
} % end visible
\end{frame}
which produces the desired result:
The unsatisfying thing is, that I had to figure out the xshift value of 1.597cm by trial and error (more or less)
Without xshift argument the result is:
I guess there is an elegant way to avoid the explicit xshift value.
The best way would it imho be to calculate the maximum x value of two nodes and use this, (as already suggested by Geoff)
But it would already be very handy to be able to explicitly define the absolute xvalues of both nodes while keeping their current y values. This would avoid the fiddly procedure of adapting the third post decimal position to ensure that the brace looks vertical.
© Stack Overflow or respective owner