2

I made a page with a coordinate system (shown in red) with (0,0) at the top left corner of the page and coordinates increasing towards the bottom right of the page.

Now I would like to set up a rotated scope (shown in green) for the right half of the page, like this:

layout

\documentclass{article}
\pagestyle{empty}
\usepackage[paperheight=17cm,paperwidth=23cm]{geometry}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[
        every node/.style={draw, rectangle},
        remember picture, overlay,
        shift={(current page.north west)},yscale=-1 % (0,0) at the top left corner
    ]

        \begin{scope}[shift={(current page.south)},rotate=90,transform shape]
        \begin{scope}[xscale=-1,yscale=-1]
        \node at (0,0){B};
        \node at (1,1){F};
        \end{scope}
        \end{scope}
    \end{tikzpicture}
\end{document}

But whenever I got the direction of the coordinates right, the contents is mirrored:

screenshot

It's like the inner scope inherits the "transform shape" of the outer scope or something.

  • This is because of transform shape, which subjects the shapes to the transformations xscale=-1,yscale=-1. – Schrödinger's cat Oct 21 '19 at 19:07
2

Yes, the inner scopes inherit the keys from the ambient scopes. This is the main reason why nesting tikzpictures is a problem. You may use transform shape=false in the inner scope.

\documentclass{article}
\pagestyle{empty}
\usepackage[paperheight=17cm,paperwidth=23cm]{geometry}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[
        every node/.style={draw, rectangle},
        remember picture, overlay,
        shift={(current page.north west)},yscale=-1 % (0,0) at the top left corner
    ]

        \begin{scope}[shift={(current page.south)},rotate=90,transform shape]
        \begin{scope}[xscale=-1,yscale=-1,transform shape=false]
        \node at (0,0){B};
        \node at (1,1){F};
        \end{scope}
        \end{scope}
    \end{tikzpicture}
\end{document}

enter image description here

  • Then the rotation is gone, too. The node should still be rotated. – AndreKR Oct 21 '19 at 19:26
  • @AndreKR Well, how would I know? You can add nodes={rotate=90}. – Schrödinger's cat Oct 21 '19 at 20:16
2

Ok, I found the issue:

transform shape is a property of the node, not a property of the scope, so there is no way to say "apply the rotate to the nodes, but not the xscale".

However, xscale and yscale are not necessary to set up a local coordinate system. I'm not sure why I used them in the first place, but x and y work just as well, and because they are not transformations they do not distort the contents:

\documentclass{article}
\pagestyle{empty}
\usepackage[paperheight=17cm,paperwidth=23cm]{geometry}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[
        every node/.style={draw, rectangle},
        remember picture, overlay,
        shift={(current page.north west)},y=-1cm % (0,0) at the top left corner
    ]

        \begin{scope}[shift={(current page.south)},rotate=90,transform shape]
        \node at (0,0){B};
        \node at (1,1){F};
        \end{scope}
    \end{tikzpicture}
\end{document}

screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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