TikZ: 角度ライブラリの使用

TikZ: 角度ライブラリの使用

ライブラリを使用しようとしていますanglesが、他の方法でノードが指定された場合にどのように適用すればよいかわかりません。

例では、ベクトルの描画とノードの命名が、コマンドdrawを発行するのと同じコマンドで実行されますangles

\documentclass[tikz]{standalone}%

\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{angles}

\begin{document}
\begin{tikzpicture}
  \coordinate (O) at (0, 0);

  \path[name path = para] (-1, -2.5) parabola bend (2, 2) (4, 0);

  \draw (O) -- (5, 0) coordinate (P1);

  \path[name path = circ] (O) circle[radius = .75bp];
  \path[name intersections = {of = para and circ}];

  \coordinate (A) at (intersection-1);
  \coordinate (B) at (intersection-2);

  \draw[-latex, red] (A) -- ($(B)!1cm!(A)$) coordinate (P2);

  \path (P1) -- (O) -- (P2)
  pic[''$\theta$'', draw, -latex, red, angle radius = .5cm,
  angle eccentricity = 1.2] {angle = P1--O--P2};
\end{tikzpicture}
\end{document}

シータは色ではないと言っているのです。


quotesHarish Kumar が回答したように、ライブラリをロードして二重引用符で囲んだ場合でも、\theta次のメッセージが表示されます。

! Missing \endcsname inserted.
<to be read again>
                   \theta
l.41   angle eccentricity = 1.2, font = \tiny]
                                               {angle = P1--O--P2};
! Missing \endcsname inserted.

 ...

l.41 ...y = 1.2, font = \tiny] {angle = P1--O--P2}
                                                  ;

! Package xcolor Error: Undefined color ```$\theta $'''.

二重引用符が同じ問題を引き起こしているということを信じない人のために、これが事実であることを示すビデオをナレーションしました。

https://www.dropbox.com/s/44zhedz2psg1vrk/2014-05-08%2018.08.46.mp4

答え1

quotes構文を使用するにはライブラリをロードする必要がありますquotes。これにより、ラベル、ピン、エッジ ノード、および画像テキストの引用符構文が有効になります。

また、これは"$\theta$"(not ''$\theta$'') のような二重引用符です。一部のエディタ (Emacs など) は、文書をコンパイルした後に正しい出力を生成するため、自動的"``またはに変換します''(単語の先頭または末尾に挿入されているかどうかによって異なります)。ただし、この場合は、実際の二重引用符。Emacsでこれらを入力するには、二重引用符キーを押すだけです。2回連続して。2 番目のコマンドは、前に挿入した 2 つの一重引用符を、ここで必要な 1 つの二重引用符に変換します。

\documentclass[tikz,varwidth]{standalone}%

\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{angles}
\usetikzlibrary{quotes}

\begin{document}
\begin{tikzpicture}
  \coordinate (O) at (0, 0);

  \path[name path = para] (-1, -2.5) parabola bend (2, 2) (4, 0);

  \draw (O) -- (5, 0) coordinate (P1);

  \path[name path = circ] (O) circle[radius = .75bp];
  \path[name intersections = {of = para and circ}];

  \coordinate (A) at (intersection-1);
  \coordinate (B) at (intersection-2);

  \draw[-latex, red] (A) -- ($(B)!1cm!(A)$) coordinate (P2);

  \path (P1) -- (O) -- (P2) pic["$\theta$", draw,-latex, red, angle radius = 0.5cm, angle eccentricity = 1.2] {angle = P1--O--P2};
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

答え2

引用ライブラリを組み込んでもまだうまくいかない場合は、提案されているようにbabelライブラリをロードすることをお勧めします。ここ私もまったく同じ問題を抱えていましたが、これで解決しました。

\usetikzlibrary{angles,quotes}
\usetikzlibrary{babel}

答え3

quote英語以外の言語を含む文書でライブラリを使用すると、Babelsの再定義に問題が生じます''。たとえば、(わずかに修正された)ユーザー11232答え):

\documentclass[tikz, margin=3mm]{standalone}%
\usetikzlibrary{angles,
%                babel, % <-- example works if you enable this library
                calc,
                intersections,
                quotes}
\usepackage[slovene]{babel}
\begin{document}
    \begin{tikzpicture}[
              > = stealth,
   angle radius = 5mm,
my angle/.style = {draw, -latex,
                   angle eccentricity=1.3,
                   font=\large} % angle label position!
                        ]
\draw   (0,0) coordinate (O) -- 
        (4,0) coordinate (P1);
\draw[very thin, dashed, name path = para] (-1,-2.5) parabola bend (2,2) (4,0);
\draw[very thin, name path = circ] (O) circle[radius = .75bp];
%
\path[name intersections = {of = para and circ, by={A,B}}];
%
\draw[-latex, red] (A) -- ($(B)!1cm!(A)$) coordinate (P2);
%
\path (P1) -- (O) -- (P2) 
    pic[my angle,"$\theta$"] {angle = P1--O--P2};
\end{tikzpicture}
\end{document}

エラーが発生します:

! Argument of \language@active@arg" has an extra }.
<inserted text> 
                \par 
l.26     pic[my angle,"$\theta$"]
                                  {angle = P1--O--P2};
? x

この場合、babel上記の MWE のプリアンブルでライブラリを有効にすると、ライブラリが消えて次の結果が得られます。

ここに画像の説明を入力してください

この問題は、ここで多くの質問/回答で議論されていることに注意してください。また、OP MWE は計算が非常に要求されるため、結果が出るまでに時間がかかります。この問題には、より優れたアプローチが存在します (ただし、これはここでの質問ではありません)。

関連情報