1

I am trying to wrap a tikzpicture node inside a box, so that I can refer to this "bounding box" from inside the picture for positioning the nodes relative to that box. I am looking for a command similar to the following one (in this example only "My Node B" is placed on top of the current page):

\documentclass{beamer}
\usepackage[T1]{fontenc}    
\usepackage{tikz}

\begin{document}

\begin{frame}
    \frametitle{Test Frame}
    \makebox[\textwidth]{  % %%% any alternative?
    \begin{tikzpicture}[overlay, remember picture]
        \draw (current bounding box.north) node (__node_ref)
            [anchor=north,fill=gray]
        {My node A};
    \end{tikzpicture}
    }

    \begin{tikzpicture}[overlay, remember picture]
        \draw (current page.north) node (__node_ref)
            [anchor=north,fill=gray]
        {My node B};
    \end{tikzpicture}

\end{frame}

\end{document}

This way, I can resize the external box and keep the relative position of the nodes of the tikzpicture intact. I tried using \makebox, \framebox and \pfgbox (the latter from inside the {tikzpicture}), but none of them worked.

I know that normally "current bounding box" might work, but I am doing this within Beamer+XeLaTeX and I can only access to the node "current page", so that I have to use "shift" for centering the nodes again.

Any ideas?

closed as off-topic by user36296, Kurt, Jesse, TeXnician, CarLaTeX Nov 9 '17 at 5:25

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • The current bounding box doesn't work because you've added the overlay option to the first node, which produces a bounding box of "zero dimension". Does your first tikzpicture have to be absolutely positioned? – Herr K. Jan 9 '14 at 0:32
  • I would like to add it inside a "box" (like in the example) and let beamer choose the position for the box in accordance with the current slide layout. I would like to specify the width and height of the box, but as I said before, I would also like beamer to position the box automatically. – Ricardo Jan 9 '14 at 0:43
  • 2
    @Ricardo: Then you can remove the overlay option and just use the current bounding box of the node in the first picture. – Herr K. Jan 9 '14 at 1:26
  • @Ricardo Solved the comment of Herr K the question? If yes you or HerrK could write an answer, which could be accepted. – Bobyandbob Nov 5 '17 at 14:20
  • 4
    I'm voting to close this question as solved in comments – user36296 Nov 9 '17 at 1:46