## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Vertical Text Alignment in circled Nodes Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
SAKDOSS
Posts: 14
Joined: Thu Feb 21, 2013 5:06 pm

### Vertical Text Alignment in circled Nodes

Hello,

It seems that I have a lot of questions these days.

I am drawing two ellipses and two circles with tikZ:
\begin{tikzpicture}   \node[ellipse, draw] at (0,0) {     \begin{tikzpicture}       \node at (0,0.2){$blablabla$};       \node at (0,-0.2){$b$};     \end{tikzpicture}   };    \node[ellipse, draw] at (3.5,0) {     \begin{tikzpicture}       \node at (0,0.2){$b$};       \node at (0,-0.2){$blablabla$};     \end{tikzpicture}   };    \node[circle, draw] at (0,3.5) {     \begin{tikzpicture}       \node at (0,0.2){$blablabla$};       \node at (0,-0.2){$b$};     \end{tikzpicture}   };    \node[circle, draw] at (3.5,3.5) {     \begin{tikzpicture}       \node at (0,0.2){$b$};       \node at (0,-0.2){$blablabla$};     \end{tikzpicture}   };\end{tikzpicture}

The result is here:
tikZ-text-alignment.png (19.34 KiB) Viewed 2895 times

As you can see the texts in the two ellipses are centered vertically whereas they are not in the circles. This is due to the fact that "blablabla" is longer than "b" but I don't understand why it's working for the ellipses only.

Is it possible to center vertically the texts in the circles without changing the coordinates of the nodes ?
Last edited by localghost on Sat Feb 23, 2013 7:25 pm, edited 1 time in total.
Reason: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.

SAKDOSS
Posts: 14
Joined: Thu Feb 21, 2013 5:06 pm
Again I found the solution (sorry for posting). I give the answer it may help someone:

\node (a) at (6,0.2){$b$};\node (b) at (6,-0.2){$blablabla$};\node[draw, circle, fit=(a) (b)] {};

localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany
Thanks for sharing. However, your solution in form of a self-contained and minimal document would be preferable since it would be compilable out of the box for everybody else.

Thorsten
LaTeX Community Moderator

¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

SAKDOSS
Posts: 14
Joined: Thu Feb 21, 2013 5:06 pm
Indeed here is a compilable latex file:
\documentclass{article} \usepackage[english]{babel}\usepackage{tikz}\usetikzlibrary{fit}\usetikzlibrary{shapes} \begin{document} \begin{tikzpicture}   \node[ellipse, draw] at (0,0) {     \begin{tikzpicture}       \node at (0,0.2){$blablabla$};       \node at (0,-0.2){$b$};     \end{tikzpicture}   };    \node[ellipse, draw] at (3.5,0) {     \begin{tikzpicture}       \node at (0,0.2){$b$};       \node at (0,-0.2){$blablabla$};     \end{tikzpicture}   };    \node[circle, draw] at (0,3.5) {     \begin{tikzpicture}       \node at (0,0.2){$blablabla$};       \node at (0,-0.2){$b$};     \end{tikzpicture}   };    \node[circle, draw] at (3.5,3.5) {     \begin{tikzpicture}       \node at (0,0.2){$b$};       \node at (0,-0.2){$blablabla$};     \end{tikzpicture}   };\end{tikzpicture} \begin{tikzpicture}   \node (a) at (6,0.2){$b$}; \node (b) at (6,-0.2){$itworksperfectly!$};   \node[draw, circle, fit=(a) (b)] {};\end{tikzpicture} \end{document}

Stefan Kottwitz
Posts: 7875
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Thanks for the solution! And in this way, I could click on "Open in writeLaTeX" and immediately test your example, very good.

Stefan