11

I have two questions. There must be an easy way for the diagram that I am trying to draw, but I am totally new to drawing diagrams in tex. Xy-pic package seems too complicated, thus I am trying TikZ-package.

  1. How do I change the arrows in my matrix to simply to $\Rightarrows$, I solved it by [double], but it does not look nice and the color of arrows are somehow different.

  2. How can I add two arrows between two nodes. Simply, I want to write $A \Rightarrow B$ and $B \nLightarrow A$ between my two nodes A and B. I could not also solve the bending problem yet.

Here is my code up to now.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes, row sep=3em, column sep=3em, text
            height=1.5ex, text depth=0.25ex] 
            {   & X & & \\
              A & B & C & D \\
              E & F & G & H \\
                  & I & & \\};
            \path[->] (m-1-2) edge [double] (m-2-3)
                               edge [double,bend left=90] (m-4-2);
             \path[->] (m-2-1) edge [double] (m-2-2)
                               edge [double] (m-3-1)
                               edge [double] (m-1-2);
             \path[->] (m-2-2) edge  [double] (m-2-3)
                               edge  [double] (m-3-2);
             \path[->] (m-2-3) edge [double] (m-2-4)
                               edge [double] (m-3-3);
             \path[->] (m-2-4) edge [double] (m-3-4);
             \path[->] (m-3-1) edge [double] (m-3-2)
                               edge [double] (m-4-2);
             \path[->] (m-3-2) edge [double](m-3-3); 
             \path[->] (m-3-3) edge [double] (m-3-4); 
             \path[->] (m-4-2) edge [double] (m-3-3);
             \end{tikzpicture}
             \end{document}
David Carlisle
  • 757,742
Derya
  • 215

3 Answers3

12

Here's one option using the tikz-cd package which facilitates the creation of commutative diagrams:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}
& X\arrow[Rightarrow]{dr}{}\arrow[Rightarrow,to path={..controls +(-2.5,0.7) and +(-2.5,-0.7).. (\tikztotarget)}]{ddd}{}    \\
A \arrow[Rightarrow]{ur}{}\arrow{r}{}\arrow{d} & B \arrow{r}{}\arrow{d} & C\arrow{r}{}\arrow{d} & D\arrow{d}\\
E \arrow[Rightarrow]{dr}{} \arrow{r}{} & F \arrow{r}{} & G\arrow{r}[color=red]{} & H\\
& I\arrow[Rightarrow]{ur}{}\\
\end{tikzcd}

\end{document}

enter image description here

If all the arrows should be given the style of \Rightarrow, it's enough to use the arrows=Rightarrow option:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}[arrows=Rightarrow]
& X\arrow{dr}{}\arrow[to path={..controls +(-2.5,0.7) and +(-2.5,-0.7).. (\tikztotarget)}]{ddd}{} \\
A \arrow{ur}{}\arrow{r}{}\arrow{d} & B \arrow{r}{}\arrow{d} & C\arrow{r}{}\arrow{d} &    D\arrow{d} \\
E \arrow{dr}{} \arrow{r}{} & F \arrow{r}{} & G\arrow{r}[color=red]{} & H \\
& I\arrow{ur}{}
\end{tikzcd}

\end{document}

enter image description here

I initially forgot question 2. You can use the in=, out= keys to bend the arrows:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}[arrows=Rightarrow]
& X\arrow{dr}{}\arrow[to path={..controls +(-2.5,0.7) and +(-2.5,-0.7).. (\tikztotarget)}]{ddd}{} \\
A \arrow{ur}{}\arrow[out=30,in=150]{r}{}\arrow{d} & B \arrow[out=210,in=330]{l}{}\arrow{r}{}\arrow{d} & C\arrow{r}{}\arrow{d} &    D\arrow{d} \\
E \arrow{dr}{} \arrow{r}{} & F \arrow{r}{} & G\arrow{r}[color=red]{} & H \\
& I\arrow{ur}{}
\end{tikzcd}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • 1
    @Derya: You're welcome! Since my response seems to have answered your question, please consider marking it as ‘Accepted’ by clicking on the tickmark below its vote count. – Gonzalo Medina Apr 06 '12 at 17:34
  • 1
    @Derya I think you got the wrong answer accepted since this is much more elaborate. :) – percusse Apr 06 '12 at 18:17
  • @percusse:lol.I tried accepting both, just saw I cant do that.. – Derya Apr 06 '12 at 18:56
