我正在尝试使用 TikZ 绘制一个简单的坐标系。我还有一个角度,我想将其标记为 phi (\varphi)。以下不带标签的代码有效:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetikzlibrary{positioning,calc,patterns,angles,quotes}
\definecolor{grid-light-grey}{gray}{.95}
\begin{document}
\frame{
\begin{tikzpicture}[axis/.style={very thick, ->, >=stealth'}]
\tkzInit[xmax=5, ymax=3, xmin=-2, ymin=-2]
\tkzGrid[sub, color=grid-light-grey, subxstep=1, subystep=1]
%% CUSTOM AXIS
\draw[axis] (-2.5, 0) -- (5.5, 0) node(re)[below left] {$Re$};
\draw[axis] (0, -2.5) -- (0, 3.5) node(im)[below left] {$Im$};
\coordinate (origin) at (0,0);
\draw[draw=green, thick] (origin) -- (3, 2) node [anchor=south west] {$ z = a + bi$}
node[] (num) {\fontfamily{qag}\selectfont x};
\draw[dashed] (3, 2) -- (0, 2) node[anchor=east] {$b$};
\draw[dashed] (3, 2) -- (3, 0) node[anchor=south west] {$a$};
\node[color=green] at (1, 1) {$r$};
\pic[draw] {angle = re--origin--num};
\end{tikzpicture}
}
\end{document}
不幸的是,当我尝试通过将选项传递给 \pic 命令来标记角度时:
\pic[draw, "$\varphi$"] {angle = re--origin--num};
突然它导致错误。这尤其奇怪,因为相同的设置在类似问题的答案中似乎有效:
https://tex.stackexchange.com/a/219039/172626
有谁知道问题是什么,为什么该语法在该问题的答案中有效,但在我的情况下却无效?
答案1
我又遇到了这个问题,我尝试了@marmot的建议,包括 tikzlibrary babel
。问题确实解决了。