Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tikz, shifting scope of nodes ...

789 views
Skip to first unread message

Zarko F. Cucej

unread,
Jan 15, 2010, 8:37:39 PM1/15/10
to
Hi,
please consider the following example:
%------------------------------------------
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}% picture 1
\node[name=a] {a};
\node[name=b] at ([yshift=-21mm]a) {b};
\end{tikzpicture}\qquad
\begin{tikzpicture}% picture 2
\node[name=a] {a};
\begin{scope}[yshift=-21mm]
\node[name=b] at (a) {b};
\end{scope}
\end{tikzpicture}
\end{document}
%------------------------------------------

Why the second picture doesn't give the same result as the first one? Is
this behaviour of scope of nodes intentional? If I give absolute
coordinates to nodes, then both pictures gives the same (expected)
result -- move the node "b" from "a" for 21mm down.

Regards,
Zarko

Zarko F. Cucej

unread,
Jan 20, 2010, 5:10:29 PM1/20/10
to

Any response to above described behaviour of "scope" in TikZ I will very
appreciated. Using the first example instead grouping by "scope" is in
the case of large set of nodes really annoying.

Regards, Zarko

Stefan Pinnow

unread,
Jan 21, 2010, 3:10:09 AM1/21/10
to
Hello Zarko,
the answer came on the pgf-user mailing list (Mark Wibrow):

Nodes are `a bit special' in that their anchors are returned absolutely
independently of the current coordinate transformation.

This can be seen to be desirable as the construction of a connecting path could
be transformed (i.e., shifted, scaled, or rotated) in some way, but would still
need to access the correct untransformed anchors of the node in order to connect
correctly.

It is possible to transform node coordinates by adding transform options to
coordinates them selves, for example:

\draw ([xshift=1cm]A) -- ([yshift=1cm]B);


Regards
Stefan Pinnow


"Zarko F. Cucej" <zarko...@gmail.com> schrieb im Newsbeitrag
news:hbL5n.453$UU2....@news.siol.net...

Zarko F. Cucej

unread,
Jan 21, 2010, 8:00:32 PM1/21/10
to
On 21.1.2010 9:10, Stefan Pinnow wrote:
> Hello Zarko,
> the answer came on the pgf-user mailing list (Mark Wibrow):
>
> Nodes are `a bit special' in that their anchors are returned absolutely
> independently of the current coordinate transformation.
>
> This can be seen to be desirable as the construction of a connecting path could
> be transformed (i.e., shifted, scaled, or rotated) in some way, but would still
> need to access the correct untransformed anchors of the node in order to connect
> correctly.
>
> It is possible to transform node coordinates by adding transform options to
> coordinates them selves, for example:
>
> \draw ([xshift=1cm]A) -- ([yshift=1cm]B);
>
>
> Regards
> Stefan Pinnow


Dear Stefan Pinnow,
thank you for your information. I do not read pgf-user mailing list, so
probably this be good idea for learn more about pgf/tikz. Anyway, I
afraid that this behaviour is feature ... in my case this is pity, since
I should now find another solution for code of my sketch.


Regards,
zarko

Stefan Pinnow

unread,
Jan 22, 2010, 2:18:18 AM1/22/10
to
Dear Zarko,
perhaps you could write a feature request to add an option which handles both
"wanted" behaviours.

If you will start reading the pgf-mailing list you can directly post it there,
otherwise write it here and I will forward it.


Best regards,
Stefan


Alain Matthes

unread,
Jan 22, 2010, 2:59:52 AM1/22/10
to


Hi

Normal. From pgfmanual

"The most important aspect of the coordinate transformation matrix
is that it applies to coordinates only! In particular, the coordinate
transformation has no effect on things like the line width or the dash
pattern or the shading angle. In certain cases, it is not immediately
clear whether the coordinate transformation matrix should apply to a
certain dimension. For example, should the coordinate transformation
matrix apply to grids? (It does.) And what about the size of arced
corners? (It does not.) The general rule is “If there is no
‘coordinate’ involved, even ‘indirectly,’ the matrix is not applied.”
However, sometimes, you simply have to try or look it up in the
documentation whether the matrix will be applied.
Setting the matrix cannot be done directly. Rather, all you can do is
to “add” another transformation to the current matrix. However, all
transformations are local to the current TEX-group."

yshift is a transformation
but now you can see the result of

\documentclass{minimal}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[scale=2]


\node[name=a] {a};
\node[name=b] at ([yshift=-21mm]a) {b};
\end{tikzpicture}

\hspace{1cm}
\begin{tikzpicture}[scale=2]
\node[name=a] {a};
\node[name=b,yshift=-21mm] at (a) {b};
\end{tikzpicture}
\end{document}


And you have the same problem with the "positioning" library

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\begin{tikzpicture}[scale=2]
\node[name=a] {a};
\node[name=b,above=-21mm of a] {b};
\end{tikzpicture}
\end{document}

By default, I suppose you don't want labels are rotated or scaled, and
I suppose
it's the same for line width
Now you can use "transform shape" but the results are ugly is some cases

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[scale=2]


\node[name=a] {a};
\node[name=b] at ([yshift=-21mm]a) {b};
\end{tikzpicture}

\hspace{1cm}
\begin{tikzpicture}[scale=2]
\node[name=a] {a};
\begin{scope}[transform shape]
\node[name=b,yshift=-21mm] at (a) {b};
\end{scope}

\end{tikzpicture}
\begin{tikzpicture}[scale=2]
\node[name=a] {a};
\begin{scope}[transform shape]
\node[name=b,above=-21mm of a] {b};


\end{scope}
\end{tikzpicture}
\end{document}

now a solution but ...

\begin{tikzpicture}[]


\node[name=a] {a};
\begin{scope}[yshift=-21mm]

\pgfextractx{\xdim}{(a)}
\pgfextractx{\ydim}{(a)}
\node[name=b] at (\xdim,\ydim) {b};
\end{scope}
\end{tikzpicture}

and more ugly but fun

\begin{tikzpicture}[]


\node[name=a] {a};
\begin{scope}[yshift=-21mm]

\pgfextractx{\xdim}{(a)}
\pgfextractx{\ydim}{(a)}
\coordinate(a) at (\xdim,\ydim) {};


\node[name=b] at (a) {b};
\end{scope}
\end{tikzpicture}

Best regards
Alain Matthes

Zarko F. Cucej

unread,
Jan 22, 2010, 4:10:02 AM1/22/10
to
Dear Stefan
thank you for your care. I will star to read pgf-mailing list, but not
before as begining of February ... i just now go to real (short)
vacation where is no internet ... :-)

Meanwhile I manage my problem as you suggest. Fortunately, there
copy-past has been of big help.

Regrads,
Zarko

Zarko F. Cucej

unread,
Jan 22, 2010, 4:16:20 AM1/22/10
to


Dear Alain,
thank you very much for detailed elaboration of the problem. I will
carefully go through your examples after my returning home.

Best regards,
Zarko


[...]

0 new messages