# Make tikz nodes flush with slide edges in beamer title slide

I'm making a title slide using the tikzpicture environment, and I'm left with some mystery margins on the top and on the left of the title slide. How can I fix this properly (i.e., not by simply futzing with hspace and vpace [unless by "informed futzing"])? I'm using the Copenhagen theme, which uses the split outer theme. The split outer theme defines a headline element with height 2.5ex, but I'm not sure how to use this information or how to determine the source of the left margin.

Here is the example:

File: main.tex

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{calc}

\usetheme{Copenhagen}

\setbeamercolor{background canvas}{bg=yellow}

\defbeamertemplate*{title page}{customtitlepage}{%
\begin{tikzpicture}
\fill[color=red, draw=none] (0,0.5\paperheight) rectangle(\paperwidth, \paperheight);

\node[text width=\paperwidth, align=center, draw=green]
at (0.5\paperwidth,1.0cm)
{\color{black}\footnotesize\insertdate};

\node[text width=\paperwidth, align=center, draw=green]
at (0.5\paperwidth,2.0cm)
{\color{black}\normalsize\insertinstitute};

\node[text width=\paperwidth, align=center, draw=green]
at (0.5\paperwidth,2.5cm)
{\color{black}\Large\insertauthor};

\node[anchor=north west, text width=0.5\paperwidth,align=right,draw=green]
at (0.5\paperwidth,0.5\paperheight)
{\color{black}\footnotesize\insertsubtitle};

\node[anchor=south, text width=\paperwidth,align=left,draw=green]
at (0.5\paperwidth,0.5\paperheight)
{\color{yellow}\Large{\bf\inserttitle}};
\end{tikzpicture}
}

\makeatletter
\def\maketitle{%
\ifbeamer@inframe
\thispagestyle{empty}\titlepage
\else
\frame{\thispagestyle{empty}\titlepage}
\fi
}
\makeatother

\author{Joe Shmoe}
\title{The Battle of Turtle Gut Inlet}
\subtitle{The first privateer battle of the American Revolutionary War}
\institute{Continental Navy}
\date{July 4th, 1776}

\begin{document}

\begin{frame}
\maketitle
\end{frame}

\section{Normal Section}
\subsection{Normal Subsection}

\begin{frame}{Normal Frame}
Normal things
\end{frame}

\end{document}


The output is below. The red rectangle, as well as the bounding boxes of all the text nodes (except the subtitle node), should be flush with the left edge of the slide, but they are not. Also, the red rectangle should be flush with the top edge of the slide, but it is not.

Title slide:

Normal slide (for context):

The easiest way to avoid beamer's built in margins is to use the [remember picture, overlay] option and locate everything relative to (current page). Don't forget to run it twice.

Note that each node includes [inner sep] (default 0.333em) of space around the text, so you either need to set it to zero or reduce [text width] by .666em.

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{calc}

\usetheme{Copenhagen}

\setbeamercolor{background canvas}{bg=yellow}

\defbeamertemplate*{title page}{customtitlepage}{%
\begin{tikzpicture}[remember picture,overlay]
\fill[color=red, draw=none] (current page.west) rectangle(current page.north east);

\node[text width={\paperwidth-.666em}, align=center, draw=green]
at ($(current page.south)+(0pt,1cm)$)
{\color{black}\footnotesize\insertdate};

\node[text width={\paperwidth-.666em}, align=center, draw=green]
at ($(current page.south)+(0pt,2cm)$)
{\color{black}\normalsize\insertinstitute};

\node[text width={\paperwidth-.666em}, align=center, draw=green]
at ($(current page.south)+(0pt,2.5cm)$)
{\color{black}\Large\insertauthor};

\node[anchor=north west, text width={0.5\paperwidth-.667em},align=right,draw=green]
at (current page.center)
{\color{black}\footnotesize\insertsubtitle};

\node[anchor=south, text width={\paperwidth-.666em},draw=green]
at (current page.center)
{\color{yellow}\Large{\bf\inserttitle}};
\end{tikzpicture}
}

\makeatletter
\def\maketitle{%
\ifbeamer@inframe
\thispagestyle{empty}\titlepage
\else
\frame{\thispagestyle{empty}\titlepage}
\fi
}
\makeatother

\author{Joe Shmoe}
\title{The Battle of Turtle Gut Inlet}
\subtitle{The first privateer battle of the American Revolutionary War}
\institute{Continental Navy}
\date{July 4th, 1776}

\begin{document}

\begin{frame}
\maketitle
\end{frame}

\section{Normal Section}
\subsection{Normal Subsection}

\begin{frame}{Normal Frame}
Normal things
\end{frame}

\end{document}

• Cool; this works for me. Just trying to understand more ... from looking at the pgf manual, the combination of remember picture and overlay makes it possible "to reference nodes in pictures other than the current one". Does this mean current page is a node in some other tikzpicture? – Chester Oct 10 '17 at 20:28
• Effectively. The package tikzpagenodes creates nodes for (current page text area), (current page header area), etc. – John Kormylo Oct 10 '17 at 20:56