I have two diagrams (both are supposed to be the same), one with explicit draw and node commands, the other one with foreach
loops. Obviously, I don't understand foreach loops, as I can only get one to work. I followed the tikz tutorial, but it quickly got over my head. I am trying to understand tikz logic through trial and error, but I became a little discouraged after trying seemingly simple things. I need help with the other ones. I ask for a nudge in the right direction as to how I am to do this. How would I need to design my loops to shorten the code of the first diagram. The second one doesn't work, when the lines are commented in.
\documentclass{article}
\usepackage[margin=20mm]{geometry}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle +(10.5,8);
\draw (0.1,0.1) rectangle +(10.3,7.8);
\foreach \x in {1.5,4,6.5,9}
\foreach \y in {1.5,4,6.5}
\draw (\x,\y) circle (1);
\node at (1.5,1.5) {PreA30};
\node at (1.5,4) {PreB30};
\node at (1.5,6.5) {PreC30};
\node at (4,1.5) {PreA50};
\node at (4,4) {PreB50};
\node at (4,6.5) {PreC50};
\node at (6.5,1.5) {PreA70};
\node at (6.5,4) {PreB70};
\node at (6.5,6.5) {PreC70};
\node at (9,1.5) {PreA90};
\node at (9,4) {PreB90};
\node at (9,6.5) {PreC90};
\node at (1.5,-.5) {30\%};
\node at (4,-.5) {50\%};
\node at (6.5,-.5) {70\%};
\node at (9,-.5) {90\%};
\node at (-.5,1.5) {A};
\node at (-.5,4) {B};
\node at (-.5,6.5) {C};
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) rectangle +(10.5,8);
\draw (0.1,0.1) rectangle +(10.3,7.8);
\foreach \x in {1.5,4,6.5,9}
\foreach \y in {1.5,4,6.5}
\draw (\x,\y) circle (1);
% the next block actually compiles, but the result is quite alarming
% I tried a different order, but that doesn't seem to matter at all
%\foreach \x in {1.5,4,6.5,9}
% \foreach \y in {1.5,4,6.5}
% \foreach \sam in {A,B,C}
% \foreach \perc in {30,50,70,90}
% \node at (\x,\y) {Pre\sam\perc};
%
%\foreach \x in {1.5,4,6.5,9}
% \foreach \perc in {30,50,70,90}
% \node at (\x,-.5) {\perc\%};
%
%\foreach \y in {1.5,4,6.5}
% \foreach \sam in {A,B,C}
% \node at {-.5,\y} {\sam};
\end{tikzpicture}
\end{document}
With marmots answer, we get what is shown in the picture below. The first diagram is what is desired. The second diagram has superpositions of text in all nodes. I know this probably has to do more with logic than LaTeX, but still, I can't quite wrap my head around the right design of the for-loops.
{
and}
.