As my figure keeps crossing the margins I end up rescaling it at the end using
\begin{tikzpicture}[scale=5/10,transform shape]. This works most of the time but it seems to me like its a hackish way of doing so. Is it possible to place nodes like we draw on a graph paper in the following manner:

  1. Draw a thin background of a 'grid' with the size of each square defined according to your needs.
  2. Use the grid to place the nodes. This way we can take precaution when deciding the size of our node objects so that we don't cross the margin.

Although I can draw a grid and select the right position of the grid by choosing the right relative coordinate, the task of selecting the coordinate becomes repetitive and painful. Is there a better way to make sure that the nodes are laid out in a tikzpicture a better way?


You can set the x and y vectors to arbitrary lengths (and directions). So you can, for example, set their lengths to \textwidth/10. Then you know that you have exactly 10 vertical units before you run out of space.


    \draw[help lines] (0,0) grid[step=1] (10,10);
    \draw (4,4) circle[radius=2];

You need the step=1 argument to grid, because the default is to have squares of 1cm width, which won't match up with the new coordinate system.

  • 1
    See also Jake's answer to tex.stackexchange.com/questions/9559/…. – Caramdir Apr 7 '11 at 16:42
  • How can I know the value of the step size so that I can use 'step' as a reference with other measurements. for example - If I want a rectangle at the coordinate (5,5) with a width=5 times the step size in the grid and height=3 times the step size in the grid. – Mir Apr 8 '11 at 14:30
  • @Meeir: is \draw (5,5) rectangle (10,8) what you want? If you need absolute measurements, you can use \textwidth/10. – Caramdir Apr 8 '11 at 16:08

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.