# arrows with tikz package

I use tikz, and try draw a directed graph with

\begin{tikzpicture}
\node[draw, circle] (1) {1};
\node[draw, circle] (2) [ right of=1] {2};

\path (1) edge (2);
\end{tikzpicture}


and get

how I can get this ? (with arrow)

### Edit

I try with

\path[->] (1) edge (2);


but I get

! Argument of \language@active@arg> has an extra }.
<inserted text>
\par
l.403     \path[->] (
1) edge (2);

-
Just add [->] after \path. See the manual for various arrow style options. –  percusse Mar 21 '12 at 0:32
As @percusse said. Possible Duplicate: Graph into graph with arrows –  Peter Grill Mar 21 '12 at 0:35
Your code \path[->] (1) edge (2); works fine for me... –  cmhughes Mar 21 '12 at 0:47

spanish babel's option declares < and > active characters to write something like <<Hello>> and obtain french quotes. This behavior clashes with TiKZ arrow form [->]. The way to deactivate <> is \usepackage[spanish,es-noquoting]{babel}, so

\documentclass{article}
\usepackage{tikz}
\usepackage[spanish,es-noquoting]{babel}
\begin{document}
\begin{tikzpicture}
\node[draw, circle] (1) {1};
\node[draw, circle] (2) [ right of=1] {2};

\path[->] (1) edge (2);
\end{tikzpicture}
\end{document}


works as expected. I've found this solution in CervanTeX (spanish TUG) forums:

Update for TiKZ 3.0

TiKZ 3.0 includes a new babel library (pgfmanual section 42) which avoid this kind of problems. Using it, is not necessary to use es-noquoting option any more. You can even have spanish quotes inside nodes.

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{tikz}
\usetikzlibrary{babel,positioning}

\begin{document}

\begin{tikzpicture}
\node[draw, circle] (1) {<<1>>};
\node[draw, circle] (2) [ right = of 1] {<<2>>};

\path[->] (1) edge (2);
\end{tikzpicture}

<<Hola>>
\end{document}


-
Do you know if babel-greek declares something which might cause problems even with 3.0? I'm having trouble reproducing in a MWE but in my real code, merely adding greek to the babel options causes compilation to fail and I've no idea why. –  cfr Aug 18 '14 at 15:07
@cfr I've never used babel-greek. What problem do you have? Is it in a TiKZ graphic? Or in normal text but loading TiKZ3.0? What's shown in .log file? I'm sure you understand that with this kind of description is difficult to help you. –  Ignasi Aug 18 '14 at 16:36
Sure. It was just a query in case you happened to know of any similar issue with babel-greek. (Yes, it is a TikZ graphic and it is something about that plus loading babel-greek, even if no Greek is included in the graphic or anywhere in the document.) But asking was rather a long shot. Thanks for taking the time to reply. –  cfr Aug 18 '14 at 17:05

Maybe this old Mail from Till Tantau I found when googling your added error message is helpful somehow: tex.pgf.user list.

There seems to be an issue with the use of < and > as ative characters in some languages in TeX. The solution is supposedly (quoting Till)

[...] using \shorthandsoff (or something similar) inside a tikzpicture.

-
maybe this is my problem, I use spanish package –  JuanPablo Mar 21 '12 at 1:00
@JuanPablo This is to show you how important a minimal working example is. –  Marc van Dongen Mar 21 '13 at 6:05

A follow-up on the possible interference from {babel} language options.

I have experienced this issue with several punctuation marks that, in French, require a space after them, and are coded in the french option to babel to do so:

  : ; ? !


However, the colon (:) is also used in arydshln.sty. To circumvent this, I do indeed use the solution ascribed to Till Tantau:

\shorthandoff{:}

I also extend that to the semi-colon, question mark, and exclamation mark in French-lang. journals which do NOT want that trailing space:

\shorthandoff{;} \shorthandoff{?} \shorthandoff{!}

Currently, I'm learning to incorporate tikz code into the CJL macros (Cdn. Jrnl. of Ling.) and have found I can get around the shared use of > by adding this

\shorthandoff{>}


not WITHIN the tikzpicture environment but just before -- but still within the outer figure environment.

-
Please also see this one to make it easier for your picture declarations tex.stackexchange.com/questions/86023/… –  percusse Mar 20 '13 at 21:52

I solved with

\begin{tikzpicture}[thick]
\node[draw, circle] (1) {1};
\node[draw, circle] (2) [ right of=1] {2};

\begin{scope}[-stealth]
\path (1) edge (2);
\end{scope}
\end{tikzpicture}

-
Using \path [-stealth] (1) edge (2); works just fine without requiring the extra scope. I would recommend you upgrade your packages. –  Peter Grill Mar 21 '12 at 1:00

Good evening, I am using this approach which doesn't affect active characters outside the TikZ environment, if needed. I would add this command in the document body for Spanish.

\tikzset{every picture/.append style={execute at begin picture={\catcode\>=12\catcode\<=12}}}


I usually don't use \shorthandoff command because it is unclear if babel package is loaded or not. If I need active characters, e.g. inside the TikZ nodes, I would use:

\node{\catcode\<=13\catcode\>=13 <<Hello>>};


Here is an example:

\documentclass{article}
\usepackage{tikz}
\usepackage[spanish]{babel}
\pagestyle{empty}
\begin{document}
\tikzset{every picture/.append style={execute at begin picture={\catcode\>=12\catcode\<=12}}}
\begin{tikzpicture}
\node[draw,circle] (1) {1};
\node[draw,circle] (2) [right of=1] {2};
\node[draw,circle,xshift=1cm,inner sep=0pt](3)[right of=2]{\catcode\<=13\catcode\>=13 <<Hello>>};
\path[<->] (1) edge (2);
\path[>-<] (2) edge (3);
\end{tikzpicture}\par
<<Hello, World!>>
\end{document}


-