Tell me more ×
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 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

ss

how I can get this ? (with arrow)

ss1

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);
share|improve this question
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

4 Answers

up vote 11 down vote accepted

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:

share|improve this answer

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.

share|improve this answer
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 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.

share|improve this answer
Please also see this one to make it easier for your picture declarations tex.stackexchange.com/questions/86023/… – percusse Mar 20 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} 
share|improve this answer
3  
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

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.