Take the 2-minute tour ×
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 have the following code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{matrix,arrows}

\begin{document}
  \[
        \begin{tikzpicture}
         \matrix (m) [matrix of math nodes,row sep=3em,column sep=1em,minimum width=2em]{
              A &   & G \\
                & S &   \\
         };
         \path[-stealth]
            (m-1-1) edge node [above] {$f$} (m-1-3)
            (m-1-1)  edge [bend right] node [left] {$p\;$} (m-2-2)
            (m-1-3) edge node [right] {$\;q$} (m-2-2)
            (m-2-2) edge node [right] {$\epsilon$} (m-1-1);
         \path[-stealth]
            ([yshift=5pt]m-1-1) edge node [right] {$g$} ([yshift=5pt]m-1-3);
        \end{tikzpicture}
    \]
\end{document}

I dare you to compile it. Then you will get a disgusting output. What I want is to get the two arrow on top one over the other (just like corolary 1.3.1.5, page 70, in the notes on http://math.umn.edu/~kwlan/articles/cpt-PEL-type-thesis-revision.pdf).

Can anyone help? I would love if the solution didn't modify too much the way I coded the diagram since it is the way I always do it (with the matrix) but beggers can't be choosers, so.

share|improve this question

3 Answers 3

up vote 7 down vote accepted

Here is an attempt to fix it by using the .east and .west anchors:

enter image description here

Notes:

  • Not sure why you were using math mode -- I have removed that in the below MWE.

Code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{matrix,arrows}

\begin{document}
        \begin{tikzpicture}
         \matrix (m) [matrix of math nodes,row sep=3em,column sep=1em,minimum width=2em]{
              A &   & G \\
                & S &   \\
         };
         \path[-stealth]
            (m-1-1.east) edge node [above,yshift=1.0ex] {$f$} (m-1-3.west)
            (m-1-1) edge [bend right] node [left] {$p\;$} (m-2-2)
            (m-1-3) edge node [right] {$\;q$} (m-2-2)
            (m-2-2) edge node [right] {$\epsilon$} (m-1-1);
         \path[-stealth]
            ([yshift=5pt]m-1-1.east) edge node [below,,yshift=-1.0ex] {$g$} ([yshift=5pt]m-1-3.west);
        \end{tikzpicture}
\end{document}
share|improve this answer
    
Amazing, thanks ! –  ortholle Feb 16 at 18:28

It's quite easy with tikz-cd:

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\[
\begin{tikzcd}[column sep=1.5em]
A \arrow[yshift=.85ex]{rr}{f}
  \arrow[yshift=-.45ex,swap]{rr}{g}
  \arrow[yshift=-.4ex,bend right,swap]{dr}{p}
&&
G \arrow{dl}{q} \\
&
S \arrow[swap]{ul}{\epsilon}
\end{tikzcd}
\]
\end{document}

enter image description here

share|improve this answer

Here a variant of Peter's code but without matrix and some adjustment with the position of some arrows.

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

\begin{document}
\begin{tikzpicture}
\path          node (A) {$A$}
    (0:4cm)    node (G) {$G$}
    (-60:4cm)  node (S) {$S$};
 \path[-stealth]
   (A) edge [bend right] node [left]  {$p\;$}      (S)
   (G) edge              node [right] {$\;q$}      (S)
   (S) edge              node [right] {$\epsilon$} (A)
   ([yshift=-2.5pt]A.east) edge node [above,yshift= 1.0ex]  {$f$} ([yshift=-2.5pt]G.west)        
   ([yshift= 2.5pt]G.west) edge node [below,yshift=-1.0ex]  {$g$} ([yshift= 2.5pt]A.east);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer

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.