TikZ:由另一個指令的選項定義的箭頭顏色

TikZ:由另一個指令的選項定義的箭頭顏色

當我遇到以下行為時,我正在學習 PGF 手冊。

參考下面的程式碼,我指定了一個latex箭頭\filldraw元素和箭頭的顏色與該元素的邊框顏色相同。但是,如果我指定一個非標準箭頭或如果我在輸出正確顯示\filldraw後使用標準箭頭。\filldraw此外,元素latex中的類型箭頭\foreach正確顯示為紅色。

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3]
  \draw [help lines,step=0.5cm] (-1.4,-1.4) grid (1.4,1.4);
  \draw (0,0) circle (1cm);
  \draw [-latex] (0,-1.5) -- (0,1.5);
  \filldraw [fill=green!20,draw=green] (0,0) -- (0.3,0) arc [start angle=0,end angle=30,radius=0.3cm] -- cycle;
  \draw [-latex] (-1.5,0) -- (1.5,0);
  \draw [->,rotate=45,dashed] (-1.5,0) -- (1.5,0);% <-- standard arrowheads are not affected
  \foreach \x in {0,30,...,330}%<-- just to highlight the problem
    \node [draw,thick,red,circle,minimum size=.8cm,
           pin={[pin edge={latex-,red,thick,shorten <=1pt}]\x:$$}] at (1.5,0) {};%<-- these arrows are not affected
\end{tikzpicture}\\
My PGF version is \pgfversion.
\end{document}

在此輸入影像描述

這裡發生了什麼事?我犯了一個基本錯誤嗎?

答案1

我同意@percusse 的評論:這看起來像一個錯誤!

當我們使用draw=some color這種顏色時,後面會被一些箭頭使用。

並以一種奇怪的方式node重置了這種行為。

這是另一個最小的例子:

\documentclass[tikz,border=7mm]{standalone}
\begin{document}
\begin{tikzpicture}
  \path[draw=orange] (0,0) circle(1cm); % this draw color is used after by some arrows
  \draw[ultra thick,|->] (0:-1) -- (0:1); % the standard and | arrows are not affected
  \draw[ultra thick,stealth-latex] (90:-1) -- (90:1); % the latex and stealth arrows use the previous draw color
  \node {}; % node reset the draw color !
  \draw[ultra thick,stealth-latex] (45:-1) -- (45:1); % now it is ok
\end{tikzpicture}
\end{document}

在此輸入影像描述

相關內容