1

I am only trying with a very naive example:

\documentclass[tikz]{standalone}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of nodes] {a};
\end{tikzpicture}
\end{document}

Then when I compile, it gives off a long list of errors, starting with a few couples of these:

! Missing } inserted.
<inserted text> 
                }
l.7 \end{tikzpicture}
                     
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

Then the following error repeat for many times

! Missing \cr inserted.
<inserted text> 
                \cr 
l.7 \end{tikzpicture}
                     
I'm guessing that you meant to end an alignment here.

! Misplaced \cr.
<inserted text> \cr 
                    
l.7 \end{tikzpicture}
                     
I can't figure out why you would want to use a tab mark
or \cr or \span just now. If something like a right brace
up above has ended a previous alignment prematurely,
you're probably due for more error messages, and you
might try typing `S' now just to see what is salvageable.

This ONLY happens when I use the \matrix command. Tikz compiles without any problem on any other commands. Does anyone know why this is happening? Thank you.

1 Answer 1

1

Each row of the matrix needs to be terminated with \\ - even if you only have a single row.

\documentclass[tikz]{standalone}
\usetikzlibrary{matrix}

\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of nodes] {a\\};
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .