50

I am using Tikz to draw a wide graph but starting from left and after reaching the middle of the graph the nodes fall outside of page. I tried playing with scale but the graph distorts and texts inside nodes does not conform to new scale well. So I need to move the (0,0) to some place left, say (-5,0) to have enough space to draw the rest of graph. How can I do that? I saw the shifting command in the manual but it was command specific and converting the coordinates is somehow overkill.

How can I shift the (0,0) to a new coordinate, say (-5,0)?

72

If you want to do exactly this, then put whatever you want to move in a scope, and provide the shift option to said scope (the curly braces are necessary so the comma isn't thought to separate options). Something like

\begin{tikzpicture}
  \begin{scope}[shift={(-5,0)}]
    ... graph goes here ...
  \end{scope}
  ... other code goes here ...
\end{tikzpicture}

However, if your whole picture is wider than the text, this won't help. In that case, you should be able to use a negative horizontal space:

\hspace*{-5cm}%
\begin{tikzpicture}
  ... picture goes here ...
\end{tikzpicture}

However, if you want centering, you could check out some of the solutions to a similar problem with over-wide tables, such as surrounding it in a zero-width box.

  • Is there another possibility to shift the origin than in a environment? I tried \scope[shift={(0,-5)}]. It is no surprise, that it didnt work. I want to shift it several times throughout the TikZ-picture. – MaestroGlanz Feb 14 '17 at 17:06
  • @MaestroGlanz: I don't know, off the top of my head – sounds like a great new question to ask here! – Antal Spector-Zabusky Feb 14 '17 at 17:09
  • 1
    For cross reference: here is the new question: tex.stackexchange.com/questions/353855/… – MaestroGlanz Feb 14 '17 at 18:32

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.