5

I'm going crazy with this error:

Bad math environment delimiter. \end{equation}
You can't use `\eqno' in restricted horizontal mode. \end{equation}

of the following MWE:

\documentclass[border=1 pt]{standalone}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{tikz-cd}

\begin{document}
    \begin{tikzcd}[row sep=huge, column sep=huge]
        \textbf{B} \arrow[r,"M"] & \text{Y}\\
        \textbf{X} \arrow[r,swap,"M"] \arrow[u,"project"] & \text{A} \arrow[u,"project", swap]
    \end{tikzcd}
\begin{equation}
    project \circ M = M \circ project
\end{equation}
\end{document}

1 Answers1

6

Solution here: How to make a standalone document with one equation?

Explanation: The standalone document class has no sections or structure and doesn't know which equation number to use. The preview option allows section and equation numbers.

Another solution would be to use custom centered inline math and custom number inside a tikzpicture.

\documentclass[border=1pt,preview]{standalone} % <- Added "preview" option
\usepackage{amsmath} % for \text macro
\usepackage{mathrsfs}
\usepackage{tikz-cd}

\begin{document}
    \begin{tikzcd}[row sep=huge, column sep=huge]
        \textbf{B} \arrow[r,"M"] & \text{Y}\\
        \textbf{X} \arrow[r,swap,"M"] \arrow[u,"\text{project}"] 
        & \text{A} \arrow[u,"\text{project}", swap]
    \end{tikzcd}

\begin{equation}
    \text{project} \circ M = M \circ \text{project} \tag{5.1} %<-If you dont want "(1)"
\end{equation}
\end{document}
Mico
  • 506,678
koleygr
  • 20,105