Graphics, Figures & TablestikZ, babel | Spanish Language Option

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
eglucon
Posts: 11
Joined: Fri Jan 16, 2009 7:13 am

tikZ, babel | Spanish Language Option

Post by eglucon »

I work with the MiKTeX 2.9 Distribution and the TeXnicCenter and I am currently trying to include a tikzpicture in an article written in Spanish, so I load the "babel" package with the "spanish" option, plus the "tikz" package in the preamble

However, when I write a particular tikzpicture, like the following:

Code: Select all

\begin{tikzpicture}
[ciclo/.style={circle,draw,fill=red!70,thick,inner sep=1pt},nociclo/.style={circle,draw,thick,inner sep=1pt}]
\node (uno) 		at 	(1,1) 	        [ciclo] {$a_5$};
\node (dos) 		at 	(1,3) 	        [ciclo] {$h_1$};
\node (tres) 		at 	(1,5) 	        [ciclo] {$a_1$};
\node (cuatro)	        at 	(3,1)		[ciclo] {$h_5$};
\node (cinco) 	        at 	(3,3) 	        [ciclo] {$a_2$};
\node (seis)		at  	(3,5) 	        [ciclo] {$h_2$};
\node (siete)		at  	(5,1) 	      [nociclo] {$h_3$};
\node (ocho)		at  	(5,3) 	      [nociclo] {$a_4$};
\node (nueve)		at  	(7,1) 	      [nociclo] {$a_3$};
\node (diez)		at  	(7,3) 	      [nociclo] {$h_4$};

\draw[->] (uno) 	-- (dos);
\draw[->] (dos) 	-- (tres);
\draw[->] (tres) 	-- (seis);
\draw[->] (seis) 	-- (cinco);
\draw[->] (cinco) 	-- (cuatro);
\draw[->] (cuatro) 	-- (uno);
\draw[->] (ocho) 	-- (seis);
\draw[->] (diez) 	-- (ocho);
\draw[->] (diez) 	-- (nueve);
\draw[->] (siete) 	-- (nueve);
\end{tikzpicture}
LaTeX does not compile the file, and it displays the following LaTeX Error message:

Code: Select all

!LaTeX Error: \begin{tikzpicture} on input line 150 ended by \end{document}
which is not the case, because \begin{tikzpicture} is ended by \end{tikzpicture}.

It turns out that when I ommit the \draw commands within the tikzpicture environment, the file is compiled without errors, and is the same case when I do not load the "babel" package with the "spanish" option and I include the \draw commands within tikzpicture.

I want to know whether the TikZ package supports the babel spanish option, and why when I do not write the \draw commands the file is correctly compiled?

Thanks,
Regards.

Eglucon

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

tikZ, babel | Spanish Language Option

Post by Stefan Kottwitz »

Hi Eglucon,

> is a shorthand in babel, that's why \draw[->] fails. You could disable it globally, or locally in the tikz picture if you need it elsewhere:

Code: Select all

\begin{tikzpicture}
  [ciclo/.style={circle,draw,fill=red!70,thick,inner sep=1pt},
   nociclo/.style={circle,draw,thick,inner sep=1pt}]
    \shorthandoff{>}
    \node (uno)       at    (1,1)            [ciclo] {$a_5$};
    \node (dos)       at    (1,3)            [ciclo] {$h_1$};
    ...
    \draw[->] (uno)    -- (dos);
    ...
\end{tikzpicture}
Stefan
LaTeX.org admin
eglucon
Posts: 11
Joined: Fri Jan 16, 2009 7:13 am

Re: tikZ, babel | Spanish Language Option

Post by eglucon »

Thank you Stefan_K, it worked perfectly.

Regards,
Eglucon.
Post Reply