LaTeX forum ⇒ Graphics, Figures & TablesVertical 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

Postby SAKDOSS » Sat Feb 23, 2013 7:02 pm

Hello,

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

I am drawing two ellipses and two circles with tikZ:
  1. \begin{tikzpicture}
  2. \node[ellipse, draw] at (0,0) {
  3. \begin{tikzpicture}
  4. \node at (0,0.2){$blablabla$};
  5. \node at (0,-0.2){$b$};
  6. \end{tikzpicture}
  7. };
  8.  
  9. \node[ellipse, draw] at (3.5,0) {
  10. \begin{tikzpicture}
  11. \node at (0,0.2){$b$};
  12. \node at (0,-0.2){$blablabla$};
  13. \end{tikzpicture}
  14. };
  15.  
  16. \node[circle, draw] at (0,3.5) {
  17. \begin{tikzpicture}
  18. \node at (0,0.2){$blablabla$};
  19. \node at (0,-0.2){$b$};
  20. \end{tikzpicture}
  21. };
  22.  
  23. \node[circle, draw] at (3.5,3.5) {
  24. \begin{tikzpicture}
  25. \node at (0,0.2){$b$};
  26. \node at (0,-0.2){$blablabla$};
  27. \end{tikzpicture}
  28. };
  29. \end{tikzpicture}


The result is here:
tikZ-text-alignment.png
tikZ-text-alignment.png (19.34 KiB) Viewed 2836 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.

Link:
BBcode:
HTML:
Hide post links
Show post links

SAKDOSS
Posts: 14
Joined: Thu Feb 21, 2013 5:06 pm

Postby SAKDOSS » Sat Feb 23, 2013 7:38 pm

Again I found the solution (sorry for posting). I give the answer it may help someone:

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

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Sat Feb 23, 2013 8:08 pm

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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


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

Link:
BBcode:
HTML:
Hide post links
Show post links

SAKDOSS
Posts: 14
Joined: Thu Feb 21, 2013 5:06 pm

Postby SAKDOSS » Sat Feb 23, 2013 8:30 pm

Indeed here is a compilable latex file:
  1. \documentclass{article}
  2.  
  3. \usepackage[english]{babel}
  4. \usepackage{tikz}
  5. \usetikzlibrary{fit}
  6. \usetikzlibrary{shapes}
  7.  
  8. \begin{document}
  9.  
  10. \begin{tikzpicture}
  11. \node[ellipse, draw] at (0,0) {
  12. \begin{tikzpicture}
  13. \node at (0,0.2){$blablabla$};
  14. \node at (0,-0.2){$b$};
  15. \end{tikzpicture}
  16. };
  17.  
  18. \node[ellipse, draw] at (3.5,0) {
  19. \begin{tikzpicture}
  20. \node at (0,0.2){$b$};
  21. \node at (0,-0.2){$blablabla$};
  22. \end{tikzpicture}
  23. };
  24.  
  25. \node[circle, draw] at (0,3.5) {
  26. \begin{tikzpicture}
  27. \node at (0,0.2){$blablabla$};
  28. \node at (0,-0.2){$b$};
  29. \end{tikzpicture}
  30. };
  31.  
  32. \node[circle, draw] at (3.5,3.5) {
  33. \begin{tikzpicture}
  34. \node at (0,0.2){$b$};
  35. \node at (0,-0.2){$blablabla$};
  36. \end{tikzpicture}
  37. };
  38. \end{tikzpicture}
  39.  
  40. \begin{tikzpicture}
  41. \node (a) at (6,0.2){$b$}; \node (b) at (6,-0.2){$itworksperfectly!$};
  42. \node[draw, circle, fit=(a) (b)] {};
  43. \end{tikzpicture}
  44.  
  45. \end{document}

Link:
BBcode: Topic is solved[/url]" title="Click to select post's link in BBcode format" onclick="this.focus();this.select();" />
HTML: Topic is solved</a>" title="Click to select post's link in HTML format" onclick="this.focus();this.select();" />
Hide post links
Show post links

User avatar
Stefan Kottwitz
Site Admin
Posts: 7801
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sat Feb 23, 2013 9:37 pm

Thanks for the solution! And in this way, I could click on "Open in writeLaTeX" and immediately test your example, very good.

Stefan
Site admin

Link:
BBcode:
HTML:
Hide post links
Show post links

SAKDOSS
Posts: 14
Joined: Thu Feb 21, 2013 5:06 pm

Postby SAKDOSS » Sun Feb 24, 2013 3:49 pm

I did not notice. Great feature.

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 5 guests