3

Can anyone help me understand why this behavior?

\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}

This doesn't result in three types of nodes (circles), instead all I see is two different types either no fill or filled with black color circle nodes. I tried all combinations like

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)Trying to draw the circle manually without using the predefined style and giving the option of \draw[pattern,pattern color] and still the same problem.

Edit: If i use the above piece of code stand alone, now I seem to get the expected three styles of nodes/circles. But as part of a another bigger document I seem to be running into the problem i.e., something else overriding it and I see filled black circles even when i define it using \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}

Edit 2:

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

After elimination process I've figured out the problem. The above two lines in the Preamble are causing the problem. I am sorry for the naivety in using the libraries without knowing the exact purpose. But why should these two lines cause this problem?

  • 1
    Can you please complete your code snippet to a compilable minimal working example MWE? BTW: Welcome to TeX.SE! – Mensch Jan 25 '15 at 18:34
  • 1
    After suitable completion of your code I get the three expected styles compiling with pdflatex. – Gonzalo Medina Jan 25 '15 at 18:42
  • I did the changes asked and I hope i am clearer now. Sorry for the inconvenience – mathamateur Jan 25 '15 at 19:10
  • Perhaps you redefined elsewhere the shaded style? It's hard (almost impossible) to detect the problem without some example code reproducing it. – Gonzalo Medina Jan 25 '15 at 21:03
3

The order of package loading is important here: load xcolor and pstricks (if you really need both TikZ and PStricks) before loading tikz, as in

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

A better approach here would be to pass usenames and dvipsnames as class options, so they will be picked by every responsive package, in particular, pstricks and xcolor; furthermore, since xcolor is internally loaded by tikz, you don't need to load it explicitly. You can then simply say:

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

By the way, never pass driver options to graphicx; instead of

\usepackage[pdftex]{graphicx}

use simply

\usepackage{graphicx}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.