5

When producing a PDF from the following example using pdflatex, I get different results between Adobe Reader and TeXworks. I think this is a bug in the way that Reader handles opacity/transparency.

My goal is to have just a small space between the black node and each edge (like how TeXworks is rendering it), and the way I'm doing that is by setting a black fill and color=transparent/opacity=0 edge for each node.

Can anyone suggest a nice workaround to get consistent results? I have many trees I am trying to render that suffer from this issue and I would like to have the space between the edge and node be transparent rather than white.

Maybe I can draw fully transparent nodes, and then draw a smaller black node on top of each of these. Can this be automated as part of the state syle? Or can I set a gap between the start and end of every edge? (How would I do this?)

\documentclass{article}
\usepackage{tikz}

\tikzstyle{lts}=[
  state/.style={circle,draw,minimum size=4pt,inner sep=0pt,line width=2pt,draw opacity=0,color=transparent,fill=black},
  edge from parent/.style={-stealth,draw},
  obs/.style={edge from parent/.style={-stealth,draw,very thick}},
]

\begin{document}
    \begin{tikzpicture}[lts]
      \node[state] {}
        child[obs] {node[state] {}
        edge from parent node {}}
        child[obs] {node[state] {}
        edge from parent node {}};
    \end{tikzpicture}
\end{document}

Comparing the rendering in TeXworks to Reader:

http://i.stack.imgur.com/xw3zu.png

3

Using draw=none instead of color=transparent seems to properly display it in Acrobat. The image on the left is the one with color=transparent, and the one on the right is with draw=noneas viewed in Acrobat:

enter image description here

Notes:

Code:

\documentclass{article}
\usepackage{tikz}

\tikzstyle{lts}=[
  state/.style={circle,draw,minimum size=4pt,inner sep=0pt,line width=2pt,draw opacity=0,color=transparent,fill=black},
  edge from parent/.style={-stealth,draw},
  obs/.style={edge from parent/.style={-stealth,draw,very thick}},
]

\tikzset{MyState/.style={circle,draw,minimum size=4pt,inner sep=0pt,line width=2pt,draw opacity=0,draw=none,fill=black}}
\tikzset{MyObs/.style={edge from parent/.style={-stealth,draw,very thick}}}

\begin{document}
    \begin{tikzpicture}[lts]
      \node[state] {}
        child[obs] {node[state] {}
        edge from parent node {}}
        child[obs] {node[state] {}
        edge from parent node {}};
    \end{tikzpicture}%
    \begin{tikzpicture}
      \node[MyState] {}
        child[MyObs] {node[MyState] {}
        edge from parent node {}}
        child[MyObs] {node[MyState] {}
        edge from parent node {}};
    \end{tikzpicture}
\end{document}
  • This is a much simpler solution than I thought I could get. In fact, I can just remove draw from state. Thanks! – cjb Apr 11 '13 at 19:14

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.