Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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,
  },
  link/.style={-latex,line width=.3mm},
}
\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 => 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}
        \draw[link] (p-\prow-\pcol) -- (p-\row-\col);
        \draw[link] ( p-\prow-\col) -- (p-\row-\col);
        \fi
      }
    }
  \end{tikzpicture}
\end{frame}

\end{document}

the errors:

! Missing number, treated as zero.
<to be read again> 
                   {
l.56 \end{frame}

? 
! Illegal unit of measure (pt inserted).
<to be read again> 
                   {
l.56 \end{frame}

? 
! Missing number, treated as zero.
<to be read again> 
                   \kern 
l.56 \end{frame}

? 
! Illegal unit of measure (pt inserted).
<to be read again> 
                   \kern 
l.56 \end{frame}

? 

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

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
well - I thank you a lot! sometimes the solution is so simple - if you know the backgrounds. –  Garonenur Apr 24 at 11:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.