7

I want all the vertical lines parallel in this example. How can I manage that? Thanks a lot. Here is a picture.

picture

\documentclass{scrartcl}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amsfonts}

\usetikzlibrary{matrix,arrows,calc}
\begin{document}
\begin{center}
\begin{tikzpicture}[]
\matrix (m) [matrix of math nodes, row sep=1.5em,
              column sep=1.5em, text height=1.5ex, text depth=0.25ex, text centered]
              {
                          & 0 &   & A &       & A\amalg_AB     &       & C     & & 0\\
                        0 &   & A &       & B     &                        & C     &       & 0\\    
                          & 0 &   & A &       & A\amalg_AB &       & C & & 0\\
                    0 &   & A &       & B &                        & C &       & 0\\
              };
              \path[->,font=\scriptsize]

                    (m-2-1) edge node[auto] {} (m-2-3)
                    (m-2-3) edge node[auto] {$f$} (m-2-5)               
                    (m-2-5) edge node[auto] {$g$} (m-2-7)
                    (m-2-7) edge node[auto] {} (m-2-9)

                    (m-4-1) edge node[auto] {} (m-4-3)
                    (m-4-3) edge node[auto] {$f$} (m-4-5)               
                    (m-4-5) edge node[auto] {$g$} (m-4-7)
                    (m-4-7) edge node[auto] {} (m-4-9)

                    (m-1-2) edge node[auto] {} (m-1-4)
                    (m-1-4) edge node[auto] {$$} (m-1-6)                
                    (m-1-6) edge node[auto] {$$} (m-1-8)
                    (m-1-8) edge node[auto] {} (m-1-10)

                    (m-3-2) edge node[auto] {} (m-3-4)
                    (m-3-4) edge node[auto] {$$} (m-3-6)                
                    (m-3-6) edge node[auto] {$$} (m-3-8)
                    (m-3-8) edge node[auto] {} (m-3-10)

                    (m-2-3) edge node[auto] {} (m-1-4)
                    (m-2-5) edge node[auto] {} (m-1-6)
                    (m-2-7) edge node[auto] {} (m-1-8)

                    (m-4-3) edge node[auto] {} (m-3-4)
                    (m-4-5) edge node[auto] {} (m-3-6)
                    (m-4-7) edge node[auto] {} (m-3-8)
                    ;
            \end{tikzpicture}
           \end{center}
  \end{document}
  • 1
    Adding text width=1cm counts? – percusse Jun 28 '13 at 17:52
  • Same problem like here: How to ensure consecutive diagonal arrows form a straight line?. The tikz-cd package uses a \matrix internally. For example, you could use column sep={between origins,3.5em} and get parallel arrows, although you have to make sure that the nodes are not overlapping or too narrow. – Qrrbrbirlbel Jun 28 '13 at 17:54
  • Could somebody "translate" me this solution into my example. I am totally no expert I never used "tikzcd", what is used in the solution you mentioned. – Jack Jun 28 '13 at 18:02
  • It's easier to type A' instead of A^\prime or A^\pr defining a new command. The result is precisely the same. – egreg Jun 28 '13 at 18:03
  • Thanks for the advice. But I still didn't solve my actual problem. – Jack Jun 28 '13 at 18:06
3

With the help of Qrrbrbirlbel, here's a solution with tikz-cd:

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

\newcommand\push[3]{#1\amalg_{#2}#3}

\begin{document}
\begin{tikzcd}[column sep={{{{3em,between origins}}}}]%[bo column sep=3em]
{} & 
0 \arrow{rr} &&
A' \arrow{rr} &&
\smash[b]{\push{A'}{A}{B} \arrow{rr}} &&
C \arrow{rr} &&
0
\\
0 \arrow{rr} &&
A \arrow{rr}{f} \arrow{ur} &&
B \arrow{rr}{g} \arrow{ur} &&
C \arrow{rr} \arrow{ur} &&
0
\\
{} & 
0 \arrow{rr} &&
A' \arrow{rr} &&
\smash[b]{\push{A'}{A}{B'}} \arrow{rr} &&
C' \arrow{rr} &&
0
\\
0 \arrow{rr} &&
A \arrow{rr}{f'} \arrow{ur} &&
B' \arrow{rr}{g'} \arrow{ur} &&
C' \arrow{rr} \arrow{ur} &&
0
\end{tikzcd}
\end{document}

The only subtle points are

  1. column sep={{{{3em,between origins}}}} with four pairs of braces.
  2. the \smash[b]{...} around the push out, in order to get the same length for the middle arrows.

The syntax of tikz-cd is surely more friendly. I believe that a bug report to the author of tikz-cd in order to fix the column sep problem is in order.

enter image description here

  • The bug fix is essentially only \patchcmd\tikzcd@sep{=#2}{={#2}}{}{}. Then only one pair of { } is needed (as usual for the ,). But then one cannot use pre-defined settings like normal and so on. – Qrrbrbirlbel Jun 28 '13 at 19:59
  • Thank you very much. I will begin using tikz-cd. I am only interested in drawing diagrams anyway. – Jack Jun 29 '13 at 11:44

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.