9

I am trying to typeset the Mayer-Vietoris sequence (concisely - without the map names above the arrows). Currently I am simply using the AMS align environment with a bunch of \rightarrow, \cdots and a \hphantom to align the last line horizontally:

\begin{align*}
\cdots & \rightarrow H_{n}\left(A\cap B\right)\rightarrow H_{n}\left(A\right)\oplus H_{n}\left(B\right)\rightarrow H_{n}\left(X\right)\rightarrow \\
 & \rightarrow H_{n-1}\left(A\cap B\right)\rightarrow\cdots \\
 & \hphantom{\rightarrow H_{n}\left(A\cap B\right)\rightarrow H_{n}\left(A\right)\oplus H_{n}\left(B\right)}\cdots\rightarrow H_{0}\left(X\right)\rightarrow 0
\end{align*}

The result looks like this:

mv1

I would like to align the first arrow on the last line correctly under the penultimate arrow on the first line, and also to merge the last line with the second one, so it looks like this (image made with image editor):

mv2

How should I do this?

3 Answers 3

8

Here is a possible solution using the package mathtools (which is kind of a successor of amsmath):

% arara: pdflatex

\documentclass{article}
\usepackage{mathtools}

\begin{document}    
    \begin{alignat*}{2}
        \cdots &\rightarrow H_{n}(A\cap B)\rightarrow H_{n}(A)\oplus H_{n}(B) &&\rightarrow H_{n}(X)\rightarrow \\
        &\rightarrow H_{n-1}(A\cap B)\rightarrow\cdots &&\mathllap{\cdots}\rightarrow H_{0}(X)\rightarrow 0
    \end{alignat*}  
\end{document}

enter image description here

A short explanation:

I used an alignat with two alignment points (as requested by you). First, I tried to push the \cdots to the right with \hfill but this does not work here. For sure you could find some array solution with this trick.

Therefore, I had to add the dots to the right of the second alignment mark and change its width to zero. The command \mathllap is provided by mathtools and smashes the box width setting its content to the left.

1
  • 1
    Thanks, this is exactly what I wanted :) I am already using mathtools in my work but I am not proficient with it. Commented Jan 8, 2015 at 10:41
6

Here's another solution using tikz-cd, which I personally use for such diagrams most of the time:

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\begin{document}
\[
    \begin{tikzcd}[arrows=to]
        \cdots \rar & H_n(A \cap B) \rar & H_n(A) \oplus H_n(B) \rar & H_n(X) \rar & \hphantom{0}\\
        \hphantom{\cdots} \rar 
        & H_{n-1}(A \cap B) \rar 
        & \makebox[\widthof{$H_n(A) \oplus H_n(B)$}][c]{$\cdots\hfill \cdots$} \rar
        &  H_0(X) \rar & 0
    \end{tikzcd}
\]
\end{document}

Output:

enter image description here

The advantage of this solution is the customizability provided by tikz. For example you can easily

  • make the diagram smaller (or bigger) by using the keys row sep and column sep
  • add colors
  • add labels to the arrows and customize them in terms of position and orientation
5

You can exploit the direct sum symbol and avoid any computation:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
\cdots & \to H_{n}(A\cap B)\to H_{n}(A) & {}\oplus H_{n}(B) & \to H_{n}(X)\to \\
       & \to H_{n-1}(A\cap B)\to\cdots  & \cdots          & \to H_{0}(X)\to 0
\end{alignat*}

\end{document}

enter image description here

Note that I removed \left and \right, which make no sense in this case. Using \to instead of \rightarrow is just a personal preference (it's surely faster to type).

Alternative solution, in case a suitable fake alignment point is not available, using ideas from https://tex.stackexchange.com/a/209732/4427

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\Spread}[2]{%
  \ifmeasuring@
    #2%
  \else
    \makebox[\ifcase\expandafter #1\maxcolumn@widths\fi]{$\displaystyle#2$}%
  \fi
}
\makeatother


\begin{document}

\begin{alignat*}{2}
\cdots \to {} & H_{n}(A\cap B)\to H_{n}(A) \oplus H_{n}(B)        && \to H_{n}(X)\to \\
       \to {} & \Spread{2}{H_{n-1}(A\cap B)\to\cdots\hfill\cdots} && \to H_{0}(X)\to 0
\end{alignat*}

\end{document}

The first argument to \Spread is the column number.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .