# How to use tikz-graph and tkz-qtree without conflict?

It seems that the tikz-qtree and tkz-graph package both define (or redefine) the \edge macro... I'd like to use both, but it doesn't seem possible:

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{tkz-graph}

\begin{document}
\begin{tikzpicture}[level distance=40pt]
\Tree [.A [.B [.C a ] ]
[.D [.E quote ]
[.F \edge[roof]; {Eye of newt, and toe of frog} ] ] ]
\end{tikzpicture}

\begin{tikzpicture}
\GraphInit[vstyle=Classic]
\Vertex{z}
\end{tikzpicture}

\end{document}


I get the following error when compiling the document above:

! Use of \@edge doesn't match its definition.

l.12               [.F \edge
[roof]; {Eye of newt, and toe of frog} ] ] ]
?


Is there a workaround?

-

Sorry I'm guilty. I have not taken sufficient precautions. The problem comes from :

\newcommand*{\Edge}[1][]{\@edge[#1]}%  because tikz-qtree defines \@edge too :(


A better way was to use \tkz@edge instead of \@edge. In the next version with pgfkeys, I'll be more careful.

Actually you can save the next file with the name : patch-tkz-graph.tex

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% patch-tkz-graph.tex : patch for tkz-graph

\makeatletter
\renewcommand*{\Edge}[1][]{\tkz@edge[#1]}%
\def\tkz@edge[#1](#2)(#3){%
\setkeys[GR]{edge}{#1}%
\begingroup%
\ifthenelse{\equal{\cmdGR@edge@double}{}}{%
\tikzset{LocalEdgeStyle/.style={color = \cmdGR@edge@color,
line width = \cmdGR@edge@lw}}}{%
\tikzset{LocalEdgeStyle/.style={line width = \cmdGR@edge@dd,
color = \cmdGR@edge@double,
double distance = \cmdGR@edge@lw,
double  = \cmdGR@edge@color}}}%
\ifGR@edge@local%
\tikzset{EdgeStyle/.style={}}%
\fi
\ifthenelse{\equal{\cmdGR@edge@label}{}}{%
\protected@edef\@tempa{%
\noexpand   \draw[LocalEdgeStyle,\cmdGR@edge@style,EdgeStyle]}%
\@tempa (#2) to (#3)}{%
\protected@edef\@tempa{%
\noexpand   \draw[LocalEdgeStyle,\cmdGR@edge@style,EdgeStyle] (#2) to%
node[fill = \cmdGR@edge@labelcolor,
text = \cmdGR@edge@labeltext,
\cmdGR@edge@labelstyle,LabelStyle]}\@tempa
{\cmdGR@edge@label} (#3)}%
;
\endgroup%
}%
\makeatother
\endinput

%%%%%%%%%%%%%%%%%%%%%%%%


And then

\documentclass{article}
\usepackage{tkz-graph}% in first
\input{patch-tkz-graph}
\usepackage{tikz-qtree}

\begin{document}
\begin{tikzpicture}[level distance=40pt]
\Tree [.A [.B [.C a ] ]
[.D [.E quote ]
[.F \edge[roof]; {Eye of newt, and toe of frog} ] ] ]
\end{tikzpicture}

\begin{tikzpicture}
\GraphInit[vstyle=Hasse]
\Vertex[style={line width=2pt}]{A}
\Vertex[x=6,y=0,style={line width=2pt}]{B}
\Edge[style={->,>=latex,bend left=90},label=$x$](A)(B)
\end{tikzpicture}

\end{document}


-
@AndrewStacey Thanks for editing and for the corrections! I need to be more careful in my packages, but also in my answers –  Alain Matthes Jun 18 '12 at 13:18
@Altermundus: thank you for your answer and for the patch! It works perfectly. –  Jay Jun 18 '12 at 13:25
@Altermundus It was only a very minor edit. I strongly suspect you're not the only one that's used an obvious name for a macro only to find it used in some other package ... –  Andrew Stacey Jun 18 '12 at 13:29
@AndrewStacey Yes I know and it's not the first time. I was careful with my new packages. I need to rewrite tkz-graph with pgfkeys and some new tools from pgf 2.1 and with some others ideas. –  Alain Matthes Jun 18 '12 at 14:20