
\sqrt{3}/2
長方形の頂点を見つけて長方形領域に色を付けようとしています。または のような関数値として y 座標を指定します\sin(60)
。 エラーが発生します。
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (-1,{-\sqrt{3}/2});
\coordinate (B) at (-1,{\sin(60)});
\coordinate (C) at (2,{\sin(60));
\coordinate (D) at (2,{-\sqrt{3}/2});
\path[fill=yellow] (A) -- (B) -- (C) -- (D) -- cycle;
\node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]below left:$A$}] at (A) {};
\node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]above left:$B$}] at (B) {};
\node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]above right:$C$}] at (C) {};
\node[outer sep=0pt,circle, fill,inner sep=1.5pt,label={[fill=white]below right:$D$}] at (D) {};
\end{tikzpicture}
答え1
TikZ
/pgf
は で使用されますが、その構文はの数学エンジンLaTeX
の構文と同様に特殊です。pgf
この特定のケースでは、sqrt
や のような関数はsin
コマンド名を (バックスラッシュ) で始めません\
。また、括弧を必要とする複合引数は で囲む必要があります{...}
。定義の正しいコードはcoordinates
次のようになります。
\coordinate (A) at (-1,{-sqrt(3)/2});
\coordinate (B) at (-1,{sin(60)});
\coordinate (C) at (2,{sin(60)});
\coordinate (D) at (2,{-sqrt(3)/2});