Is it possible to create a multiline node in a Tikz matrix? If yes, how?
Thanks in advance.
Graphics, Figures & Tables ⇒ Tikz multiline matrix
-
- Posts: 5
- Joined: Sat Sep 26, 2009 6:11 am
Tikz multiline matrix
Last edited by reisgabrieljoao on Thu Oct 28, 2010 11:32 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Tikz multiline matrix
Very simple after specifying a text width for the node.
However, the line wrapping might be insufficient.
For more specific help it requires a minimal example.
Thorsten
Code: Select all
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node[text width=4cm] {The quick brown fox jumps over the lazy dog.};
\end{tikzpicture}
\end{document}
For more specific help it requires a minimal example.
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 5
- Joined: Sat Sep 26, 2009 6:11 am
Tikz multiline matrix
Well, I'll try to explain myself a little better. What I meant was that I wanted a node to occupy 2 lines, not its text. Here's a minimal example:
I want that node 2 occupies 2 lines (the first and the second) so that node 1 and 3 get aligned with it.
Code: Select all
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\matrix {
& \node (node1) [draw] {Node number 1}; \\
\node (node2) [draw, minimum height=3em] {Node number 2}; & \node (node3) [draw] {Node number 3}; \\
};
\end{tikzpicture}
\end{document}
Tikz multiline matrix
You could use the fit library:
Code: Select all
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}
\matrix {
\node (node0) {\phantom{Node number 2}}; & \node[draw] (node1) {Node number 1};\\
\node (node2) {\phantom{Node number 2}}; & \node [draw] (node3) {Node number 3};\\
};
\node[draw, fit = (node0) (node2),inner sep=0pt] {Node number 2};
\end{tikzpicture}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
-
- Posts: 5
- Joined: Sat Sep 26, 2009 6:11 am
Re: Tikz multiline matrix
Seems that it solved my problem, thank you very much.