# Example of a complex compound tikz math statement

Could someone provide an example of a complex compound mathematical statement in tikz as I find that most of the answers out there are difficult to understand or lacking. I want a MWE example like this one (note, this one does not compile)

\documentclass[landscape]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\newcommand{\tableXOff}{0.4}
\newcommand{\tableYOff}{0.1}
\newcommand{\tableW}{0.5}
\newcommand{\tableH}{0.2}
\newcommand{\xShift}{2}

\usepackage[top=1in,bottom=1in,right=1in,left=1in]{geometry}
\begin{document}
\begin{tikzpicture}[scale=5.3,cap=round,>=latex]
\draw[blue,ultra thick] (-2cm,-2cm) rectangle (2cm,2cm);
\foreach \x in {0,1,...,3} {%
\fill[brown] (\x*(\tableXPad+\tableW)+\tableXOff-\xShift,-\tableYOff) rectangle (\x*0.9+\tableXOff+\tableW-\xShift,-\tableYOff-\tableH);
}
\end{tikzpicture}
\end{document}


So I don't go blind trying to read values, but instead use variables. Unfortunately, the parantheses around (\tableXPad+\tableW) cause an error. How do I get around this?

-
Put braces around (I think) the first entry in the problematic ordered pair. – Charles Staats Apr 11 '14 at 5:00
@CharlesStaats please include an answer with an example as the very first thing I did was bullet riddle the statement with curly brackets – puk Apr 11 '14 at 5:02

Put braces around the entry in the ordered pair that contains the problematic parentheses:

\documentclass[margin=10pt,convert]{standalone}
\usepackage{tikz}

\newcommand{\tableXOff}{0.4}
\newcommand{\tableYOff}{0.1}
\newcommand{\tableW}{0.5}
\newcommand{\tableH}{0.2}
\newcommand{\xShift}{2}

\usepackage[top=1in,bottom=1in,right=1in,left=1in]{geometry}
\begin{document}
\begin{tikzpicture}[scale=5.3,cap=round,>=latex]
\draw[blue,ultra thick] (-2cm,-2cm) rectangle (2cm,2cm);
\foreach \x in {0,1,...,3} {%
\fill[brown] ({\x*(\tableXPad+\tableW)+\tableXOff-\xShift},-\tableYOff) rectangle (\x*0.9+\tableXOff+\tableW-\xShift,-\tableYOff-\tableH);
}
\end{tikzpicture}
\end{document}


The result:

-
Sorry. I didn't see your answer when I posted mine. – A.Ellett Apr 11 '14 at 5:10
Actually, I think our posted answers were essentially simultaneous. – Charles Staats Apr 11 '14 at 5:12