It seems I am missing something while defining my title page in `beamer`. This was my first attempt (of course more sophisticated visually):
\documentclass[aspectratio=169]{beamer}
\usepackage{tikz}
\mode<presentation>
\defbeamertemplate*{title page}{mydefault}{%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth,\the\paperheight);
\fill[fill=red] (0,0) rectangle (\the\paperwidth,\the\paperheight);
\node[anchor=north west,inner sep=0pt,outer sep=0pt] at (0,\the\paperheight) {This text should be in the upper left corner};
\end{tikzpicture}
}
\mode<all>
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}
[![enter image description here][1]][1]
The issue was, that my red box with the text is not aligned to the upper left corner. If I put the same code into `\defbeamertemplate*{background}{mydefault}` the positioning is absolute to the upper left corner, but I need to have different backgrounds available for the user to select before he outputs a `\titlepage`. And just for reference, I want to avoid using `[remember picture,overlay]` and `current page`-nodes to avoid multiple compilations.
----------
I then realized, that maybe there is an alternate approach to reach my goal, which is to have 5 different backgrounds, 2 for titles, 1 for section title, one for regular pages and one for the presentation end page.
I read https://tex.stackexchange.com/questions/31316/different-backgrounds-for-title-and-normal-frames-in-beamer before, but it has the exact same issue with a non-absolute position. Then I came across https://tex.stackexchange.com/questions/459174/setbackgroundtemplate-on-title-page-within-custom-theme-file and https://tex.stackexchange.com/questions/317938/theme-with-a-different-footline-for-the-titlepage/323638#323638 so I continued to implement:
\documentclass[aspectratio=169]{beamer}
\usepackage{tikz}
\makeatletter
\def\ps@navigation@titlepage{%
\setbeamertemplate{background}[color][green]
\@nameuse{ps@navigation}}
\addtobeamertemplate{title page}{\thispagestyle{navigation@titlepage}}{}
\makeatother
\mode<presentation>
\defbeamertemplate*{background}{color}[1][red]{%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth,\the\paperheight);
\fill[fill=#1] (0,0) rectangle (\the\paperwidth,\the\paperheight);
\node[anchor=north west,inner sep=0pt,outer sep=0pt] at (0,\the\paperheight) {This text should be in the upper left corner};
\end{tikzpicture}
}
\mode<all>
\setbeamertemplate{background}[color][red]
\begin{document}
\title{This shall be a green title}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
This shall be a regular red content page
\end{frame}
\title{This shall be a blue title}
\begin{frame}
\setbeamertemplate{background}[color][blue]
\titlepage
\end{frame}
\begin{frame}
This shall be a regular red content page
\end{frame}
\end{document}
My problem is now that I don't get how to set another background for another title page, as my understanding is I can only pass one pagestyle to the title page with this way, any ideas? And would it be possible to do something like `\begin{frame}[red/blue/green]\titlepage\end{frame}` to pass the information into my template?
[1]: https://i.stack.imgur.com/so2jm.png
Top Answer
samcarter
One can define a couple of custom frame options to enable something like `\begin{frame}[red/blue/green]\titlepage\end{frame}`:
```
\documentclass[aspectratio=169]{beamer}
\usepackage{tikz}
\makeatletter
\defbeamertemplate{background canvas}{color}[1][red]{%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth,\the\paperheight);
\fill[fill=#1] (0,0) rectangle (\the\paperwidth,\the\paperheight);
\node[anchor=north west,inner sep=0pt,outer sep=0pt] at (0,\the\paperheight) {This text should be in the upper left corner};
\end{tikzpicture}
}
\BeforeBeginEnvironment{frame}{%
\setbeamertemplate{background canvas}[color][red]%
}
\makeatletter
\define@key{beamerframe}{green}[true]{%
\setbeamertemplate{background canvas}[color][green]%
}
\define@key{beamerframe}{blue}[true]{%
\setbeamertemplate{background canvas}[color][blue]%
}
\makeatother
\begin{document}
\title{This shall be a green title}
\begin{frame}[green]
\titlepage
\end{frame}
\begin{frame}
This shall be a regular red content page
\end{frame}
\title{This shall be a blue title}
\begin{frame}[blue]
\titlepage
\end{frame}
\begin{frame}
This shall be a regular red content page
\end{frame}
\end{document}
```
Or for arbitrary colours:
```
\documentclass[aspectratio=169]{beamer}
\usepackage{tikz}
\makeatletter
\defbeamertemplate{background canvas}{color}[1][red]{%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth,\the\paperheight);
\fill[fill=#1] (0,0) rectangle (\the\paperwidth,\the\paperheight);
\node[anchor=north west,inner sep=0pt,outer sep=0pt] at (0,\the\paperheight) {This text should be in the upper left corner};
\end{tikzpicture}
}
\BeforeBeginEnvironment{frame}{%
\setbeamertemplate{background canvas}[color][red]%
}
\makeatletter
\define@key{beamerframe}{mycolor}[true]{
\setbeamertemplate{background canvas}[color][#1]%
}
\makeatother
\begin{document}
\title{This shall be a green title}
\begin{frame}[mycolor=green]
\titlepage
\end{frame}
\begin{frame}
This shall be a regular red content page
\end{frame}
\title{This shall be a blue title}
\begin{frame}[mycolor=blue]
\titlepage
\end{frame}
\begin{frame}
This shall be a regular red content page
\end{frame}
\end{document}
```
![Screen Shot 2020-07-05 at 14.20.27.png](/image?hash=feba05bf0bbc187d053e0ed6c89c91b842c08cff4777c5ed689d95929d087006)