varkor / quiver

A modern commutative diagram editor for the web.
https://q.uiver.app
MIT License
2.38k stars 79 forks source link

Using within align environment #51

Closed AviSteiner closed 3 years ago

AviSteiner commented 3 years ago

The code

\documentclass{article}
\usepackage{amsmath}
\usepackage{quiver}

\begin{document}

% https://q.uiver.app/?q=WzAsMixbMCwwLCJQIl0sWzEsMCwiUSJdLFswLDEsIlxcdmFycGhpIiwwLHsib2Zmc2V0IjotMX1dLFswLDEsIjAiLDIseyJvZmZzZXQiOjF9XV0=
\begin{align}
    \begin{tikzcd}
        {P} & {Q}
        \arrow["{\varphi}", from=1-1, to=1-2, shift left=1]
        \arrow["{0}"', from=1-1, to=1-2, shift right=1]
    \end{tikzcd}
\end{align}

\end{document}

produces the error image

When align is replaced by equation, this doesn't happen. Is this a problem with tikzcd or with quiver?

varkor commented 3 years ago

& has a different meaning inside align, which is conflicting with the meaning inside tikzcd. You can use the ampersand replacement option to overwrite the tikz-cd symbol:

\begin{align}
    \begin{tikzcd}[ampersand replacement=\&]
        {P} \& {Q}
        \arrow["{\varphi}", from=1-1, to=1-2, shift left=1]
        \arrow["{0}"', from=1-1, to=1-2, shift right=1]
    \end{tikzcd}
\end{align}

I'm not sure whether this is something I want to handle inside quiver directly, because I think this is a fairly uncommon use-case (as opposed to using equation, for instance), and when it is needed, one can perform the ampersand replacement manually.

If you disagree, let me know, and we can discuss a possible solution.

varkor commented 3 years ago

I've opened an issue for ampersand replacement here: https://github.com/varkor/quiver/issues/51, because I think it would be a useful option.