TikZ-用图案填充圆圈-意外行为

TikZ-用图案填充圆圈-意外行为

有人能帮助我理解为什么会出现这种行为吗?

\documentclass[journal]{IEEEtran}
\usepackage[pdftex]{graphicx}
\usepackage{tikz,pgfplots}
\usetikzlibrary{arrows,shapes,chains,matrix,positioning,scopes,patterns}
\begin{document}
\begin{tikzpicture}[>=latex,
shaded/.style={circle,radius=\r,draw,pattern=north west lines,pattern color=blue},
point/.style={circle,radius=\r,draw,thick,fill=black},
empty/.style={circle,radius=\r,draw,fill=none}]
\def\r{0.2}
\node[point] (23) at (0,0){$p_{2,3}$};
\node[shaded] (24) [right=of 23]{};
\node[shaded] (22) [left=of 23]{};
\node[empty] (21) [left=of 22] {};

\node[shaded] (33) [above=of 23]{};
\node[shaded] (34) [right=of 33]{};
\node[shaded] (32) [left=of 33]{};
\node[shaded] (31) [left=of 32] {};

\node[shaded] (13) [below=of 23]{};
\node[shaded] (14) [right=of 13]{};
\node[shaded] (12) [left=of 13]{};
\node[shaded] (11) [left=of 12] {}; 

\end{tikzpicture}
\end{document}

这不会产生三种类型的节点(圆圈),相反,我看到的只是两种不同类型的节点,要么没有填充,要么用黑色圆圈节点填充。我尝试了所有组合,例如

1)shaded/.style={circle,radius=\r,draw,pattern=north west lines,pattern color=blue}," replaced by "shaded/.style={circle,radius=\r,draw,fill=none,pattern=north west lines,pattern color=blue},

2)尝试手动绘制圆圈而不使用预定义样式并提供选项,\draw[pattern,pattern color]但问题仍然存在。

编辑:如果我单独使用上面的代码,现在我似乎得到了预期的三种节点/圆圈样式。但作为另一个更大的文档的一部分,我似乎遇到了问题,即其他东西覆盖了它,即使我使用 定义它,我也会看到填充的黑色圆圈\node[shaded]

\documentclass[journal]{IEEEtran}
\usepackage[pdftex]{graphicx}
\usepackage{tikz,pgfplots}
\usetikzlibrary{arrows,shapes,chains,matrix,positioning,scopes,patterns}
\begin{document}
%Lot of remaining part of the journal is here%
\begin{figure}[h!]
 \centering
\begin{tikzpicture}[>=latex,
shaded/.style={circle,radius=\r,draw,pattern=north west lines,pattern color=blue},
point/.style={circle,radius=\r,draw,thick,fill=black},
empty/.style={circle,radius=\r,draw,fill=none}]
\def\r{0.2}
\node[point] (23) at (0,0){$p_{2,3}$};
\node[shaded] (24) [right=of 23]{};
\node[shaded] (22) [left=of 23]{};
\node[empty] (21) [left=of 22] {};

\node[shaded] (33) [above=of 23]{};
\node[shaded] (34) [right=of 33]{};
\node[shaded] (32) [left=of 33]{};
\node[shaded] (31) [left=of 32] {};

\node[shaded] (13) [below=of 23]{};
\node[shaded] (14) [right=of 13]{};
\node[shaded] (12) [left=of 13]{};
\node[shaded] (11) [left=of 12] {}; 

\end{tikzpicture}   
\label{Fig:MP_Scheduling}
\end{figure}
\end{document}

编辑2:

\usepackage[usenames,dvipsnames]{pstricks}
\usepackage[usenames,dvipsnames]{xcolor}   

经过排除法,我找到了问题所在。序言中的上述两行代码导致了问题。我很抱歉在不知道确切用途的情况下使用这些库。但为什么这两行代码会导致这个问题呢?

答案1

命令包加载在这里很重要:在加载之前加载xcolorpstricks(如果你真的需要 TikZ 和 PStricks)tikz,如下所示

\usepackage[usenames,dvipsnames]{xcolor} 
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{tikz,pgfplots}

这里更好的方法是将usenamesdvipsnames作为类选项传递,这样它们将被每个响应式包选择,特别是pstricksxcolor;此外,由于xcolor是由内部加载的tikz,因此您无需明确加载它。然后您可以简单地说:

\documentclass[journal,usenames,dvipsnames]{IEEEtran}
\usepackage{graphicx}
\usepackage{pstricks}
\usepackage{tikz,pgfplots}

顺便一提,绝不将驱动程序选项传递给graphicx; 而不是

\usepackage[pdftex]{graphicx}

简单使用

\usepackage{graphicx}

相关内容