5

How can I reverse some arrows of the diagram given by the code below?

\begin{tikzpicture}
  % Tell it where the nodes are
  \node (A) {$A$};
  \node (B) [below=of A] {$B$};
  \node (C) [right=of A] {$C$};
  \node (D) [right=of B] {$D$};
  % Tell it what arrows to draw
  \draw[-stealth] (A)-- node[left] {\small $i$} (B);
  \draw[-stealth] (B)-- node [below] {\small $g$} (D);
  \draw[-stealth] (A)-- node [above] {\small $j$} (C);
  \draw[-stealth] (C)-- node [right] {\small $k$} (D);
\end{tikzpicture}
  • Do you want to add extra arrows or just change the direction of some of the existing arrows? – Gonzalo Medina Dec 8 '11 at 20:23
  • 1
    Just to change the directions of some/all of them. Thank you – Nadori Dec 8 '11 at 20:27
10

You can either interchange - and the specification of the arrow tip, or you can also interchange the order of the nodes; the following code shows both options:

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

\begin{document}

\begin{tikzpicture}
  \node (A) {$A$}; 
  \node (B) [below=of A] {$B$}; 
  \node (C) [right=of A] {$C$}; 
  \node (D) [right=of B] {$D$};
  \draw[-stealth] (A)-- node[left] {\small $i$} (B); 
  \draw[-stealth] (B)-- node [below] {\small $g$} (D); 
  \draw[-stealth] (A)-- node [above] {\small $j$} (C); 
  \draw[-stealth] (C)-- node [right] {\small $k$} (D); 
\end{tikzpicture}

\begin{tikzpicture}
  \node (A) {$A$}; 
  \node (B) [below=of A] {$B$}; 
  \node (C) [right=of A] {$C$}; 
  \node (D) [right=of B] {$D$};
  \draw[stealth-] (A)-- node[left] {\small $i$} (B); 
  \draw[stealth-] (B)-- node [below] {\small $g$} (D); 
  \draw[-stealth] (C)-- node [above] {\small $j$} (A); 
  \draw[-stealth] (D)-- node [right] {\small $k$} (C); 
\end{tikzpicture}

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.