There were/are certain problems in your code:
The first one, as pointed out by Jake, was that you used a node where you should use a coordinate (which is a shape-less node, namely only a point).
Then, as pointed out by TorbjørnT., you inserted a spurious space at the end of \tikzstyle assignment. The \tikzstyle macro is long deprecated and should be replaced with the more flexible \tikzset. This wouldn't have helped with the space, though. I advice you to move any global assignments in the preamble where you don't have to take care of spaces. Is this style only used in this TikZ picture in your document, move its declaration to the optional argument of \begin{tikzpicture} (or use a \tikzset inside the environment where it normally doesn’t create a space either):
\begin{tikzpicture}[frame/.style={…, …}]
Then we have the right of syntax which is also deprecated. Use the positioning library and the right=of <lastnode> syntax.
You don’t even need this auxiliary code if you check inside the \foreach loop whether you have the first node or not:
\ifnum\framenum=1
\node[frame] (f\framenum) {…};
\else
\node[frame, right=of f\lastframenum] (f\framenum) {…};
\fi
There is also no need for the \intCalcDec macro, you have used the remember option of the \foreach loop:
\foreach \framenum[remember=\framenum as \lastframenum] in {1,...,7}{
or you could just do the calculation with eTeX’s \numexpr:
\node [frame, right=of f\number\numexpr\framenum-1\relax] (f\framenum) {…};
Take a look at reference 5 for a small overview on this topic.
While the intcalc package is surely a great package; PGF has a lot of mathematical functions built-in, which we can use in the evaluate option of the \foreach loop:
\foreach \frameNum[
evaluate=\frameNum as \frameAngle using {int(8*(mod(\frameNum,3)-1))}
] in {1,...,7}
But why go through all that trouble when the TikZ’ chains library does all the work for us when we starta chain at the overlaying scope level (the tikzpicture implies a scope), and then set every node on this chain.
Without the frame style definition this becomes nearly a one-liner:
\begin{tikzpicture}[start chain]
\foreach \frameNum[
evaluate=\frameNum as \frameAngle using {int(8*(mod(\frameNum,3)-1))}
] in {1,...,7}
\node [frame, on chain] (f\frameNum){$f_\frameNum$ $\frameAngle^\circ$};
\end{tikzpicture}
I also switched to the minimum size option (which sets minimum height and minimum width, and inserted an manual linebreak.
TorbjørnT. also detected that the height of the nodes is not always the same, and in fact the minus sign seems to add a depth to the last line. We can overwrite this by setting text depth to 0pt which will only work for the last line. For other cases, you can use the \smash macro and/or (provided by the amsmath package) the b option: $\smash[b]{\frameAngle^\circ}$.
References
- What is the use of percent signs (%) at the end of lines?
- Should \tikzset or \tikzstyle be used to define TikZ styles?
- Difference between "right of=" and "right=of" in PGF/TikZ
- Package PGF Math Error: Unknown operator `o' or `of' (it’s an overview of the
positioning library)
- How to decrease the counter in tikz foreach loop
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{chains,positioning}
\tikzset{
frame/.style={
rectangle,
draw,
fill=blue!20,
align=center,
minimum size=2\baselineskip,
node distance=0.5cm
}
}
\begin{document}
\begin{tikzpicture}[start chain]
\foreach \frameNum[
evaluate=\frameNum as \frameAngle using {int(8*(mod(\frameNum,3)-1))}
] in {1,...,7}
\node [frame, text depth=+0pt, on chain] (f\frameNum){$f_\frameNum$\\$\frameAngle^\circ$};
\end{tikzpicture}
\end{document}
Output

\coordinateinstead of\node– Jake Apr 26 '13 at 11:51\tikzstyleadds a space character, add a%at the end of that line. I.e.... node distance=1.5cm]%. Edit: forgot a reference: http://tex.stackexchange.com/questions/7453 – Torbjørn T. Apr 26 '13 at 12:01minimum heightto2.7emfixes that. – Torbjørn T. Apr 26 '13 at 12:10\tikzsetand\tikzstyleshould go in the preamble (where they don't create spaces), when the assignments aren't local to one TikZ picture, in this case they should be used in the optional argument of the TikZ picture. – Qrrbrbirlbel Apr 26 '13 at 12:10node[label=below:hi]) – Cyriac Antony Nov 04 '19 at 07:46coorditnate[label=below:hi]. For some reason,coordinate (someName)[label=below:hi]doesn't work. – Cyriac Antony Nov 04 '19 at 07:50