Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using TikZ to draw some trees in my thesis. This is a sample of what is being done:

\documentclass{article}
\usepackage{tikz-qtree}

\newcommand{\Ta}{
\begin{tikzpicture}[level distance=30pt, sibling distance=90pt]
  \node {}
        child {node {$p(x)$}
        child{node {$skipped$} edge from parent[draw=none]}
    }
        child {node {$s(x)$}
        child {node {$\sim s(x)$}
            child{node {$closed$} edge from parent[draw=none]}
        }   
    };
\end{tikzpicture}
}

\newcommand{\Tb}{
\begin{tikzpicture}[level distance=30pt, sibling distance=90pt]
\tikzstyle{level 2}=[level distance=30pt, sibling distance=80pt]
  \node {}
        child {node {$p(x)$}
        child{node {$q(x)$}
            child{node {$skipped$} edge from parent[draw=none]}
        }
        child{node {$\sim p(x)$}
            child{node {$closed$} edge from parent[draw=none]}
        }
    }
        child {node {$s(x)$}
        child {node {$\sim s(x)$}
            child{node {$closed$} edge from parent[draw=none]}} 
    };
\end{tikzpicture}
}


\newcommand{\Tc}{
\begin{tikzpicture}[level distance=30pt, sibling distance=90pt]
\tikzstyle{level 1}=[sibling distance=90pt]
\tikzstyle{level 2}=[sibling distance=80pt]
\tikzstyle{level 3}=[sibling distance=40pt]
  \node {}
        child {node (n1) {$p(x)$}
        child{node {$q(x)$}
            child{node (n2) {$\sim p(x)$}
                child{node {$closed$} edge from parent[draw=none]}
            }
            child{node {$\sim q(x)$}
                child{node {$closed$} edge from parent[draw=none]}
            }
            child{node {$ r(x)$}
                child{node {$skipped$} edge from parent[draw=none]}
            }
        }
        child{node {$\sim p(x)$}
            child{node {$closed$} edge from parent[draw=none]}
        }
    }
        child {node {$s(x)$}
        child {node {$\sim s(x)$}
            child{node {$closed$} edge from parent[draw=none]}} 
    };

\path[dashed, <->](n1)edge [bend right=45]  node[above left]{reduction}(n2);

\end{tikzpicture}
}

\begin{document}
\pgfversion

\begin{figure}
\centering
\begin{minipage}{0.45\textwidth}
\centering\Ta
\caption{$Ta$}
\end{minipage}
\begin{minipage}{0.45\textwidth}
\centering\Tb
\caption{$Tb$}
\end{minipage}
\vspace{15pt}
\vspace{15pt}
\begin{minipage}{0.45\textwidth}
\centering\Tc
\caption{$Tc$}
\end{minipage}
\end{figure}


\end{document}

There is one little problem I cannot solve. The command:

\path[dashed,<->](n1)edge [bend right=45]  node[above left]{reduction}(n2);

produces a line that is touching the bottom node, and this is a little annoying.

enter image description here

I tried different approaches but nothing seemed to work. Can anyone help me figure this out?

share|improve this question
    
It works fine for me. You might be using an old (i.e. older than 2.1) version of TikZ/PGF. You can check this by inserting \pgfversion after \begin{document} in your file. Also note that it is helpful if you make your code examples full, compilable documents starting from \documentclass so people who want to try out the code don't have to write the preamble themselves and guess at packages you might be loading. –  Jake May 30 '11 at 21:35
    
Please always add a full minimal working example (MWE) that illustrates your problem. This means with the preamble and document environment. Do you have some global tikz style settings? I also don't get the result. The solid lines e.g. from q(x) to ~p(x) is much shorter when I compile the above code. –  Martin Scharrer May 30 '11 at 21:38
    
@jake: \pgfversion returned 2.10... i will edit my post –  astazed May 30 '11 at 21:40
2  
@Nagi The problem is caused by the tikz-qtree package. If you aren't using its methods for inputting trees, you shouldn't load it. (Another reason to make a minimal working example.) –  Alan Munn May 30 '11 at 21:43
2  
@Alan: Wow, you sure know your tree packages, to be able to recognise this error without a full MWE. –  Jake May 30 '11 at 21:45
show 2 more comments

2 Answers 2

up vote 5 down vote accepted

The problem is caused by the tikz-qtree package. If you aren't using its methods for inputting trees, you shouldn't load it. (Another reason to make a minimal working example.)

However, because of the way tikz-qtree draws its trees, you might prefer the tree to look that way, in which case Martin's solution will solve the problem. Here's a comparison of the same tree with tikz-qtree loaded and not loaded: (The one with tikz-qtree uses the shorten solution on the path.)

Without tikz-qtree

tree without tikz-qtree loaded

With tikz-qtree

tree with tikz-qtree loaded

share|improve this answer
    
i flagged this as the right answer because it is, but i am going to use Martin Scharrer's answer because like you said, it is much nicer with tikz-qtree... –  astazed May 31 '11 at 7:10
add comment

You could use shorten >=<length> to shorten the arrow a little bit:

\path[dashed,<->,shorten >=5pt](n1)edge [bend right=45]  node[above left]{reduction}(n2);

There is also shorten < for the other end.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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