7

How can I enumerate diagrams made with tikz-cd?

I mean, not only enumerate them but enumerate in order to quote them later in the document.

5
  • 3
    Insert them inside an equation as you do with simple formulas.
    – Sigur
    Commented Jan 13, 2015 at 23:22
  • 1
    @Sigur But that leaves much space between the last text line and the begin of the diagram.
    – user
    Commented Jan 13, 2015 at 23:30
  • Don't leave any blank line on your code before/after the equation environment.
    – Sigur
    Commented Jan 13, 2015 at 23:32
  • You'll have to define some diagram environment with a counter of its own. Then I think you can even corss-reference them smartly with the cleveref package.
    – Bernard
    Commented Jan 13, 2015 at 23:52
  • Do you want just a number (as for a standard equation) or do you want something more elaborate as a caption (name+number+separator+description)? Commented Jan 13, 2015 at 23:56

1 Answer 1

8

You just use the standard equation environment:

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

\usepackage{lipsum}% just to have some text
\begin{document}

\lipsum*[2]
\begin{equation}\label{diagram}
\begin{tikzcd}
A\arrow[r,"f"] \arrow[d,"\alpha"] & B \arrow[d,"\beta"] \\
A' \arrow[r,"f'"] & B'
\end{tikzcd}
\end{equation}
\lipsum*[3]
\begin{equation}\label{equation}
A+B+C=D
\end{equation}
some text after the equation just to see the spacing and
for printing the references to diagram~\eqref{diagram}
and to equation~\eqref{equation}.

\end{document}

enter image description here

I can see excess spacing nowhere.

3
  • For some reason, you really have to use equation and not align. Using align causes all sorts of alignment issues.
    – Umang
    Commented Dec 12, 2015 at 17:54
  • @Umang You should use align only for multiline displays. If you have an actual problem with diagrams in align, please ask a new question.
    – egreg
    Commented Dec 12, 2015 at 17:59
  • 1
    I didn't know that equation is more semantically correct that align for single line equations. I posted my comment just as a warning for anyone who (like me) uses align for all equations. Apparently I've been doing this wrong.
    – Umang
    Commented Dec 12, 2015 at 18:07

You must log in to answer this question.

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