[Tex/LaTex] Title in box in Beamer presentation

beamer

1)How to put the title on the titlepage in Beamer to a block of a desired color? Similarly like in themes Warsaw, Berlin…
2)How to control space between author and date? \vspace seems does not work.

1) I use this

\title[TITLE]{TITLE\\[1em]
\includegraphics[height=4cm]{logo}\\[1em]}
\subtitle{\textbf{Subtitle}}

But I want teh box only around TITLE . How can I do this?

Best Answer

You can redefine the title page template and introduce the necessary modifications for the layout; this redefinition is needed since both the title and the subtitle are, by deafult, inside the same beamercolorbox so simply redefining the title beamer color would produce a box around both title and subtitle (which is not wanted here):

\documentclass{beamer}

\title{TITLE}
\titlegraphic{\includegraphics[height=4cm]{cat}}
\subtitle{\textbf{Subtitle}}
\author{Author}

\setbeamercolor{title}{bg=orange,fg=white}

\makeatletter
\setbeamertemplate{title page}
{
  \vbox{}
  \vfill
  \begin{centering}
    \begin{beamercolorbox}[sep=8pt,center]{title}
      \usebeamerfont{title}\inserttitle
    \end{beamercolorbox}
    \setbeamercolor{title}{bg=white,fg=structure}
    \begin{beamercolorbox}[sep=8pt,center]{title}
      {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
      \fi%     
    \end{beamercolorbox}%
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center]{author}
      \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \vskip-1em\par % change here
    \begin{beamercolorbox}[sep=8pt,center]{institute}
      \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center]{date}
      \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
  \end{centering}
  \vfill
}
\makeatother

\begin{document}

\maketitle

\end{document}

enter image description here

Notice that now there's no need to use \title[TITLE]{TITLE\includegraphics{...}} but now you can simply use \title{TITLE} and \titlegraphic{\includegraphics[]{}}`. Of course, feel free to make the necessary adjutments according to your particular needs (yo can play with the lengths in the \vskip commands to adjust vertical spacing).

As requested in a comment, to have a colored box around only the subtitle, the necessary modifications are the following:

\documentclass{beamer}

\title{TITLE}
\titlegraphic{\includegraphics[height=4cm]{cat}}
\subtitle{\textbf{Subtitle}}
\author{Author}


\makeatletter
\setbeamertemplate{title page}
{
  \vbox{}
  \vfill
  \begin{centering}
    \begin{beamercolorbox}[sep=8pt,center]{title}
      \usebeamerfont{title}\inserttitle
    \end{beamercolorbox}
      {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
      \setbeamercolor{title}{bg=orange,fg=white}
      \begin{beamercolorbox}[sep=8pt,center]{title}
        {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
      \fi%     
    \end{beamercolorbox}%
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center]{author}
      \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \vskip-1em\par % change here
    \begin{beamercolorbox}[sep=8pt,center]{institute}
      \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center]{date}
      \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
  \end{centering}
  \vfill
}
\makeatother

\begin{document}

\maketitle

\end{document}

enter image description here

With a new request, here's the code to change at will the width of the box used for the subtitle; change the length used for \subtitwd (initially set to 4cm) according to your needs:

\documentclass{beamer}

\newlength\subtitwd
\setlength\subtitwd{4cm}% change the width here

\makeatletter
\setbeamertemplate{title page}
{
  \vbox{}
  \vfill
  \begin{centering}
    \begin{beamercolorbox}[sep=8pt,center]{title}
      \usebeamerfont{title}\inserttitle
    \end{beamercolorbox}
      {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
      \ifx\insertsubtitle\@empty%
      \else%
        \vskip0.25em%
      \setbeamercolor{title}{bg=orange,fg=white}
      \vbox{%
         \hfill\begin{beamercolorbox}[wd=\subtitwd,sep=8pt,center]{title}
            {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
        \end{beamercolorbox}\hfill\null%
      }%
      \fi%     
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center]{author}
      \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \vskip-1em\par % change here
    \begin{beamercolorbox}[sep=8pt,center]{institute}
      \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center]{date}
      \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
  \end{centering}
  \vfill
}
\makeatother

\title{TITLE}
\titlegraphic{\includegraphics[height=4cm]{cat}}
\subtitle{\textbf{Subtitle}}
\author{Author}

\begin{document}

\maketitle

\end{document}

enter image description here