0

I'm doing a lot of equations with tikzcd, and for some bigger equations I want the equation number labet to be on the bottom of the diagram. Is there any way to achieve this without manipulating the width of the diagram?

I apologize in advance for the stupid example :-)

\begin{equation}
\begin{tikzcd}
A \arrow[r] & B \arrow[d]\arrow[r] & B \arrow[d]\arrow[r]  & B \arrow[d]\arrow[r]  & B \arrow[d] \arrow[r]& B \arrow[d] \arrow[r] & B \arrow[d] \arrow[r]& B \arrow[d]       \\
D \arrow[u] & C \arrow[l] & C \arrow[l] & C \arrow[l] & C \arrow[l] & C \arrow[l] & C \arrow[l] & C \arrow[l] 
\end{tikzcd}
\end{equation}

enter image description here

2 Answers 2

2

amsmath will lower the equation number when the display is too wide. You can make it artificially too wide by using a box.

However, you need ampersand replacement, because & only works when the tikzcd environment is not in the argument to a command.

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

\usepackage{lipsum}

\begin{document}

\lipsum[1][1-4]
\begin{equation}
\makebox[\displaywidth]{%
  \begin{tikzcd}[ampersand replacement=\&]
  A \arrow[r] \& B \arrow[d]\arrow[r] \& B \arrow[d]\arrow[r] \&
  B \arrow[d]\arrow[r]  \& B \arrow[d] \arrow[r]\& B \arrow[d] \arrow[r] \&
  B \arrow[d] \arrow[r]\& B \arrow[d]
  \\
  D \arrow[u] \& C \arrow[l] \& C \arrow[l] \& C \arrow[l] \& C \arrow[l] \&
  C \arrow[l] \& C \arrow[l] \& C \arrow[l]
  \end{tikzcd}%
}
\end{equation}
\lipsum[1][1-4]

\end{document}

enter image description here

On the other hand, it's hard to find a reason for this strange placement.

1

Since I do not have the embedding document, I need to guess.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\begin{multline}
\begin{tikzcd}[ampersand replacement=\&]
A \arrow[r] \& B \arrow[d]\arrow[r] \& B \arrow[d]\arrow[r]  \& B \arrow[d]\arrow[r]  \& B \arrow[d] \arrow[r]\& B \arrow[d] \arrow[r] \& B \arrow[d] \arrow[r]\& B \arrow[d]       \\
D \arrow[u] \& C \arrow[l] \& C \arrow[l] \& C \arrow[l] \& C \arrow[l] \& C \arrow[l] \& C \arrow[l] \& C \arrow[l] 
\end{tikzcd}\\
\end{multline}
\end{document}
4
  • Using multiline with the \end{tikzcd}\\ does place the label in the correct place, but it misaligns the equation. Instead of being centered it is left aligned. Also, why do you use [ampersand replacement=\&]?
    – nancytrain
    May 17, 2021 at 19:23
  • @nancytrain You can also use \begin{align} \begin{tikzcd}[ampersand replacement=\&] ... \end{tikzcd}\notag \\ \end{align}. I use ampersand replacement to distinguish the ampersands in the tikzcd matrix from the ones in the amsmath environment because otherwise they can lead to confusion or errors.
    – user242026
    May 17, 2021 at 19:31
  • That does work, even though it looks like black magic. Is there any way to put [ampersand replacement=\&] on the align so I don't need to replace & in all my equations?
    – nancytrain
    May 17, 2021 at 19:52
  • @nancytrain No, as far as I know there is no easy way to install an ampersand replacement for amsmath environments.
    – user242026
    May 17, 2021 at 19:56

You must log in to answer this question.

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