With the gathered
subsidiary environment, the code
\newcommand{\id}{\mathrm{id}}
\[\begin{gathered}
\text{if $g$ is a left-inverse of $f$, then }
\begin{tikzcd}
A\ar[r, "f"]\ar[rr, "\id_A"', bend right = 30] & B\ar[r, "g"] & A
\end{tikzcd}
\text{ commutes; and,}\\
\text{if $g$ is a right-inverse of $f$, then }
\begin{tikzcd}
B \ar[r, "g"]\ar[rr, "\id_B", bend right = 30] & A\ar[r, "f"] & B
\end{tikzcd}
\text{ commutes.}
\end{gathered}\]
Now, I wish to use align the sentences at the commutative diagrams. I try the following using the align*
environment:
\begin{align*}
\text{if $g$ is a left-inverse of $f$, then }
& \begin{gathered}[c]
\begin{tikzcd}
A\ar[r, "f"]\ar[rr, "\id_A"', bend right = 30] & B\ar[r, "g"] & A
\end{tikzcd}
\end{gathered}
\text{ commutes; and,}\\
\text{if $g$ is a right-inverse of $f$, then } &
& \begin{tikzcd}
B \ar[r, "g"]\ar[rr, "\id_B", bend right = 30] & A\ar[r, "f"] & B
\end{tikzcd}
\text{ commutes.}
\end{align*}
But the ampersands of align*
and tikzcd
seem to get mixed up. I get the following error messages:
- Package pgf Error: Single ampersand used with wrong catcode. \end{align*}
- Package pgf Error: No shape named `tikz@f@6-1-3' is known. I think the culprit is a tikzcd arrow in cell 1-1.
- Package pgf Error: Single ampersand used with wrong catcode. \end{align*}
- Package pgf Error: No shape named `tikz@f@7-1-3' is known. I think the culprit is a tikzcd arrow in cell 1-1.
- Package pgf Error: Single ampersand used with wrong catcode. \end{align*}
- Package pgf Error: No shape named `tikz@f@8-1-3' is known. I think the culprit is a tikzcd arrow in cell 1-1.
- Package pgf Error: Single ampersand used with wrong catcode. \end{align*}
- Package pgf Error: No shape named `tikz@f@9-1-3' is known. I think the culprit is a tikzcd arrow in cell 1-1. Overfull \hbox (66.04643pt too wide) detected
How can I get around this?
tikz-cd
manual. Insidealign
&
has special meaning other than the one used intikzcd
so they clash.\[...\]
andgathered
here. Or, worse,align*
tabular
or in fact I wouldn't align at all, and just use paragraphs.align*
so that I the lower diagram is exactly below the upper one. And I usedgathered
so that I could break the first line after "and;". I couldn't use\[...\]
here for this. And\beging{tikzcd} ... \end{tikzcd}
will not be centered if I don't use a super-environment like\[...\]
.tabular
gave me what I wanted!