3

This question already has an answer here:

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}

marked as duplicate by koleygr, CarLaTeX, Stefan Pinnow, Troy, Mico Oct 22 '17 at 5:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Do you need the equation to be numbered? – koleygr Oct 22 '17 at 4:19
  • 1
    By substituting \documentclass{article} to \documentclass[border=1 pt]{standalone}, the error goes away. – Roboticist Oct 22 '17 at 4:19
  • @koleygr: It should be numbered. – A.Loc Oct 22 '17 at 4:20
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}

Not the answer you're looking for? Browse other questions tagged or ask your own question.