# why is beamer breaking this tikz picture

I am trying to get this graphic to work and it does, if not used in beamer but in article for example.

this here produces some errors:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\tikzset{%
box/.style={%
minimum height=5mm,
inner sep=.7mm,
outer sep=0mm,
text width=10mm,
text centered,
draw,
fill=white,
line width=.25mm,
rounded corners=2.3mm,
rotate=0,
},
}
\begin{frame}{title}
\begin{tikzpicture}[x=13mm,y=9mm]
% Pascal's triangle
% row #0 => value is 1
\node[box] (p-0-0) at (0,0) {1};
\foreach \row in {1,...,5} {%
% col #0 =&gt; value is 1
\node[box] (p-\row-0) at (-\row/2,-\row) {1};
\pgfmathsetmacro{\value}{1};
\foreach \col in {1,...,\row} {%
% iterative formula : val = precval * (row-col+1)/col
% (+ 0.5 to bypass rounding errors)
\pgfmathtruncatemacro{\value}{\value*((\row-\col+1)/\col)+0.5};
\global\let\value=\value
% position of each value
\coordinate (pos) at (-\row/2+\col,-\row);
% odd color for odd value and even color for even value
\pgfmathtruncatemacro{\rest}{mod(\value,2)}
\ifnum \rest=0
\node[box] (p-\row-\col) at (pos) {\value};
\else
\node[box] (p-\row-\col) at (pos) {\value};
\fi
% for arrows and plus sign
\ifnum \col<\row
\node[above=0mm of p-\row-\col]{+};
\pgfmathtruncatemacro{\prow}{\row-1}
\pgfmathtruncatemacro{\pcol}{\col-1}
\fi
}
}
\end{tikzpicture}
\end{frame}

\end{document}


the errors:

! Missing number, treated as zero.
{
l.56 \end{frame}

?
! Illegal unit of measure (pt inserted).
{
l.56 \end{frame}

?
! Missing number, treated as zero.
\kern
l.56 \end{frame}

?
! Illegal unit of measure (pt inserted).
\kern
l.56 \end{frame}

?


Any Idea what I could do to get beamer to cooperate with this tikz?

-

The macro \value already has a meaning in LaTeX and in the line \global\let\value=\value then you are overwriting it. beamer complains because it uses \value in the frame trickery. article doesn't complain on just the diagram because \value isn't used if this picture is all there is, but it would complain as soon as you tried to do something using a counter (since that's what \value is for).

In short, rename \value to something "safe" such as \myvalue and it compiles.

-
well - I thank you a lot! sometimes the solution is so simple - if you know the backgrounds. –  Garonenur Apr 24 '14 at 11:07