I want to create a beamer presentation, where I intend to use one single TikZ graphics for 3 consecutive frames but with different node labels. I have a separate TikZ file where I use self defined commands for the label text that are redefined in the main TeX file for each frame respectively.
Problem 1: Since the labels differ in their size the placement of the graphic within the frame changes. Is there an easy way to apply TikZ coordinates relative to the frame or some other way to position the graphic equally for each frame?
Problem 2: When I redefine some label texts, partially additional margins occur. Can someone explain to me why this happens and how I can prevent this?( --> see minimal example, label at root node). I started to introduce for each label text individual label distance values for fine tuning but I really don't like this deficient work around. Has someone a more elegant solution?
Please note, that \lblAA, \lblBA, etc. are used to define the label texts and \sepAA, \sepBA, etc. were originally intend to fine tune spacing (which is set to 0cm in this example).
I appreciate any help or suggestions.
Thx in advance!
% MAIN TEX FILE
\documentclass[compress,nonav,10pt]{beamer}
\usetheme{Warsaw}
\makeatletter
\DeclareMathSizes{\@xpt}{\@xpt}{3}{2}
\makeatother
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc,shapes}
\begin{document}
\newcommand{\lblAA}{$\vec{\phi}_{1,1}$}
\newcommand{\sepAA}{0cm}
\newcommand{\lblBA}{$\vec{\phi}_{2,1}$}
\newcommand{\sepBA}{0cm}
\newcommand{\lblBB}{$\vec{\phi}_{2,2}$}
\newcommand{\sepBB}{0cm}
\newcommand{\lblCA}{$\vec{\phi}_{\log_2\mkern-5mu N,1}$}
\newcommand{\sepCA}{0cm}
\newcommand{\lblCD}{$\vec{\phi}_{\log_2\mkern-5mu N,N\! /\! 2}$}
\newcommand{\sepCD}{0cm}
\newcommand{\lblDA}{$\vec{\psi}_1$}
\newcommand{\sepDA}{0cm}
\newcommand{\lblDB}{$\vec{\psi}_2$}
\newcommand{\sepDB}{0cm}
\newcommand{\lblDG}{$\vec{\psi}_{N-1}$}
\newcommand{\sepDG}{0cm}
\newcommand{\lblDH}{$\vec{\psi}_{N}$}
\newcommand{\sepDH}{0cm}
\begin{frame}{Tree}
\begin{figure}
\centering
\input{tree.tikz}
\end{figure}
\end{frame}
\renewcommand{\lblAA}{$\left \vert \left \langle \vec{\phi}_{1,1}, \vec{x} \right \rangle \right \vert > \tau_1$ ?}
\renewcommand{\sepAA}{0cm}
\renewcommand{\lblBA}{$\left \vert \left \langle \vec{\phi}_{2,1}, \vec{x} \right \rangle \right \vert > \tau_2$ ?}
\renewcommand{\sepBA}{0cm}
\renewcommand{\lblBB}{$\tau_2 < \left \vert \left \langle \vec{\phi}_{2,2}, \vec{x} \right \rangle \right \vert$ ?}
\renewcommand{\sepBB}{0cm}
\renewcommand{\lblCA}{$\left \vert \left \langle \vec{\phi}_{\log_2\mkern-5mu N,1}, \vec{x}\right \rangle \right \vert > \tau_{\log_2\mkern-5mu N}$ ?}
\renewcommand{\sepCA}{0cm}
\renewcommand{\lblCD}{$\tau_{\log_2\mkern-5mu N} < \left \vert \left \langle \vec{\phi}_{\log_2\mkern-5mu N,N\! /\! 2}, \vec{x} \right \rangle \right \vert$ ?}
\renewcommand{\sepCD}{0cm}
\renewcommand{\lblDA}{$\left \langle \vec{\psi}_1, \vec{x} \right \rangle$}
\renewcommand{\sepDA}{0cm}
\renewcommand{\lblDB}{$\left \langle \vec{\psi}_2, \vec{x} \right \rangle$}
\renewcommand{\sepDB}{0cm}
\renewcommand{\lblDG}{$\left \langle \vec{\psi}_{N-1}, \vec{x} \right \rangle$}
\renewcommand{\sepDG}{0cm}
\renewcommand{\lblDH}{$\left \langle \vec{\psi}_{N}, \vec{x} \right \rangle$}
\renewcommand{\sepDH}{0cm}
\begin{frame}{Tree}
\begin{figure}
\centering
\input{tree.tikz}
\end{figure}
\end{frame}
\end{document}
% THE TIKZ FILE ("tree.tikz")
\newcommand{\dx}{1.8}
\newcommand{\dy}{3}
\begin{tikzpicture}[scale=.5, every node/.style={fill=black,circle,inner sep=0pt,circle,minimum size=.2cm}]
\normalsize
\coordinate (N11) at (0,0);
\node[label={[label distance=\sepAA]above:{\lblAA}}] at (N11) {};
\coordinate (N21) at ($ (N11) + (-\dx, -\dy) $);
\node[label={[label distance=\sepBA]west:{\lblBA}}] at (N21) {};
\draw[-, thick] (N21) -- (N11);
\coordinate (N22) at ($ (N11) + (\dx, -\dy) $);
\node[ label={[label distance=\sepBB]east:{\lblBB}}] at (N22) {};
\draw[-, thick] (N22) -- (N11);
\coordinate (N31) at ($ (N21) + (-\dx, -\dy) $);
\node[label={[label distance=\sepCA]west:{\lblCA}}] at (N31) {};
\draw[dash pattern=on 1pt off 2pt, thick] (N21) -- ($ (N21) + .33*(-\dx, -\dy) $);
\draw[dash pattern=on 1pt off 2pt, thick] ($ (N21) + .66*(-\dx, -\dy) $) -- (N31);
\draw[dash pattern=on 1pt off 2pt, thick] (N21) -- ($ (N21) + .33*(\dx, -\dy) $);
\coordinate (N34) at ($ (N22) + (\dx, -\dy) $);
\node[ label={[label distance=\sepCD]east:{\lblCD}}] at (N34) {};
\draw[dash pattern=on 1pt off 2pt, thick] (N22) -- ($ (N22) + .33*(-\dx, -\dy) $);
\draw[dash pattern=on 1pt off 2pt, thick] ($ (N22) + .66*(\dx, -\dy) $) -- (N34);
\draw[dash pattern=on 1pt off 2pt, thick] (N22) -- ($ (N22) + .33*(\dx, -\dy) $);
%\draw[-, thick] (N22) -- (N34);
\coordinate (N41) at ($ (N31) + (-\dx, -\dy) $);
\node[ label={[label distance=\sepDA]below:{\lblDA}}] at (N41) {};
\draw[-, thick] (N31) -- (N41);
\coordinate (N42) at ($ (N31) + (\dx, -\dy) $);
\node[ label={[label distance=\sepDB]below:{\lblDB}}] at (N42) {};
\draw[-, thick] (N31) -- (N42);
\coordinate (N47) at ($ (N34) + (-\dx, -\dy) $);
\node[ label={[label distance=\sepDG]below:{\lblDG}}] at (N47) {};
\draw[-, thick] (N34) -- (N47);
\coordinate (N48) at ($ (N34) + (\dx, -\dy) $);
\node[ label={[label distance=\sepDH]below:{\lblDH}}] at (N48) {};
\draw[-, thick] (N34) -- (N48);
\draw[dash pattern=on 1pt off 2pt, thick] ($ (N42) + .6*(\dx, 0)$) -- ($ (N47) + .6*(-\dx, 0) $);
\draw[dash pattern=on 1pt off 2pt, thick] ($ (N31) + .9*(\dx, 0)$) -- ($ (N34) + .9*(-\dx, 0) $);
\end{tikzpicture}
every node/.style
withcircle
and labels are really nodes, so if you increase the label text, the node increases its radius, pushing the tree down.