# How to create a 32 by 32 grid?

I want to create a 32 by 32 grid as shown below. 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.

• 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
• 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
• 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}
\begin{document}
\begin{tikzpicture}[scale=.5]
% 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);
\end{tikzpicture}
\end{document}


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

\documentclass{article}

\usepackage[margin=1in]{geometry}
\usepackage{tikz}

\begin{document}

\begin{center}
\begin{tikzpicture}[scale=0.5]
\foreach\x in {0,...,31} \draw(\x,31)--(\x,0) node[anchor=north]{\x} (31,\x)--(0,\x) node[anchor=east]{\x};
\end{tikzpicture}
\end{center}

\end{document}


Just for fun solution with PSTricks.

\documentclass[pstricks,border=15mm,12pt]{standalone}
\psset{unit=6mm,dimen=monkey,linewidth=2pt}
\begin{document}
\begin{pspicture}[showgrid](31,31)
\psframe[linecolor=red](8,8)(23,23)
\psframe[linecolor=blue](12,12)(19,19)
\rput(0,-1.5){0}\rput(31,-1.5){1}\psline{<->}(1,-1.5)(30,-1.5)
\rput(-1.5,0){0}\rput(-1.5,31){1}\psline{<->}(-1.5,1)(-1.5,30)
\end{pspicture}
\end{document}
{"ft_lang_label":"__label__en","ft_lang_prob":0.90527076,"math_prob":0.97202873,"size":742,"snap":"2019-43-2019-47","text_gpt3_token_len":220,"char_repetition_ratio":0.11517615,"word_repetition_ratio":0.0,"special_character_ratio":0.32345015,"punctuation_ratio":0.10982659,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9859834,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-20T09:46:44Z\",\"WARC-Record-ID\":\"<urn:uuid:4e6b7928-54fd-4f01-9957-ca7f55e1461d>\",\"Content-Length\":\"149491\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b22a551e-c010-416f-918f-315c4e09529f>\",\"WARC-Concurrent-To\":\"<urn:uuid:1edadd32-cdab-478f-bae6-9fbe94eb0a5b>\",\"WARC-IP-Address\":\"151.101.1.69\",\"WARC-Target-URI\":\"https://tex.stackexchange.com/questions/200144/how-to-create-a-32-by-32-grid?noredirect=1\",\"WARC-Payload-Digest\":\"sha1:43YGJCMYOWEKZBEBZQ4NCYDMTD3XNDAK\",\"WARC-Block-Digest\":\"sha1:OFMQ3W74YPCPPMT2ZKCCHUZLMYLISHSB\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496670535.9_warc_CC-MAIN-20191120083921-20191120111921-00402.warc.gz\"}"}