Featured Book

LaTeX Beginners Guide

Who is online

In total there are 13 users online :: 0 registered, 0 hidden and 13 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 13 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Vertical Text Alignment in circled Nodes Topic is solved

alignmentnodesTikZAdd tags Information and discussion about graphics, figures & tables in LaTeX documents.

Vertical Text Alignment in circled Nodes

Postby 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
tikZ-text-alignment.png (19.34 KiB) Viewed 1116 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

Re: Vertical Text Alignment in circled Nodes

Postby 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

Re: Vertical Text Alignment in circled Nodes

Postby 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
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
User avatar
localghost
Site Moderator
 
Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

Re: Vertical Text Alignment in circled Nodes  Topic is solved

Postby 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

Re: Vertical Text Alignment in circled Nodes

Postby 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
User avatar
Stefan_K
Site Admin
 
Posts: 6269
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Vertical Text Alignment in circled Nodes

Postby SAKDOSS on Sun Feb 24th, 2013

I did not notice. Great feature.
SAKDOSS
 
Posts: 14
Joined: Thu Feb 21st, 2013


Topic Tags

alignmentnodesTikZ

Return to Graphics, Figures & Tables

Who is online

Users browsing this forum: No registered users and 13 guests