\node 未被 Tex 识别

\node 未被 Tex 识别

我决定学习如何在乳胶中制作一些图形,目前正在观看这个视频: https://www.youtube.com/watch?v=LoBC8zIB-3k&feature=youtu.be

但是,每次我尝试运行代码时,它都会告诉我 \node 无法识别。这是我迄今为止进行测试的结果。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,positioning}

\tikzstyle{startstop} = {rectangle, rounded corners, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=red!30}
\tikzstyle{io} = {trapezium, trapezium left angle=70, trapezium right angle=110, minimum width = 3cm, minimum height=1cm, text centered, draw=black, fill=blue!30}
\tikzstyle{process} = {rectangle,minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30}
\tikzstyle{decision} = {diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30}
\tikzstyle{arrow} = {thick-->,>=stealth}
\begin{document}
                \begin{tikzpicture}[node distance=2cm]
                \node[startstop] (start) {Start};
                \end{tikzpicture}
\end{document}

答案1

欢迎!您使用了错误的语法,符号\tikzstyle后应使用方括号=。这触发了错误。但是,\tikzstyle无论如何您都不应该使用,而应该改用\tikzset。这是您的代码的最低限度修改版本,可以正常工作。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,positioning}

\tikzset{startstop/.style={rectangle, rounded corners, minimum width=3cm,
minimum height=1cm, text centered, draw=black, fill=red!30},
io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width = 3cm, minimum height=1cm, text centered, draw=black, fill=blue!30}
process/.style={rectangle,minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30}
decision/.style={diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30}
arrow/.style={thick-->,>=stealth}}
\begin{document}
   \begin{tikzpicture}[node distance=2cm]
   \node[startstop] (start) {Start};
   \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您的样式选项必须用括号包裹,而不是花括号。

这是的语法\tikzstyle

\tikzstyle{name} = [some options ...]

相关内容