Usman Sajid
Usman Sajid

Reputation: 319

Introduce line break in the text inside rectangle in latex tikz

I have a rectangular box in latex. I want to introduce line breaks in the text that appears in the rectangular shape. Can anybody guide me in this regard. I have tried the following statement but it does not work.

\draw[solid]  (7,-4) rectangle (11,-3) node[ pos=.5] {abc \\ def };

Upvotes: 2

Views: 3758

Answers (1)

If your node has a specified width, you can use line breaks

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw  (7,-4) rectangle (11,-3) node[ pos=.5,text width=4cm,align=center] {abc \linebreak def };
\end{tikzpicture}

\end{document}

Upvotes: 1

Related Questions