As for your suggestion to wrap the tikzcd
environment in a tikzpicture
. Please don't! This amounts to nesting tikzpicture
, which is not supported and can lead to all sorts of complications.
I will assume that you are not looking for something like the example on the top of p. 13 of the tikz-cd
manual. This allows you to embed matrices in the tikzpicture
but it won't support the \arrow
command (without further ado). That this, the following assumes that you do want to use the \arrow
command. Then there are at least two ways to add plain TikZ code:
execute at end picture
, see here for an original post on this.
remember picture
.
Both allow you to draw stuff, and to access nodes from the diagram. You may use either alias
or \tikzcdmatrixname-<row>-<column>
, which is the predefined node name.
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\subsection*{Method 1: \texttt{execute at end picture}}
\begin{tikzcd}[execute at end picture={
\draw[-latex,red] ([yshift=1cm]A) to[out=45,in=170] ([yshift=1cm]C)
to[out=-10,in=45] (F);
\draw[blue] ([yshift=0.5em]D.north west) to[out=20,in=180]
([yshift=1.5em]E.north) to[out=0,in=160] ([yshift=-0.5em]F.south east);}]
& |[alias=A]|A \arrow[r] & B\arrow[loop above] & |[alias=C]| C\arrow[l]\\
|[alias=D]|D\arrow[r] & |[alias=E]| E\arrow[loop above] & & |[alias=F]| F\arrow[ul]\\
& G\arrow[u] & H\arrow[ul] & \\
& J\arrow[u] & & \\
\end{tikzcd}
\subsection*{Method 2: \texttt{remember picture}}
\begin{tikzcd}[remember picture]
& |[alias=A]|A \arrow[r] & B\arrow[loop above] & |[alias=C]| C\arrow[l]\\
|[alias=D]| D\arrow[r] & |[alias=E]| E\arrow[loop above] & & |[alias=F]| F\arrow[ul]\\
& G\arrow[u] & H\arrow[ul] & \\
& J\arrow[u] & & \\
\end{tikzcd}
\begin{tikzpicture}[overlay,remember picture]
\draw[-latex,red] ([yshift=1cm]A) to[out=45,in=170] ([yshift=1cm]C)
to[out=-10,in=45] (F);
\draw[blue] ([yshift=0.5em]D.north west) to[out=20,in=180]
([yshift=1.5em]E.north) to[out=0,in=160] ([yshift=-0.5em]F.south east);
\end{tikzpicture}
\end{document}

If you are more familiar with calc
(instead of the yshift
s) this will also work provided you load the library. As you can see, overlay
has the slight disadvantage that the bounding box does not get adjusted, but may be argued to be less "hacky".