!软件包 tikz 错误:放弃此路径。您忘记了分号吗?

!软件包 tikz 错误:放弃此路径。您忘记了分号吗?

我似乎遗漏了一些有关 tikz 工作原理的基本知识...我真的不知道我丢失的分号在哪里!

梅威瑟:

\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}

答案1

  • ]选项后面有一个虚假的tikzpicture(虽然不会造成太大的危害,但不应该出现)。

  • 左括号比右括号多。

  • \node树中的 s 应该只是s node(没有反斜杠),不需要以分号结尾。

\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}

在此处输入图片描述

相关内容