Open kpym opened 5 years ago
To somehow allow a tikzcd inside a tikzpicture is a good feature to add. There are a few other ways to achieve this, and I'm not sure your proposal is the best option — as you said on stackexchange, it is not "in the spirit of tikz".
One thing that works (and has always worked) is to put the tikzcd environment inside a \node
. Another possibility I can imagine is to define a style so that \matrix[commutative diagram]{
diagram contents}
produces a diagram.
The problem with including tikzcd
inside a node
is that this do not help with drawing on the diagram, and that including \tikzpicture
inside node
is not always a good idea.
But I agree that if you can produce a single style commutative diagram
such that any code write inside tikzcd
can be copy/pasted inside \matrix[commutative diagram]
will be a good solution. In this case the tikzcd
environment will simply be equivalent to \tikz\matrix[commutative diagram]{...};
.
The solution that I propose has the pros :
tikzpicture
the code stays the same;tikzcd
works inside and outside.But if you don't like it, no problem, it's just a proposal ;) In this case you can simply close this pull request.
Testing \ifx\path\tikz@command@path
might be another option.
Following the idea of this answer and to make the interaction with
tikz
more fluent in some cases like this one, I modified the code to usetikzpicture
orscope
depending from where we call thetikzcd
environment. I also added a stylename
to facilitate the access to the cells.Here is a demonstration how it works: