3

A very simple square grid can be made with tikz:

\documentclass{article}
\usepackage[margin=.25in]{geometry}
\usepackage{tikz}
\pagestyle{empty}

\begin{document}
\centering
\tikz\draw [thin] (0,0) grid (20,26)
\end{document}

How can one make an isometric grid with tikz? I found one with PSTricks, but it is not easy to customize. And I'd like a solution that does not require PSTricks, if at all possible.

  • The answer has been updated for better use of nodes' anchors as reference points. – Ignasi Mar 22 '16 at 19:39
6

An example with kite shapes. Command \isogrid{rows}{cols} draws an isometri grid with rows+1 rows and cols+1.

Using nodes instead of pure lines, nodes anchors can help to draw over the grid.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{shapes}

\tikzset{
    iso/.style={kite, draw, kite vertex angles=120,  minimum size=1cm, outer sep=0pt}
}

\newcommand{\isogrid}[2]{
\foreach \i [count=\row from 0, remember=\row as \lastrow (initially 0)] in {0,...,#1}{
    \foreach \j [count=\col from 0, remember=\col as \lastcol (initially 0)] in {0,...,#2}{
        \ifnum\row=0
            \ifnum\col=0
                \node[iso] (\row-\col) {\row-\col};
            \else
                \node[iso, anchor=left vertex] (\row-\col) at (\row-\lastcol.right vertex) {\row-\col};
            \fi
        \else
            \ifnum\col=0
                \node[iso, anchor=upper vertex] (\row-\col) at (\lastrow-\col.lower vertex) {\row-\col};
            \else
                \node[iso, anchor=left vertex] (\row-\col) at (\row-\lastcol.right vertex) {\row-\col};
            \fi
        \fi
        }
    }
\draw (0-0.left vertex)--(#1-0.left vertex);
\foreach \i in {0,...,#2}{
    \draw (0-\i.upper vertex)--(#1-\i.lower vertex);
    \draw (0-\i.right vertex)--(#1-\i.right vertex);
}
}

\begin{document}
\begin{tikzpicture}

\isogrid{19}{9}
\begin{scope}[line width=2pt]
\draw (1-3.right vertex)--(3-5.right vertex)--(7-1.right vertex)--(5-0.left vertex)--cycle;
\draw (5-0.left vertex)--(13-0.left vertex)--(15-1.right vertex)--(7-1.right vertex);
\draw (3-5.right vertex)--(5-5.right vertex)--(7-7.right vertex)--(10-7.right vertex)--(11-8.right vertex)--(12-7.right vertex)--(13-8.right vertex)--(15-7.upper vertex)--(13-5.upper vertex)--(10-5.upper vertex)--(8-3.upper vertex)--(5-5.right vertex);
\draw (9-5.lower vertex)--(7-7.right vertex);
\draw (12-5.lower vertex)--(10-7.right vertex);
\draw (11-8.right vertex)--(16-8.right vertex)--(17-7.lower vertex)--(13-3.lower vertex)--(15-1.right vertex);
\draw (7-3.lower vertex)--(13-3.lower vertex);
\draw (14-7.lower vertex)--(17-7.lower vertex);

\draw[dashed] (13-0.left vertex)--(9-3.right vertex)--(1-3.right vertex);
\draw[dashed] (9-3.right vertex)--(14-8.right vertex)--(15-7.right vertex)--(16-8.right vertex);
\draw[dashed] (12-7.right vertex)--(15-7.right vertex);
\end{scope}
\end{tikzpicture}

\end{document}

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.