0

I know how to create a grid by using TikZ and the following:

\documentclass[a4paper,10pt,table]{book}
\usepackage{tikz}
\usetikzlibrary{arrows,plotmarks}
\def\quadrill#1{\smallbreak\textcolor{gray}     {\setlength\unitlength{5mm}\begin{picture}(36,#1)
\multiput(0,0)(1,0){37}{\line(0,1){#1}}
\put(0,0){\line(1,0){36}}
\multiput(0,1)(0,1){#1}{\line(1,0){36}}
\end{picture}}\medbreak}

\newenvironment{Quadrill}[1]{\quadrill#1}{}

\begin{document}
\Quadrill{12}   
\end{document}

My aim is now to add a counter, for example a big number in the upper left corner area of my grids. Unfortunately, I am not able to adapt the previous code.

  • 2
    I'm confused. You are loading TikZ but seem not to make use of it. Would you be interested in a TikZ based solution? – marmot Apr 17 '18 at 17:01
  • A solution using Tikz would be as good. Thank you for your help. – jowe_19 Apr 17 '18 at 17:08
1
\documentclass[a4paper,10pt,table]{book}
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{calc}
\newcommand{\quadrill}[2][]{\smallbreak\noindent\begin{tikzpicture}[gray]
\draw (0,0) grid[step={\linewidth/36}] (\linewidth,{\linewidth/36});
\node[anchor=south west,gray] at (0,{\linewidth/36}) {#2};
\end{tikzpicture}\medbreak}
\newenvironment{Quadrill}[1]{\quadrill{#1}}{}

\begin{document}
\Quadrill{12}   
\end{document}

enter image description here

  • It works fine. I just changed a little bit the code in order to print and to increment automatically the counter together with the section. – jowe_19 Apr 17 '18 at 20:26
  • @jowe_19 If the solution worked for you please see How do you accept an answer? and perhaps How does accepting an answer work?. – marmot Apr 17 '18 at 20:28
  • \newcounter{NoQuadrill} \newcommand{\quadrill}[1]{\smallbreak\begin{tikzpicture} [scale=0.5,gray] \draw(0,0) grid (34,#1); \node[anchor=north west] at (31.5,1.1) {\color{blue}\bfseries\Large{\thesection.\theNoQuadrill}}; \end{tikzpicture}\medbreak} \newenvironment{Quadrill}[1] {\refstepcounter{NoQuadrill}\quadrill{#1}}{} – jowe_19 Apr 17 '18 at 20:28
  • @jowe_19 That's all very nice, but was that part of your question? – marmot Apr 17 '18 at 20:29

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.