I want to create a 32 by 32 grid as shown below. enter image description here

And I also want to add two labeling in x and y directions.

1) 0 - 31 (grid number)

2) 0- 1 (box unit)

I a next slide I have to draw a new box starting from grid number 8 and ends on the grid number 23.

And in the next level I have to add another box which has to start from grid number 12 and should end on grid number 19.

Is there any method to accomplish this ? I tried with TikZ

\draw and \fill

commands. But not giving any desirable result. Please suggest any method to achieve this.

Thank you.

  • 3
    Welcome to TeX.SX! Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – darthbith Sep 8 '14 at 11:55
  • 3
    Use \draw [help lines,step=1 or 0.5](0,0) grid (31,31); An example may be here tex.stackexchange.com/a/199898/34618 – Jesse Sep 8 '14 at 12:01
  • 1
    I would strongly recommend to have a look to the nice showgrid library. – Claudio Fiandrino Sep 8 '14 at 12:32

Here a short MWE. See the pgfmanual for descriptions. Adjust the scale-option to your needs (to get the image fit to your page-size)

\documentclass[tikz, border=5mm]{standalone}
  % Grid
  \draw [step=1, dotted] (0,0) grid (31,31);

  % Grid units
  \foreach \x in {0,...,31} {
   \node [below] at (\x,0) {\x};
   \node [left]  at (0,\x) {\x};

  % Box units
  \draw [<->, shorten >= .5cm, shorten <= .5cm] (0,-1.5) node {0} -- ++(31,0) node {1};
  \draw [<->, shorten >= .5cm, shorten <= .5cm] (-1.5,0) node {0} -- ++(0,31) node {1};

  % Inner rectangles
  \draw [red, ultra thick] (8,8) rectangle (23,23);
  \draw [blue, ultra thick] (12,12) rectangle (19,19);

Rendered image: rendered image


Jesse's comment is probably easiest, but something along the lines of the code below works, also




\foreach\x in {0,...,31} \draw(\x,31)--(\x,0) node[anchor=north]{\x} (31,\x)--(0,\x) node[anchor=east]{\x}; 


Just for fun solution with PSTricks.


enter image description here

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.