Goebel, Juergen | 1 Jul 09:40
Favicon

center the content (text!) of a box

Hi,

I'd like to center (horizontally and vertically) the content of the box
in the following example with respect to the parentheses.  This means
that the exponent should be ignored.  I tried to achieve this with some
\vphantom-commands (as I usually do outside of pgf/tikz) but irritatingly
with no effect.  What do I have to do?

\documentclass[12pt]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
 \draw (-0.5,-0.5) rectangle (0.5,0.5);
 \path (0,0) node {$\vphantom{_2}\left(\cdot\right)^2\vphantom{_2}$};
\end{tikzpicture}
\end{document}

Regards,

Juergen

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
Mark Wibrow | 1 Jul 10:14

Re: center the content (text!) of a box

Hi,

This is the best I can get:

\begin{tikzpicture}
 \draw (-0.5,-0.5) rectangle (0.5,0.5);
 \path (0,0) node (c) [text depth=\heightof{$\cdot$}]
 {\phantom{$\mathstrut^2$}$\left(\cdot\right)^2$};
 \draw [red](c.center)  circle (1pt);
\end{tikzpicture}

There may be better solutions, I'm not much of LaTeX user.

Regards

Mark

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Goebel, Juergen | 1 Jul 10:24
Favicon

Re: center the content (text!) of a box

> Mark Wibrow [mailto:m.wibrow <at> googlemail.com] wrote:

> This is the best I can get:
> 
> \begin{tikzpicture}
>  \draw (-0.5,-0.5) rectangle (0.5,0.5);
>  \path (0,0) node (c) [text depth=\heightof{$\cdot$}]
>  {\phantom{$\mathstrut^2$}$\left(\cdot\right)^2$};
>  \draw [red](c.center)  circle (1pt);
> \end{tikzpicture}
> 
> There may be better solutions, I'm not much of LaTeX user.

Hi Mark,

Thanks a lot, the result is much better than before and
should be sufficient.  Just one comment: The option
text depth=\heightof{$\cdot$}  gives an error.
	Missing number, treated as zero.

Best,

Juergen

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Mark Wibrow | 1 Jul 10:35

Re: center the content (text!) of a box

2008/7/1 Goebel, Juergen <juergen.goebel <at> eads.com>
> Just one comment: The option
> text depth=\heightof{$\cdot$}  gives an error.
>        Missing number, treated as zero.
>

It works with the current CVS version (compatability with calc for
\heightof was added after 2.0).  You could always try

\newbox\cdotbox
\setbox\cdotbox=\hbox{$\cdot$}
\begin{tikzpicture}
 \draw (-0.5,-0.5) rectangle (0.5,0.5);
 \path (0,0) node (c) [text depth=\ht\cdotbox]
 {\phantom{$\mathstrut^2$}$\left(\cdot\right)^2$};
 \draw [red](c.center) circle (1pt); % is it centered?
\end{tikzpicture}

Which should to the same thing.

Mark

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Picon

Fwd: center the content (text!) of a box

Maybe you can draw the box around the picture:

\begin{tikzpicture}[remember picture,overlay]
  \node (text) at (0, 0) {$\left(\tikz[remember picture] \node[inner sep=0] 
(c) {$\cdot$};\right)^2$};
  \draw (c.center) ++(-0.5, -0.5) rectangle ++(1, 1);
  \draw [red](c.center)  circle (1pt);
\end{tikzpicture}
Favicon
From: Goebel, Juergen <juergen.goebel <at> eads.com>
Subject: [Pgf-users] center the content (text!) of a box
Date: 2008-07-01 07:40:25 GMT

Hi,

I'd like to center (horizontally and vertically) the content of the box
in the following example with respect to the parentheses.  This means
that the exponent should be ignored.  I tried to achieve this with some
\vphantom-commands (as I usually do outside of pgf/tikz) but irritatingly
with no effect.  What do I have to do?

\documentclass[12pt]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
 \draw (-0.5,-0.5) rectangle (0.5,0.5);
 \path (0,0) node {$\vphantom{_2}\left(\cdot\right)^2\vphantom{_2}$};
\end{tikzpicture}
\end{document}

Regards,

Juergen

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
pgf-users mailing list
pgf-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pgf-users
Picon

Re: Fwd: center the content (text!) of a box

