[Tex/LaTex] ! Package tikz Error: Giving up on this path. Did you forget a semicolon

tikz-trees

I seem to be missing something fairly fundamental about how tikz works… I really can't figure out where my missing semicolon is!

MWE:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[sibling distance=10em,
  every node/.style = {draw=none, fill=none}]]
  \node {What are the types of \code{a} and \code{b}?}
  child { \node {\code{int} and \code{int}}
    child { \node{Execute procedure \code{int\_add}. }; }; }
  child { \node {\code{float} and \code{float}}
    child { \node{Execute procedure \code{float\_add}.}; }; }
  child { \node {\code{float} and \code{int}}
    child { \node{Execute procedure \code{float\_plus\_int}.}; }; }
  child { \node {\code{int} and \code{float}}
    child { \node{Execute procedure \code{int\_plus\_float}.}; }; }
  child { \node {\code{string} and \code{string}}
    child { \node{Execute procedure \code{string\_concatenate}.}; }; }
  child { \node {Any other combination}
    child { \node{Raise \code{TypeError}.}; }; };
\end{tikzpicture}
\end{document}

Best Answer

  • There is a spurious ] after the options of tikzpicture (which doesn't do much harm, but shouldn't be there).

  • There are more opening than closing braces.

  • The \nodes within the tree should be just nodes (without backslash), which do not require terminating semicolons.

.

\documentclass{standalone}
\usepackage{tikz}
\newcommand\code[1]{\texttt{#1}}
\begin{document}
\begin{tikzpicture}[sibling distance=10em,
  every node/.style = {draw=none, fill=none}]]
  \node {What are the types of \code{a} and \code{b}?}
  child { node {\code{int} and \code{int}}
          child { node{Execute procedure \code{int\_add}. }
                }
          }
  child { node {\code{float} and \code{float}}
          child { node{Execute procedure \code{float\_add}.}
                }
        }
  child { node {\code{float} and \code{int}}
          child { node{Execute procedure \code{float\_plus\_int}.}
                }
        }
  child { node {\code{int} and \code{float}}
          child { node{Execute procedure \code{int\_plus\_float}.}
                }
        }
  child { node {\code{string} and \code{string}}
          child { node{Execute procedure \code{string\_concatenate}.}
                }
        }
  child { node {Any other combination}
          child { node{Raise \code{TypeError}.}
                }
        };
\end{tikzpicture}
\end{document}

enter image description here

Related Question