# How to set the content size of a TikZ node?

I am trying to implement a beamer template according to some previously given PowerPoint template. Now I am on the title page and I need your advice.

I have a set of coordinate calculations done. After that I know what area is reserved for the title, subtitle, and other texts. In the MWE I put a red rectangle there just make it visible for now.

As the title might well be lengthy and thus a linebreak might happen, I'd like to use LeTeX's space alignment techniques to get things aligned nicely. The idea here is to have a vbox (minipage in the MWE), that has correct sizes such that I can e.g. use \vfill to evenly space the remaining space in the range without manually tweaking too much with coordinates. Also this allows me to leave out e.g. the subtitle and still have a valid spacing.

So assuming, I have "some" coordinates (nw) and (se) I am looking for spanning a minipage in that rectangular range. The property minimum height of tikz is not much of use here as it modifies the shape of the node and not it's content. As far as I know the same holds for the fitting library of tikz.

The approach with the minipage seems to work well, but I need the horizontal and vertical distances of the coordinates as length values in classical LaTeX length registers. Using these I can define the minipage just as I did explicitly below with a hardcoded height.

Is there a simpler way to achieve what I am trying? How can I access the vertical distance of two coordinates and save in a register?

\documentclass{beamer}
\usepackage{tikz}

\setbeamertemplate{title page}{
\begin{tikzpicture}[overlay,remember picture,every node/.style={inner sep=0pt}]
\path (current page.south west) node [anchor=south west] {\rule{5cm}{4cm}}; % Logo
\path % Here comes some crazy coordinate math normally, in MEW just dummy coordinates
(current page.north east) ++(-7.5cm,-2cm) coordinate (nw) ++(6cm,-5cm) coordinate (se);

% Inside this rectangle the text should be placed
\draw [red] (nw) rectangle (se);

% Here comes a test implementation, how things could look like
\path (nw) node [anchor=north west,align=left] %
{\begin{minipage}[t][5cm]{\textwidth}
{\LARGE\bfseries The title}

\vfill

% {\Large\bfseries The subtitle}
%
% \vfill

{\Large The Author}

\vfill

{\large 01/01/2020}
\end{minipage}
};
\end{tikzpicture}
}

\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}

• In my personal beamer theme, I use the calc library to compute midpoints e.g. ($(a)!0.5!(b)$). Basically my title is positioned at a fiwed height on the page, then the other stuff (e.g. subtitle) are positioned based on north/south anchors of the title so that even if my title is long or spans multiple lines everything shifts accordingly. If everything is very long it stops working at some point though (no perfect solution for this) – BambOo May 25 at 11:00
• I ran your code, but I am unsure if I understand what you want correctly. You mean to extract the distance between two coordinates to use them as parameters for the minipage ? – BambOo May 25 at 11:23
• That was the idea. ALthough I found a solution yet after revisiting the pgf guide. – Christian Wolf May 25 at 12:21

Actually, you can take advantage of the calc library and of the let operation to do this in one shot, without explicitely defining additional TeX counters. See below.

\setbeamertemplate{title page}{
\begin{tikzpicture}[overlay,remember picture,every node/.style={inner sep=0pt}]
\path (current page.south west) node [anchor=south west] {\rule{5cm}{4cm}}; % Logo
\path % Here comes some crazy coordinate math normally, in MEW just dummy coordinates
(current page.north east) ++(-7.5cm,-2cm) coordinate (nw) ++(6cm,-5cm) coordinate (se);

% Inside this rectangle the text should be placed
\draw [red] (nw) rectangle (se);

% Here comes a test implementation, how things could look like
\path
let \p1 = ($(nw) - (se)$) in
(nw) node [anchor=north west,align=left] %
{\begin{minipage}[t][\y1]{\textwidth}
{\LARGE\bfseries The title}

\vfill

% {\Large\bfseries The subtitle}
%
% \vfill

{\Large The Author}

\vfill

{\large 01/01/2020}
\end{minipage}
};
\end{tikzpicture}
}


I was able to find a solution to the issue at least after I reread some parts of the pgfmanual.

After the coorinates have been defined I can extract them to macros using something like this (the typeout is just for debugging here):

\path (nw);
\pgfgetlastxy{\myfoox}{\myfooy}
\typeout{Last coordinate: \myfoox, \myfooy}
\path (se);
\pgfgetlastxy{\mybarx}{\mybary}
\typeout{Last coordinate: \mybarx, \mybary}


After the macros have been defined, I can now assign LaTeX registers with these values with

\newlength\myfoo
\newlength\mybar
\setlength\myfoo{\myfooy}
\setlength\mybar{\mybary}


Now I can subtract them from each other to get the (vertical in this case) distance between the two coordinates in myfoo

\multiply\mybar by -1
\typeout{After negation: \the\mybar}

\path (nw) node [anchor=north west,align=left] %