I suck at drawing with TikZ, and it takes forever, so I decided I need a new approach. When I use Illustrator and Inkscape, I like to start with a grid; like graph paper. So now I do this (below), so I have a huge canvas, and all I have to do is join the dots (vertices). Then when I'm done, I can just stick a % in front of \draw (0,0) grid (100,100); and the grid's gone.

enter image description here 10⨉10

enter image description here 100⨉100

What I want now, is to label each node with it's corresponding coordinates (yes, all of them), so I can sketch things up real quick and not waste so much time guessing and re-compiling. Either on each vertex or in the adjacent space should be fine, but if possible without getting in the way too much (maybe hiding in the corner with in a discrete tone or semi-transparency; something practical). If I could solve it programmatically and with a loop, rather than having to type each coordinate manually, that would obviously be ideal. Anyway, here's the MWE:

\draw (0,0) grid (100,100);

It is not too difficult to apply some surgery to this great answer but I am not sure how helpful this is. If it's not, or if LoopSpace wants to write an answer, I'll be happy to delete this.

\makeatletter% from https://tex.stackexchange.com/a/39698/121799
  labeled grid/.style={
    to path={%
        \draw[minor help lines] (\tikztostart) grid (\tikztotarget);
        \draw[major help lines] (\tikztostart) grid (\tikztotarget);
        \pgfmathsetmacro{\grd@xc}{\grd@xa + \pgfkeysvalueof{/tikz/grid with coordinates/major step}}
        \pgfmathsetmacro{\grd@yc}{\grd@ya + \pgfkeysvalueof{/tikz/grid with coordinates/major step}}
        \foreach \x in {\grd@xa,\grd@xc,...,\grd@xb}
        \node[anchor=north] at (\x,\grd@ya) {\pgfmathprintnumber{\x}};
        \foreach \y in {\grd@ya,\grd@yc,...,\grd@yb}
        \node[anchor=east] at (\grd@xa,\y) {\pgfmathprintnumber{\y}};
        \path foreach \x in {\grd@xa,\grd@xc,...,\grd@xb}
        {foreach \y in {\grd@ya,\grd@yc,...,\grd@yb}
         { (\x,\y) node[grid with coordinates/grid label] {$(\pgfmathprintnumber{\x},\pgfmathprintnumber{\x})$}}};
  minor help lines/.style={
    help lines,
    step=\pgfkeysvalueof{/tikz/grid with coordinates/minor step},
  major help lines/.style={
    help lines,
    line width=\pgfkeysvalueof{/tikz/grid with coordinates/major line width},
    step=\pgfkeysvalueof{/tikz/grid with coordinates/major step}
  grid with coordinates/.cd,
  minor step/.initial=.2,
  major step/.initial=1,
  major line width/.initial=2pt,
  grid label/.style={below left,scale=0.5,opacity=0.5}

\draw (0,0) to[labeled grid] (10,10);

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.