18

So I am trying to insert a functioning tikz image into a beamer project and it keeps giving me an error.

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{tikz}
\usetikzlibrary{shapes,trees,positioning}
\begin{document}
\begin{frame}{Examples}
\begin{center}
\begin{tikzpicture}[level/.style={sibling distance=60mm/#1},minimum size=20pt,scale=.8,
every node/.style={transform shape}] % If you want to scale the picture insert ``scale=
(something), every node/.style={transform shape}'' Ex:[level/.style={sibling 
distance=60mm/#1},minimum size=20pt,scale=.8, every node/.style={transform shape}] would 
scale to 80% of original size
\node [circle,draw] (z){\textbf{$u$}}
  child {node [circle,draw,fill=black,text=white] (a) {\textbf{$v$}}
    child {node [circle,draw,fill=black,text=white] (c) {}}
    child {node [circle,draw] (d) {}
    }
  }
  child {node [circle,draw,fill=black,text=white] (b) {\textbf{$w$}}
    child {node [circle,draw,fill=black,text=white] (e) {}}
     child {node [circle,draw] (f) {}}
  };
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

The error I keep getting is:

./SDN Presentation.tex:61: Illegal parameter number in definition of \iterate.
<to be read again> 
                   1
l.61 \end{frame}

If I delete the /#1 at the beginning of the picture I get an image though not the one I am looking for. Not sure how to fix this issue since the code works for the amsart document class.

2
  • 1
    Welcome to TeX SE! Nice first question! (Has code ;).)
    – cfr
    Mar 24, 2015 at 0:46
  • 3
    You may use ####1 instead of #1 to define the level style. Mar 24, 2015 at 0:56

1 Answer 1

23

You need to pass the fragile option to the frame environment to stop beamer trying to parse things it shouldn't.

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{tikz}
\usetikzlibrary{shapes,trees,positioning}
\begin{document}
\begin{frame}[fragile]{Examples}
\begin{center}
\begin{tikzpicture}[level/.style={sibling distance=60mm/#1},minimum size=20pt,scale=.8,
every node/.style={transform shape}] % If you want to scale the picture insert ``scale= (something), every node/.style={transform shape}'' Ex:[level/.style={sibling distance=60mm/#1},minimum size=20pt,scale=.8, every node/.style={transform shape}] would scale to 80% of original size
\node [circle,draw] (z){\textbf{$u$}}
  child {node [circle,draw,fill=black,text=white] (a) {\textbf{$v$}}
    child {node [circle,draw,fill=black,text=white] (c) {}}
    child {node [circle,draw] (d) {}
    }
  }
  child {node [circle,draw,fill=black,text=white] (b) {\textbf{$w$}}
    child {node [circle,draw,fill=black,text=white] (e) {}}
     child {node [circle,draw] (f) {}}
  };
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

fragile tree

1
  • Bro, I was losing my mind trying to solve a related problem with tikz and beamer and this [fragile] command solved all the problems. Thanks!
    – Powder
    Jan 30 at 2:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .