1

How do I draw a 4x4 grid over the following TikZ diagram using \foreach? Is it preferable to do so with one \foreach command?

\documentclass{amsart}
\usepackage{mathtools}

\usepackage{tikz}
\usetikzlibrary{calc,intersections}



\begin{document}

\noindent \begin{minipage}{3.5in}
\noindent \raggedright{\textbf{1.) }The following figure is composed of quarter-arcs \\
of circles of radii 1, 2, 3, and 4. Calculate the area \\
enclosed by the polygon.}
\end{minipage}
%
\hspace{0.25cm}
%
\raisebox{0mm}[0mm][0mm]
{
\begin{tikzpicture}[baseline=(current bounding box.west)]

\path[draw=blue, fill=blue!50] ({(3/4)*4},0) -- (0,0) arc (180:90:{(3/4)*4}) -- ({(3/4)*4},0) -- cycle;
\path[fill=white] ({(3/4)*4},{(3/4)*1}) -- ({(3/4)*1},{(3/4)*1}) arc (180:90:{(3/4)*3});
\path[fill=blue!50] ({(3/4)*3},{(3/4)*1}) -- ({(3/4)*1},{(3/4)*1}) arc (180:90:{(3/4)*2}) -- cycle;
\draw[blue] ({(3/4)*1},{(3/4)*1}) arc (180:90:{(3/4)*2});
\path[fill=white] ({(3/4)*3},{(3/4)*2}) -- ({(3/4)*2},{(3/4)*2}) arc (180:90:{(3/4)*1});
\draw[blue] ({(3/4)*2},{(3/4)*2}) arc (180:90:{(3/4)*1});
\path[fill=white] ({(3/4)*4},{(3/4)*2}) -- ({(3/4)*4},{(3/4)*0}) arc (270:180:{(3/4)*2});
\draw[blue] ({(3/4)*4},{(3/4)*0}) arc (270:180:{(3/4)*2});

%A 4 \times 4 lattice grid is drawn.
%\foreach \x in {0,1,2,3} {\draw ({(3/4)*\x},0) -- ({(3/4)*\x},{(3/4)*1});}
%\foreach \y in {0,1,2,3} {\draw (0,{(3/4)*\y}) -- ({(3/4)*1},{(3/4)*\y});}

\end{tikzpicture}
}


\end{document}

closed as off-topic by Sebastiano, Mensch, Andrew Swann, user121799, Mico May 26 '18 at 2:28

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    \draw (0,0) grid[step=3/4] (3,3); – percusse May 20 '18 at 14:24
  • 2
    If you really want a foreach solution, you can try \foreach\t in {0,.75,...,3}\draw (\t,0)--(\t,3) (0,\t)--(3,\t);. – Kpym May 20 '18 at 14:41
  • 1
    @Adelyn No reason, you can use any valid macro name : \t, \x,\bingo,... (even ~ is ok if you don't need unbreakable spaces inside the loop). – Kpym May 21 '18 at 7:07
  • 1
    Also, \x0-\x2, \y0-\y2 and \p0-\p2 are used as pseudo-registers in TikZ. There might be odd effects caused by redefining \x, \y or \p inside a foreach loop. – John Kormylo May 21 '18 at 18:53
  • 4
    I'm voting to close this question as solved in comments. – Sebastiano May 25 '18 at 22:49

Browse other questions tagged or ask your own question.