8

The following is one example to illustrate my point. The two edges differs in the '-latex' option. How come this option will affect the direction. As I understand it, this option just change how the arrow tips are rendered. The result is this: enter image description here

Is it a bug or a feature?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=6, transform shape]
\tikzstyle{every node} = [circle, fill=gray!30]
    \node (a) at (0, 0) {A};
    \node (b) at +(0: 1.5) {B}
        edge [<-, green,dashed, -latex, bend left=30] (a)
        edge [<-, green,dashed, bend right=30] (a)
        ;
\end{tikzpicture}
\end{center}
\end{document}

Edit: My intention is just to change the arrrow tip style, which is achieved in this. The accepted answer explains how it works.

This is the final code, which only changes the style of arrow tips, using >=latex:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=6, transform shape]
\tikzset{>=latex}
\tikzset{every node/.style={circle, fill=gray!30}}
    \node (a) at (0, 0) {A};
    \node (b) at +(0: 1.5) {B}
        edge [<-, red,dashed, bend left=30] (a)
        edge [<-, red,dashed, bend right=30] (a)
        ;
\end{tikzpicture}
\end{center}
\end{document}

1 Answers1

10

It's a feature; the string latex in -latex has the same syntactic behaviour as the > in ->:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=6, transform shape]
\tikzset{every node/.style={circle, fill=gray!30}}
    \node (a) at (0, 0) {A};
    \node (b) at +(0: 1.5) {B}
        edge [latex-, red,dashed, bend left=30] (a)
        edge [<-, red,dashed, bend right=30] (a)
        ;
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

Just to expand a little: the syntax -arrowtip puts arrowtip at the end of the path; arrowtip- puts arrowtip at the beginning of the path, and arrowtip1-arrowtip2 puts arrowtip1 at the beginning of the path and arrowtip2 at the end of the path.

If you want to change only the arrow tip without affecting its placement, you can use the >=arrowtip syntax. A little example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=6, transform shape,line width=3pt]
\tikzset{every node/.style={circle, fill=gray!30}}
    \node (a) at (0, 0) {A};
    \node (b) at +(0:1.5) {B}
        edge [->, blue,dashed, bend right=45] (a)
        edge [<-, red,dashed, bend right=30] (a)
        edge [latex->, orange,dashed, bend right=15] (a)
        edge [<-, >=latex, magenta,dashed, bend left=15] (a)
        edge [<-, blue,dashed, bend left=30] (a)
        edge [latex-, red,dashed, bend left=45] (a)
        ;
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

Not related to the question, but I also changed the old \tikzstyle to \tikzset.

Gonzalo Medina
  • 505,128