13

I saw some explanation here how to shift the origin. But at the end of the environment it is reverted.

What I want is a command that shifts without reverting it. I thought this might be possible with nodes. But this is just an idea for a work around.

I tried the command \scope[shift={(0,-5)}] and it - of course - didn't work.

What I want to achieve is something like this:

\draw [->, very thick] (0, 0) -- (0,-1);
\scope[shift={(0,-1)}]
\draw [->, very thick] (0, 0) -- (0,-1);
\scope[shift={(0,-1)}]
\draw [->, very thick] (0, 0) -- (0,-1);

resulting in three chained arrows. I'm aware that this might be achieved in other ways, but some command like this would be in my opinion very useful.

2 Answers 2

14

I'm not sure of the usefulness of this approach, but \tikzset can alter most of tikz parameters from the point it appears on, so...

\documentclass[tikz, border=5pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw [->, very thick] (0, 0) -- (0,-1);
    \tikzset{shift={(0,-1)}}
    \draw [->, very thick] (0, 0) -- (0,-1);
    \tikzset{shift={(0,-1)}}
    \draw [->, very thick] (0, 0) -- (0,-1);
\end{tikzpicture}
\end{document}

Result

4
  • Where can I find this list of parameters. I havent found it in the documentation (yet). Feb 14, 2017 at 18:22
  • 1
    Any option you can pass to a scope, or even to a tikzpicture can be set via \tikzset, so for example, rotate=90, x=0.5cm, every node/.style={whatever}, etc.
    – JLDiaz
    Feb 14, 2017 at 18:24
  • The usefulness of this approach is, that I can create tikz pictures which change with different parameters (i.e. \textwidth). This way I can make full dynamic diagrams. i.e. If I change the middle arrow in size or direction, the bottom arrow follows. Feb 14, 2017 at 18:29
  • @MaestroGlanz I understand, but I think that dynamic diagrams (i.e: which can adapt to layout changes) can be created also with the help of tikz positioning library (and/or calc expressions, named coordinates, etc.)
    – JLDiaz
    Feb 14, 2017 at 19:04
4
\draw [->] (0, 0) -- (0,-1);
\begin{scope}[yshift=-1cm]
\draw [->] (0, 0) -- (0,-1);
\end{scope}
\begin{scope}[yshift=-2cm]
\draw [->] (0, 0) -- (0,-1);
\end{scope}

enter image description here

Note:

  • as experienced TeX.SE user you should provide complete small document and with this helps people who would be willing help you. Above example I test in my tikzpicture test-bed, which setting can differ from your document, so I didn't provide them.
  • scope[<options>] is wrong syntax, correct is \begin{scope}[<options>] ... \end{scope}
  • each shift of scoped part of image code is relative to coordinate (0,0), sou you need accordingly increase shift amount, otherwise the second shifted image part will overlap previous one.
  • for shift in only one direction you can use xshift=... or yshift=...
4
  • 2
    I think the OP was aware of the proper use of scope but he wondered if it would be possible to "permanently" change the origin, so that each new shift is accumulative, so you don't need to mentally track the "total" shifting, hence my answer.
    – JLDiaz
    Feb 14, 2017 at 18:20
  • I know that it is wrong. If you read the question carefully, I dont want to use an environment. The solution with tikzset is what I was looking for. scope was just how it Should work. Feb 14, 2017 at 18:20
  • @MaestroGlanz, I read your question carefully and didn't found anything what you now claim, that it is in question ... and, if you know, that scope[...] doesn't work, why than you use it? You should then emphasize that this is pseudo code ...
    – Zarko
    Feb 14, 2017 at 18:33
  • @JLDiaz, it seems that you have crystal ball by which you can see in questions more than we others can :-) ... I like to have one, at list for while :-) :-)
    – Zarko
    Feb 14, 2017 at 18:35

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.