# TikZ-cd Exact Sequence with Intermediate Zeros

I've had a problem using TikZ-CD to create long exact sequences for topology. I'm moderately set on using it, because creating long exact sequences of short exact sequences (where there's a vertical chain of the horizontal short sequences) requires TikZ-CD to make, and I really want to be consistent if possible.

However, if some of the middle terms of the sequence are 0 and the sequence is split over two lines (if the sequence is too long), the arrows become disproportionately long around the zeros and trying to use "column sep" has the same problem, just with shorter arrows. On the other hand, trying to use the "shorten" command leaves awkward white space around the terms.

Is there any way to make these arrows a set length to avoid these problems?

MWE:

\usepackage{tkz-graph,amsmath,amssymb,tikz-cd}

\begin{document}
Without shorten:
$\begin{tikzcd} 0 \arrow[r] & H^0(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \arrow[r] & 0 \arrow[r] & H^0(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \arrow[r] & H^1(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) & \mbox{} \\ \phantom{0} \arrow[r] & 0 \arrow[r] & H^1(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \arrow[r] & H^2(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \arrow[r] & 0 \arrow[r] & \cdots. \end{tikzcd}$

\mbox{}

With shorten:
$\begin{tikzcd}[column sep=2ex] 0 \arrow[r] & H^0(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \arrow[r,shorten >=2ex] & 0 \arrow[r,shorten <=2ex] & H^0(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \arrow[r] & H^1(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) & \mbox{} \\ \phantom{0} \arrow[r,shorten >=2ex] & 0 \arrow[r,shorten <=2ex,shorten >=2ex] & H^1(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \arrow[r] & H^2(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \arrow[r,shorten >=2ex] & 0 \arrow[r,shorten <=2ex] & \cdots. \end{tikzcd}$

Desired:
$\begin{split} 0 &\longrightarrow H^0(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \longrightarrow 0 \longrightarrow H^0(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \longrightarrow H^1(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \mbox{} \\ \phantom{0} &\longrightarrow 0 \longrightarrow H^1(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \longrightarrow H^2(\mathbb{R}\text{P}^n ; \mathbb{Z}_2) \longrightarrow 0 \longrightarrow \cdots. \end{split}$
\end{document}`

You could adjust some arrow lengths, but I'm not sure you really need vertical alignment between objects that are not related in any way.

\documentclass{article}
\usepackage{
%tkz-graph,
amsmath,amssymb,tikz-cd
}

\begin{document}

$\begin{tikzcd}[column sep=0.45em] 0 \arrow[r] &[1em] H^0(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \arrow[r] &[-1em] 0 \arrow[r] &[1em] H^0(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \arrow[r] &[1em] H^1(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \\ {} \arrow[r] & 0 \arrow[r] & H^1(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \arrow[r] & H^2(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \arrow[r] & 0 \arrow[r] & \cdots. \end{tikzcd}$
\bigskip
\begin{aligned} 0 &\longrightarrow H^0(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \longrightarrow 0 \longrightarrow H^0(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \longrightarrow H^1(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \\[2ex] &\longrightarrow 0 \longrightarrow H^1(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \longrightarrow H^2(\mathbb{R}\mathrm{P}^n ; \mathbb{Z}_2) \longrightarrow 0 \longrightarrow \cdots. \end{aligned}

\end{document}

I'd prefer the second version.

Actually, I'd do it with \rightarrow, but it's personal preference.

• Your versions certainly look better. So is aligned the only way to achieve the equal-sized arrows? If that's how it is, that's how it is. I just thought I'd see if there was a way to do it in TikZ. Dec 15, 2020 at 20:44
• @Isomorphism tikz-cd is especially for commutative diagrams where you need alignments. Dec 15, 2020 at 20:59