# How to insert a linebreak in a TikZ matrix node?

How can I get a linebreak inside a matrix node? The following gives the error:

Package tikz Error: Giving up on this path. Did you forget a semicolon?.

unless I remove the linebreak.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [
matrix of nodes
] {
{some text} &
{this node \\ does not work} \\
{other text} &
{more text} \\
};
\end{tikzpicture}
\end{document}

-

Just like in any node, you need to specify the alignment in order to break the line.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [
matrix of nodes,
nodes={align=left, text width=3cm} % New!
] {
{some text} &
{text with \\ linebreak} \\
{other text} &
{more text} \\
};
\end{tikzpicture}
\end{document}

-
I still get ! Package tikz Error: Giving up on this path. Did you forget a semicolon?. when compiling your example, without any modification. What version of tikz or other is required for this to work? –  Georges Dupéron Sep 16 '13 at 11:55
Hmf. It doesn't work here either. I'm pretty sure I tested it back then, and I think the OP wouldn't have accepted it if it didn't work, but I also don't think I updated any tikz package since then. So no idea what's happening. Anyway, I'm adding a fix to the answer. Thanks for the notification! –  T. Verron Sep 16 '13 at 14:38