yishn / tikzcd-editor

A simple visual editor for creating commutative diagrams.
https://tikzcd.yichuanshen.de/
MIT License
1.86k stars 101 forks source link

Diagrams with empty nodes produces invalid tikzcd code #20

Closed maxsnew closed 6 years ago

maxsnew commented 6 years ago

I'm getting some invalid tikzcd code when I have diagrams with "empty" nodes.

For instance an arrow by itself produces the code

\begin{tikzcd}
 \arrow[r] & 
\end{tikzcd}

and I get an error like this:

! Package pgf Error: No shape named tikz@f@5-1-2 is known.
...
l.441 I think the culprit is a tikzcd arrow in cell 1-1.
\errmessage ...currentrow -\tikzcd@currentcolumn }

l.442 \end{tikzcd}

To fix this you can put in a dummy there like {}:

\begin{tikzcd}
{} \arrow[r] & {}
\end{tikzcd}

Here's a bigger example that I was making where I put two diagrams side-by-side. Here, the empty nodes aren't the source or target for anything, but they are still in the diagram. I haven't looked at your representation, but I think the solution here would be to make sure that no nodes in the generated code are empty, where any cell within the bounding box of the whole diagram is going to be considered a node.

yishn commented 6 years ago

tikzcd-editor already includes {} for empty cells. Try empty your cache and reload the app; it should work correctly. The generated code of your 'bigger example' compiles without complaint.