7

This is a little bit of a simplification and I've put the drawing commands into a foreach loop. It's a little hard to understand what the end product should look like. Moreover, the coloring seems to be a PDF viewer issue since SumatraPDF doesn't exhibit this problem. The reqired arrow name is implies and can be found in arrows library documentation. I didn't want to make it too terse for the sake of simplification but it's certainly possible.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}[>=implies]
\matrix (m) [matrix of math nodes, nodes in empty cells, row sep=3em, column sep=3em, 
text height=1.5ex, text depth=0.25ex] 
        {   & X & &     \\
          A & B & C & D \\
          E & F & G & H \\
              & I & &   \\};

\foreach[remember=\x as \lastx (initially 1)] \x in {2,...,4}{
    \draw[double,->] (m-2-\lastx) -- (m-2-\x);
    \draw[double,->] (m-3-\lastx) -- (m-3-\x);
}

\foreach \x in {1,...,4}{\draw[double,->] (m-2-\x) -- (m-3-\x);}

\draw[double,->] (m-1-2) -- (m-2-3);
\draw[double,->] (m-2-1) -- (m-1-2);
\draw[double,->] (m-4-2) -- (m-3-3);
\draw[double,->] (m-3-1) -- (m-4-2);
\draw[double,->] (m-1-2) .. controls ([xshift=-1.2cm]m-1-1) and ([xshift=-1.2cm]m-4-1) .. (m-4-2);
\end{tikzpicture}
\end{document}

enter image description here

percusse
  • 157,807
0

One way of changing arrows to $\Rightarrows$ is using tikz-cd by adding [commutative diagrams/Rightarrow] to edge. The following code is a slightly modified version of the answer and it can be found on tikzcd manual (page 13) as a pentagon diagram.

Code is not the same as yours but it gives the essential idea of turning edges into Rightarrow of tikz-cd.

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\newlength{\edgelentgh}
\setlength{\edgelentgh}{3cm}
\[
\begin{tikzcd}[row sep={0cm,between origins},column sep={0cm,between origins}] %setting seperators to zero for easier manipulation
&[.3090169944\edgelentgh]
&[.5\edgelentgh] % above value times golden ratio
F'(U_2)\arrow{ddl}\arrow{ddr}\arrow{drr} 
&[.5\edgelentgh] 
&[.3090169944\edgelentgh]\\[.5877852523\edgelentgh]
 F'(U_1)\arrow{urr}\arrow{rrrr}\arrow{dr}\arrow{drrr} 
&&&& F'(U_3) \arrow{dlll}\arrow{dl} 
\\[.9510565163\edgelentgh] % above value times golden ratio
& 
F(V)\arrow{rr} 
&& 
F(W) 
& 
\end{tikzcd}
\]      

% This example is given in the tikz-cd manual:
\begin{tikzpicture}[commutative diagrams/every diagram]
\node (P0) at (90:.8506508084\edgelentgh) {$F'(U_2)$};
\node (P1) at (90+72:.8506508084\edgelentgh) {$F'(U_1)$} ;
\node (P2) at (90+2*72:.8506508084\edgelentgh) {$F(V)$};
\node (P3) at (90+3*72:.8506508084\edgelentgh) {$F(W)$};
\node (P4) at (90+4*72:.8506508084\edgelentgh) {$F'(U_3)$};
%
\path[commutative diagrams/.cd, every arrow, every label]
(P0) edge[commutative diagrams/Rightarrow] node (P4)
(P3) edge[commutative diagrams/Rightarrow] node[swap] (P4)
(P1) edge[commutative diagrams/Rightarrow] node (P0)
(P1) edge[commutative diagrams/Rightarrow] node[swap] (P2) 
(P2) edge[commutative diagrams/Rightarrow] (P3);
\end{tikzpicture}
\end{document}
512122
  • 195
  • 1
  • 6