5

I'm trying to figure out a good way to use LaTeX to draw the following diagram (snapshot image from a document).

enter image description here

The closest I could come to this is using the following code:

\begin{align}
\begin{array}{ccccccccc}
  0 &\xlongrightarrow & M' & \xlongrightarrow & M & \xlongrightarrow & M'' & \xlongrightarrow & 0\\
  & & \bigg\downarrow & & \bigg\downarrow & & \bigg\downarrow & & \\
  0 &\xlongrightarrow & N' & \xlongrightarrow & N & \xlongrightarrow & N'' &  \xlongrightarrow & 0
\end{array}
\end{align}

which renders to the following picture:

enter image description here

Using the array and align environment does not seem like a good thing to do. Is there a more efficient way to make such a diagram with arrows? I have seen similar posts which suggest TikZ, but I don't know much about it -- maybe I'll learn it. But multiple solutions or pointers in the right direction will be very welcome.

What about arrows at angles (say something from $M'$ in the first row to $N$ in the second row -- it makes no sense in the context here, but I'd like to be able to make such arrows easily, with little modification to the code needed in case of changes)?

Ari Brodsky
  • 2,596
  • 2
    You should learn more about tikz, for diagrams see tikz-cd – daleif Nov 13 '16 at 18:54
  • 1
    Once you've dabbled a bit with TikZ, you'll find it well suited to this kind of diagram. And then you can do things like the Snake Diagram http://tex.stackexchange.com/q/3892/86 – Andrew Stacey Nov 13 '16 at 19:23

4 Answers4

8

If you like a TikZ solution (with also the diagonal arrow):

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
    \begin{tikzcd}%
        0 \arrow[r] & M' \arrow[r] \arrow[d] \arrow[rd] & M \arrow[r]  \arrow[d] & M'' \arrow[r] \arrow[d]  & 0 \\  
        0 \arrow[r] & N' \arrow[r]  & N \arrow[r]  & N'' \arrow[r]  & 0 
    \end{tikzcd}%
\end{document}

enter image description here

CarLaTeX
  • 62,716
3

Here is a simple solution. The long right arrows are produced with hboxes. You can adapt the length; I chose here 1cm.

\documentclass{article}

\usepackage{amsmath}

\newcommand{\Lrightarrow}{\hbox to1cm{\rightarrowfill}}
\newcommand{\Ldownarrow}{\bigg\downarrow}


\begin{document}

\[
  \setlength{\arraycolsep}{1pt}
  \begin{array}{*{9}c}
    0 &\Lrightarrow & M' & \Lrightarrow & M & \Lrightarrow & M'' & \Lrightarrow & 0\\
    & & \Ldownarrow & & \Ldownarrow & & \Ldownarrow & & \\
    0 &\Lrightarrow & N' & \Lrightarrow & N & \Lrightarrow & N'' &  \Lrightarrow & 0
  \end{array}
\]

\end{document}

enter image description here

user94293
  • 4,254
2

Using the amscd package gives similar results, though diagonal arrows are not supported:

\documentclass{article}
\usepackage{amscd}
\begin{document}
\[
\begin{CD}
0 @>>> M' @>>> M @>>> M'' @>>> 0 \\
@. @VVV @VVV @VVV \\
0 @>>> N' @>>> N @>>> N'' @>>> 0
\end{CD}
\]
\end{document}
Ari Brodsky
  • 2,596
1

Here is a solution using the xy-pic package, including a diagonal arrow:

\documentclass{article}
\usepackage[all]{xy}
\begin{document}
\xymatrix{
0 \ar[r]    & M' \ar[d]\ar[r] \ar[dr]   & M \ar[d]\ar[r]    & M'' \ar[d]\ar[r]  & 0 \\
0 \ar[r]    & N' \ar[r]                 & N \ar[r]          & N'' \ar[r]        & 0
}
\end{document}

XY-pic User's Guide

Ari Brodsky
  • 2,596