[Tex/LaTex] TikZ Grid Paper With Node Coordinates

diagramsdrawgraphicsgraphstikz-pgf

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:


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[12pt]{standalone}
\usepackage{tikz}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}
\draw (0,0) grid (100,100);
\end{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Best Answer

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.

\documentclass[tikz,border=3.14mm]{standalone}
\makeatletter% from https://tex.stackexchange.com/a/39698/121799
\def\grd@save@target#1{%
  \def\grd@target{#1}}
\def\grd@save@start#1{%
  \def\grd@start{#1}}
\tikzset{
  labeled grid/.style={
    to path={%
      \pgfextra{%
        \edef\grd@@target{(\tikztotarget)}%
        \tikz@scan@one@point\grd@save@target\grd@@target\relax
        \edef\grd@@start{(\tikztostart)}%
        \tikz@scan@one@point\grd@save@start\grd@@start\relax
        \draw[minor help lines] (\tikztostart) grid (\tikztotarget);
        \draw[major help lines] (\tikztostart) grid (\tikztotarget);
        \grd@start
        \pgfmathsetmacro{\grd@xa}{\the\pgf@x/1cm}
        \pgfmathsetmacro{\grd@ya}{\the\pgf@y/1cm}
        \grd@target
        \pgfmathsetmacro{\grd@xb}{\the\pgf@x/1cm}
        \pgfmathsetmacro{\grd@yb}{\the\pgf@y/1cm}
        \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},
    draw=none
  },
  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}
}
\makeatother
\begin{document}

\begin{tikzpicture}
\draw (0,0) to[labeled grid] (10,10);
\end{tikzpicture}
\end{document}

enter image description here