我正在尝试用箭头绘制图表。我已经能够使用此代码生成图表但没有箭头:
\begin{tikzpicture}
\node (a) at (0,0) {$a$};
\node (z1) at (3,2) {$z_1$};
\node (z2) at (3,0) {$z_2$};
\node (z3) at (3,-2) {$z_3$};
\draw (a) -- (z1);
\draw (a) -- (z2);
\draw (a) -- (z3);
\end{tikzpicture}
但是我需要这些段是箭头并向这些段添加标签但是当我尝试这段代码时:
\begin{tikzpicture}
\node (a) at (0,0) {$a$};
\node (z1) at (3,2) {$z_1$};
\node (z2) at (3,0) {$z_2$};
\node (z3) at (3,-2) {$z_3$};
\draw [->] (a) -- (z1) {$1/2$};
\draw [->] (a) -- (z2) {$1/4$};
\draw [->] (a) -- (z3) {$1/4$};
\end{tikzpicture}
我在第一\draw
行收到一个错误,上面写着:
Argument of \language?@active@arg> has an extra }.
Runaway argument?
Missing \endcsname inserted.
然后在\end{tikzpicture}
我得到的行中:
Extra }, or forgotten \endgroup.
Missing } inserted.
我正在使用的完整代码是这样的:
\documentclass[spanish]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr} % Required for custom headers
\usepackage{lastpage} % Required to determine the last page for the footer
\usepackage{extramarks} % Required for headers and footers
\usepackage[usenames,dvipsnames]{color} % Required for custom colors
\usepackage{graphicx} % Required to insert images
\usepackage{listings} % Required for insertion of code
\usepackage{courier} % Required for the courier font
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (a) at (0,0) {$a$};
\node (z1) at (3,2) {$z_1$};
\node (z2) at (3,0) {$z_2$};
\node (z3) at (3,-2) {$z_3$};
\draw [->] (a) -- (z1) node[midway,above] {$1/2$};
\draw [->] (a) -- (z2) node[midway,above] {$1/4$};
\draw [->] (a) -- (z3) node[midway,above] {$1/4$};
\end{tikzpicture}
\end{document}