我现在尝试了一段时间来为我的三角形添加一个角度,但不幸的是,我收到以下错误:“Package PGF Math Error: Unknown function ‘axis’ (in 'axis cs')”。我的 Latex 代码如下所示:
\documentclass[12pt]{article}
\usepackage[german]{babel}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\usepackage{blindtext}
\usepackage{listofsymbols}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{xcolor}
\usepackage{longtable}
\usepackage{stmaryrd}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tkz-euclide}
\usepackage{calc}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xtick={-1, 1},
ytick={-1, 1},
xlabel={$x$},
ylabel={$y$},
xlabel style={below right},
ylabel style={above left},
xmin=-1.5,
xmax=1.5,
ymin=-1.5,
ymax=1.5,
axis equal image]
\draw[color=teal] (axis cs:0,0) -- (axis cs:0.71,0) -- (axis cs:0.71,0.71) -- cycle;
\draw[fill=lightgray, thick] (axis cs: 0,0) -- (axis cs: 0,0) arc (axis cs: 0.71,0) node at (axis cs: 0.71,0.71) {$\alpha$} -- cycle;
\draw(axis cs: 0,0) circle [radius=100];
\end{axis}
\end{tikzpicture}
\end{center}~\\
尝试绘制浅灰色圆弧时出现错误。谢谢 JackboyPlay 的帮助。
答案1
- 添加
\pgfplotsset{compat=1.18}
,然后axis cs
是默认的。 arc
语法不同,请参见https://tex.stackexchange.com/a/175027
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
xtick={-1, 1},
ytick={-1, 1},
xlabel={$x$},
ylabel={$y$},
xlabel style={below right},
ylabel style={above left},
xmin=-1.5,
xmax=1.5,
ymin=-1.5,
ymax=1.5,
axis equal image]
\draw[color=teal] (0,0) -- (0.71,0) -- (0.71,0.71) -- cycle;
\draw[fill=lightgray, thick] (0,0) -- (0.71,0) arc (0:45:0.71) -- cycle;
\node at (22:.30) {$\alpha$};% polar coordinate: 22 degrees, distance 0.30
\draw(0,0) circle (1);
\end{axis}
\end{tikzpicture}
\end{document}