A package for nested commutative diagrams

Is there a package that offers nested commutative diagrams? I want to be able to use a commutative diagram in a marginal note to a main diagram. The idea of what I'm looking for should hopefully be given by the following, non-working code.

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
a \arrow[r] \arrow[d] & b \arrow[d] \\
c \arrow[r] \arrow[d] & d \arrow[d] & \text{since}
\begin{tikzcd}
e \arrow[r] \arrow[d] & f \arrow[d] \\
g & h
\end{tikzcd}
i & k
\end{tikzcd}
\end{document}

• you can always do the inner one first in a \savebox then just \usebox to nest it. Mar 2, 2021 at 14:59
• @DavidCarlisle Thanks, it works. If you make that an answer I'll accept it.
– mjc
Mar 2, 2021 at 15:15

You can do the inner one first in a \savebox then use \usebox to nest it.

You can also make a single TikZ-cd:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
a\ar[r]\ar[dd] & b\ar[dd] &[-1em] &[-2em]\\
&&& c\ar[r]\ar[dd] & f\ar[dd]\$-4ex] c\ar[r]\ar[dd] & d\ar[dd] & \text{since}\\[-3ex] &&& g & h\\ i & k \end{tikzcd} \end{document}  These are two diagrams. \documentclass{article} \usepackage{amsmath} \usepackage{tikz-cd} \begin{document} \[ \begin{gathered} \begin{tikzcd} a \arrow[r] \arrow[d] & b \arrow[d] \\ c \arrow[r] \arrow[d] & d \arrow[d] \\ i & k \end{tikzcd} \end{gathered} \quad\text{since}\quad \begin{gathered} \begin{tikzcd} e \arrow[r] \arrow[d] & f \arrow[d] \\ g & h \end{tikzcd} \end{gathered}$

\end{document}