# How to center and wrap text inside node?

Consider two circles with long text nodes inside:

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0) circle (1.5cm) node[text width=3cm] {This is a relatively long text};
\draw (5,0) circle (1.5cm) node[text width=3cm] {This is another very long text};
\end{tikzpicture}

\end{document}


I want to have the text centered and wrapped in each circle. I've tried two solutions so far:

1. Using label=center:<my_text> inside node, as suggested here. This centers the text, but does not wrap it. So the text goes outside the circle.

2. Using pos=0.5 or midway inside node, as suggested here. This works fine for one circle, but not for two. The text is placed on top of each other in the first circle.

How can I achieve what I want?

• Just add align=center to the node options. – Alan Munn Nov 13 at 17:37

Alignment inside nodes is determined by the align key. In this case you want align=center:

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0) circle (1.5cm) node[text width=3cm,align=center] {This is a relatively long text};
\draw (5,0) circle (1.5cm) node[text width=3cm,align=center] {This is another very long text};
\end{tikzpicture}

\end{document}


One approach is to make the node circle shapes, add align=center to the text, and given them a minimum size.

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw (0,0)% circle (1.5cm)
node[align=center,minimum size=3cm,draw,circle]
{This is\\ a relatively\\ long text};
\draw (5,0)% circle (1.5cm)
node[align=center,minimum size=3cm,draw,circle]
{This is\\ another very\\ long text};
\end{tikzpicture}

\end{document}


You need to add the line breaks yourself, or use something like parshape to automatically follow the outline of a circle.