alignment • nodes • TikZ •
Add tags
Information and discussion about graphics, figures & tables in LaTeX documents.
by SAKDOSS on Sat Feb 23rd, 2013
Hello, It seems that I have a lot of questions these days. I am drawing two ellipses and two circles with tikZ: - Code: Select all • Open in writeLaTeX
\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 317 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 23rd, 2013, 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 21st, 2013
by SAKDOSS on Sat Feb 23rd, 2013
Again I found the solution (sorry for posting). I give the answer it may help someone: - Code: Select all • Open in writeLaTeX
\node (a) at (6,0.2){$b$}; \node (b) at (6,-0.2){$blablabla$}; \node[draw, circle, fit=(a) (b)] {};
-
SAKDOSS
-
- Posts: 14
- Joined: Thu Feb 21st, 2013
by localghost on Sat Feb 23rd, 2013
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
-

localghost
- Site Moderator
-
- Posts: 8730
- Joined: Fri Feb 2nd, 2007
- Location: Braunschweig, Germany
by SAKDOSS on Sat Feb 23rd, 2013
Indeed here is a compilable latex file: - Code: Select all • Open in writeLaTeX
\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}
-
SAKDOSS
-
- Posts: 14
- Joined: Thu Feb 21st, 2013
by Stefan_K on Sat Feb 23rd, 2013
Thanks for the solution! And in this way, I could click on "Open in writeLaTeX" and immediately test your example, very good.
Stefan
LaTeX Community Administrator
-

Stefan_K
- Site Admin
-
- Posts: 6140
- Joined: Mon Mar 10th, 2008
- Location: Hamburg, Germany
-
by SAKDOSS on Sun Feb 24th, 2013
I did not notice. Great feature.
-
SAKDOSS
-
- Posts: 14
- Joined: Thu Feb 21st, 2013
Topic Tags
alignment • nodes • TikZ
Return to Graphics, Figures & Tables
Users browsing this forum: No registered users and 13 guests
|