使用 Tikz for Overleaf 时如何修复此错误?
How can I fix this error when using Tikz for Overleaf?
我正在尝试制作带箭头的图表。我已经能够使用此代码制作图表但没有箭头:
\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) {/2$};
\draw [->] (a) -- (z2) {/4$};
\draw [->] (a) -- (z3) {/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] {/2$};
\draw [->] (a) -- (z2) node[midway,above] {/4$};
\draw [->] (a) -- (z3) node[midway,above] {/4$};
\end{tikzpicture}
\end{document}
在节点之间尝试 edge
命令
\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) edge (z1) (a) edge (z2) (a) edge (z3);
\end{tikzpicture}
有几个问题:
\draw
命令不像 \node
命令那样使用标签。如果要向箭头添加文本,有几种可能性,例如 \draw [->] (a) -- (z1) node[midway,above] {/2$};
那么你也在加载西班牙文的 babel 包。这引入了一些速记来编写干扰 tikz 的西班牙字符。关闭这些简写或加载 tikz babel
library
请不要多次加载包
查看 nicefrac
包以获得更好的分数
\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}
\usetikzlibrary{babel}
\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] {/2$};
\draw [->] (a) -- (z2) node[midway,above] {/4$};
\draw [->] (a) -- (z3) node[midway,above] {/4$};
\end{tikzpicture}
\end{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);
\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) {/2$};
\draw [->] (a) -- (z2) {/4$};
\draw [->] (a) -- (z3) {/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] {/2$};
\draw [->] (a) -- (z2) node[midway,above] {/4$};
\draw [->] (a) -- (z3) node[midway,above] {/4$};
\end{tikzpicture}
\end{document}
在节点之间尝试 edge
命令
\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) edge (z1) (a) edge (z2) (a) edge (z3);
\end{tikzpicture}
有几个问题:
\draw
命令不像\node
命令那样使用标签。如果要向箭头添加文本,有几种可能性,例如\draw [->] (a) -- (z1) node[midway,above] {/2$};
那么你也在加载西班牙文的 babel 包。这引入了一些速记来编写干扰 tikz 的西班牙字符。关闭这些简写或加载 tikz
babel
library请不要多次加载包
查看
nicefrac
包以获得更好的分数
\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}
\usetikzlibrary{babel}
\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] {/2$};
\draw [->] (a) -- (z2) node[midway,above] {/4$};
\draw [->] (a) -- (z3) node[midway,above] {/4$};
\end{tikzpicture}
\end{document}