Search code examples
latexr-markdownbeamer

How to customize the title page of beamer presentation?


It is very often one needs to customize the title page of presenation.

For example, we want to :

  • remove title page number;
  • add logo or banner;
  • move title, subtitle etc.;
  • add a label;
  • etc.

Base look:

---
title: "My beautiful presentation"
author: "John Doe"
institute: "New Town University"

output: 
  beamer_presentation:
     latex_engine: lualatex

keep_tex: true
header-includes: |
  \usepackage{tikz}
  \usepackage[absolute,overlay]{textpos}       
  \usetheme{metropolis}       
---

enter image description here

Then comes the strange, when I want to add something via (title: etc. were removed):

  \setbeamertemplate{title page}{
    \insertsubtitle{My new presentation}
  } 

... my title page disappears (now toc is the 1st page).

enter image description here

Same situation when I try to add new label via \begin{textblock*} ... \end{textblock*} or \includegraphics[trim= ...]{pic.png}

When title etc. were retained - we see only subtitle/textblock/pic:

enter image description here

Where is a problem?


An update.

Under label I supposed a text in the desired position. Sorry for the mispresentation.

Look to this pic, how to do this?

enter image description here

Also I want to ask, how to combine this solution with rmarkdown? Adding frame by frame in header-includes is ok, but how to add frames with R-code via #, ## etc.?


Solution

  • If you use

    \setbeamertemplate{title page}{
      ...
    } 
    

    you instruct latex to throw away the existing title page and replace it with whatever code you write inside this template.

    Furthermore the syntax \insertsubtitle{My new presentation} is wrong. To set the subtitle, you should use \subtitle{...} (not inside the title page!) and if you'd like to insert the subtitle in a custom title page, you can use \insertsubtitle (this macro does not have any arguments!)


    • remove title page number;

    use a plain frame

    • add logo or banner;

    use \titlegraphic{...}

    • move title, subtitle etc.;

    Start with the definition from the metropolis theme and modify it to whatever layout you like

    • add a label;

    like in any other frame with the label=... option


    \documentclass{beamer}
    
    \title{text}
    \author{names}
    
    \usetheme{metropolis}
    
    \makeatletter
    \setbeamertemplate{title page}{
      \begin{minipage}[b][\paperheight]{\textwidth}
        \ifx\inserttitlegraphic\@empty\else{\centering some text here\\[-1.2cm] \usebeamertemplate*{title graphic}}\fi
        \vfill%
        \ifx\inserttitle\@empty\else\usebeamertemplate*{title}\fi
        \ifx\insertsubtitle\@empty\else\usebeamertemplate*{subtitle}\fi
        \usebeamertemplate*{title separator}
        \ifx\beamer@shortauthor\@empty\else\usebeamertemplate*{author}\fi
        \ifx\insertdate\@empty\else\usebeamertemplate*{date}\fi
        \ifx\insertinstitute\@empty\else\usebeamertemplate*{institute}\fi
        \vfill
        \vspace*{1mm}
      \end{minipage}
    }
    \makeatother
    
    \titlegraphic{\includegraphics[width=3cm]{example-image-duck}}
    
    \begin{document}
        
    \begin{frame}[plain,label=whatever]
        \titlepage
    \end{frame} 
        
    \end{document}
    

    ---
    output: 
      beamer_presentation:
         latex_engine: lualatex
    
    keep_tex: true
    header-includes: |
      \usepackage{tikz}
      \usepackage[absolute,overlay]{textpos}       
      \usetheme{metropolis}  
      \AfterBeginDocument{
      \title{My beautiful presentation}
      \author{John Doe}
      \date{\today}
      \institute{New Town University}}   
      \makeatletter
      \setbeamertemplate{title page}{
      \begin{minipage}[b][\paperheight]{\textwidth}
        \ifx\inserttitlegraphic\@empty\else{\centering some text here\\[-1cm] \usebeamertemplate*{title graphic}}\fi
        \vfill%
        \ifx\inserttitle\@empty\else\usebeamertemplate*{title}\fi
        \ifx\insertsubtitle\@empty\else\usebeamertemplate*{subtitle}\fi
        \usebeamertemplate*{title separator}
        \ifx\beamer@shortauthor\@empty\else\usebeamertemplate*{author}\fi
        \ifx\insertdate\@empty\else\usebeamertemplate*{date}\fi
        \ifx\insertinstitute\@empty\else\usebeamertemplate*{institute}\fi
        \vfill
        \vspace*{1mm}
      \end{minipage}
      }
      \makeatother
      \titlegraphic{\includegraphics[width=3cm]{example-image-duck}}  
    ---
    
    ##  {.plain}
    \titlepage
    
    ##
    
    \tableofcontents
    
    # a new section
    
    ## next frame