[Tex/LaTex] Center a Node Vertically TikZ

nodespositioningtikz-pgf

I'm using TikZ to create the following drawing:

drawing

So far so good, but now I'd like to center the node with the gray background vertically. Here's its code:

\setlength{\arraycolsep}{2pt}
\draw[xshift=-3cm,yshift=(current bound box.center)]
  node[align=left,right,rounded corners,fill=black!10,inner sep=1ex]
  {$
    \left\{
      \begin{array}{llc}
        h &=& \overline{AF}\\
        l &=& \overline{BF}\\
        l'&=& \overline{AB}\\
        d &=& \overline{CE}
      \end{array}
    \right.
  $};

It's being pushed to the left by xshift, thus I could equally use yshift with a measure to center it. However, is it possible to do it dynamically (by retrieving the bounding box height)? That's, if the drawing grows, it will remain centered.

Best Answer

You could use the positioning library and then use the left=of <node identifier> for positioning the node containing the array; I added some more files to the array to see the effect:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\setlength{\arraycolsep}{2pt}
\node[draw,fill,circle,inner sep=1pt,label=right:$C$] at (3,0) (c) {};
\node[align=left,rounded corners,fill=black!10,inner sep=1ex,left=of c]
  {$
    \left\{
      \begin{array}{llc}
        h &=& \overline{AF}\\
        l &=& \overline{BF}\\
        l'&=& \overline{AB}\\
        d &=& \overline{CE}\\
        h &=& \overline{AF}\\
        l &=& \overline{BF}\\
        h &=& \overline{AF}\\
        l &=& \overline{BF}\\
      \end{array}
    \right.
  $};
\end{tikzpicture}

\end{document}

enter image description here

More generally (as Caramdir has suggested), you can use left=of current bounding box.center:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\setlength{\arraycolsep}{2pt}
\node[draw,fill,circle,inner sep=1pt,label=right:$C$] at (3,0) (c) {};
\node[align=left,rounded corners,fill=black!10,inner sep=1ex,left=of current bounding box.center]
  {$
    \left\{
      \begin{array}{llc}
        h &=& \overline{AF}\\
        l &=& \overline{BF}\\
        l'&=& \overline{AB}\\
        d &=& \overline{CE}\\
        h &=& \overline{AF}\\
        l &=& \overline{BF}\\
        h &=& \overline{AF}\\
        l &=& \overline{BF}\\
      \end{array}
    \right.
  $};
\end{tikzpicture}

\end{document}
Related Question