Am Dienstag, 1. Juli 2008 schrieb Christoph Bartoschek:
> Maybe you can draw the box around the picture:
>
> \begin{tikzpicture}[remember picture,overlay]
>   \node (text) at (0, 0) {$\left(\tikz[remember picture] \node[inner sep=0]
> (c) {$\cdot$};\right)^2$};
>   \draw (c.center) ++(-0.5, -0.5) rectangle ++(1, 1);
>   \draw [red](c.center)  circle (1pt);
> \end{tikzpicture}

\begin{tikzpicture}[remember picture,overlay]
  \node (text) at (0, 0) {$\tikz[remember picture] \node[inner sep=0] (c) 
{$\left(\cdot\right)$};^2$};
  \draw (c.center) ++(-0.5, -0.5) rectangle ++(1, 1);
  \draw [red](c.center)  circle (1pt);
\end{tikzpicture}

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Till Tantau | 1 Jul 12:05
Picon
Favicon

Re: center the content (text!) of a box

Hi!

try

  \node[text height=0.8em,text depth=0.2em] {$\left(\cdot 
\right)^{2^{2^2}}$};

The problem with your \vphantom is that it is simply "not deep enough"  
because a subscript is not as "low" as the superscript is "high".  
Also, the placement of the subscript is different because no  
paranthesis preceeds it.

Best regards,
Till

Am 01.07.2008 um 09:40 schrieb Goebel, Juergen:
> Hi,
>
> I'd like to center (horizontally and vertically) the content of the  
> box
> in the following example with respect to the parentheses.  This means
> that the exponent should be ignored.  I tried to achieve this with  
> some
> \vphantom-commands (as I usually do outside of pgf/tikz) but  
> irritatingly
> with no effect.  What do I have to do?
>
> \documentclass[12pt]{scrartcl}
> \usepackage{tikz}
> \begin{document}
> \begin{tikzpicture}
>  \draw (-0.5,-0.5) rectangle (0.5,0.5);
>  \path (0,0) node {$\vphantom{_2}\left(\cdot\right)^2\vphantom{_2}$};
> \end{tikzpicture}
> \end{document}
>
> Regards,
>
> Juergen
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php_______________________________________________
> pgf-users mailing list
> pgf-users <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pgf-users

--
Prof. Dr. Till Tantau <tantau <at> tcs.uni-luebeck.de>
http://www.tcs.uni-luebeck.de

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Goebel, Juergen | 1 Jul 12:23
Favicon

Re: center the content (text!) of a box

> Till Tantau wrote:

> The problem with your \vphantom is that it is simply "not 
> deep enough"  
> because a subscript is not as "low" as the superscript is "high".  
> Also, the placement of the subscript is different because no  
> paranthesis preceeds it.

Oh, I see. That explains why my seemingly naive attempt 
wasn't successfull.

Thanks,

Juergen

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Goebel, Juergen | 1 Jul 12:28
Favicon

Re: center the content (text!) of a box

> Mark Wibrow wrote:

> It works with the current CVS version (compatability with calc for
> \heightof was added after 2.0).  

Thanks for the hint.

> \newbox\cdotbox
> \setbox\cdotbox=\hbox{$\cdot$}
> \begin{tikzpicture}
>  \draw (-0.5,-0.5) rectangle (0.5,0.5);
>  \path (0,0) node (c) [text depth=\ht\cdotbox]
>  {\phantom{$\mathstrut^2$}$\left(\cdot\right)^2$};
>  \draw [red](c.center) circle (1pt); % is it centered?
> \end{tikzpicture}
> 
> Which should to the same thing.

This works really fine and so I'm going to integrate it into my
library. Thank you!

Regards,

Juergen

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Goebel, Juergen | 1 Jul 12:29
Favicon

Re: Fwd: center the content (text!) of a box

> Christoph Bartoschek wrote:

> Maybe you can draw the box around the picture:
> 
> \begin{tikzpicture}[remember picture,overlay]
>   \node (text) at (0, 0) {$\left(\tikz[remember picture] 
> \node[inner sep=0] 
> (c) {$\cdot$};\right)^2$};
>   \draw (c.center) ++(-0.5, -0.5) rectangle ++(1, 1);
>   \draw [red](c.center)  circle (1pt);
> \end{tikzpicture}

Interesting, but I will prefer Marks approach.
Thanks for your suggestion.

Best,

Juergen 

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

Gmane