# Manipulate cell width in tikz-cd

This is something of a nitpick, but I'm having some trouble getting to grips with tikz-cd. I'm not sure of the TikZ terminology, but I think I'm trying to find a way to manipulate cell widths. Here's a minimal example to illustrate my problem:

\documentclass{minimal}
\usepackage{tikz, tikz-cd}

\begin{document}
\begin{tikzcd}
A \rar \dar & B \rar \dar & C \dar \\
D \rar      & E \rar      & F \oplus G
\end{tikzcd}
\end{document}


I'd like to make the arrow from B to C the same length as that from E to F+G. My first thought was that I should pad the box (cell?) containing C so it's the same width as the one containing F + G. I can sort of do it by replacing C with \quad C \quad, but surely there must be a better way! Does anyone know how to do this?

Sure, you can set C inside a box that is exactly the width of F \oplus G:

\documentclass{article}
\usepackage{calc,tikz-cd}

\begin{document}
\begin{tikzcd}
A \rar \dar & B \rar \dar & \makebox[\widthof{$F \oplus G$}]{$C$} \dar \\
D \rar      & E \rar      & F \oplus G
\end{tikzcd}
\end{document}


calc's command \widthof is used to measure the width of F \oplus G, setting C in a centred box of that exact width.

You have to fool tikz-cd into thinking that the lower right corner object has zero width; then you can artificially shorten the arrow to it.

\documentclass{article}
\usepackage{tikz-cd,mathtools}

\begin{document}
\begin{tikzcd}
A \arrow{r} \arrow{d} & B \arrow{r} \arrow{d} & C \arrow{d} \\
D \arrow{r}           & E \arrow[end anchor={[xshift=-1.25em]}]{r}
& \mathclap{F \oplus G}
\end{tikzcd}
\end{document}


The command \mathclap is provided by mathtools.

Sincerely, I prefer the default version.

• Oh, that's a nice way of doing it - not quite what I had in mind but it seems to be what I was looking for. Thanks! – DavidR Nov 4 '13 at 19:48

Not a new problem:

## Code

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}\centering
\begin{tikzcd}[
matrix of math nodes maybe/.append style={
/tikz/column 3/.append style={
/tikz/nodes={
text width=\widthof{$F\oplus G$},
align=center}}}]
A \rar \dar & B \rar \dar & C \dar \\
D \rar      & E \rar      & F \oplus G
\end{tikzcd}\medskip\par
\begin{tikzcd}
A \rar \dar & B \rar \dar &
|[text width=\widthof{$F\oplus G$}, align=center]|C \dar \\
D \rar      & E \rar      & F \oplus G
\end{tikzcd}\bigskip

\begin{tikzcd}
A \rar \dar & B \rar \dar & C \dar \\
D \rar      & E \rar      & |[overlay]| F \oplus G
\end{tikzcd}\medskip\par
\begin{tikzcd}[nodes=overlay, row sep=large, column sep=large]
A \rar \dar & B \rar \dar & C \dar \\
D \rar      & E \rar      & F \oplus G
\end{tikzcd}\bigskip

\begin{tikzcd}[/tikz/column sep=
{\pgfkeysvalueof{/tikz/commutative diagrams/column sep/large},between origins}]
A \rar \dar & B \rar \dar & C \dar \\
D \rar      & E \rar      & F \oplus G
\end{tikzcd}\bigskip
\end{document}