i would like to obtain this effect
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\clip (-1ex,-12pt) rectangle (1ex,12pt);
\node [align=center] (text) {A \\ B \\ C};
\end{tikzpicture}
\end{document}
but i cannot find a way to clip the node that is still to be drawn, something like
\clip ($(text.south west) + (0,6pt)$) rectangle ($(text.north east) - (0,6pt)$);
how can i achieve it without explicit use of the position to clip?
Best Answer
Ah, this looks like a job for
\pgfpositionnodelater
! If you call this command in a local scope, subsequently defined nodes won't be typeset straight away, but their content will be saved into a box and the edge coordinates can be saved to macros. You can then use the node aliasnot yet positioned@<node name>
to set up your clip path, and then load the edge coordinates and typeset the node using\pgfpositionnodenow
.EDIT by percusse
If you want to use the TikZ frontend for a similar effect, you can use
append after command
key as follows:Roughly speaking, it nests the path construction and node placement in the desired order. The counterpart in terms of the order is given by the
prefix after command
. This allows us to use the name of the node to-be-created in advance. However, its use is quite limited as stated in the manual. You can not change the structural properties such as shape,color etc of the node.