2

Starting from Claudio Fiandrino's answer (Design a custom Beamer theme from scratch), I'm trying to create my own beamer theme for my thesis' presentation. I'm quite satisfied with it, but I would like to solve some issues:

  • On the title page, I set the distance between the top margin and the title using \vskip<..>cm, but I have to change it everytime I modify the title (e.g. if the title spans two lines, I'll have to decrease it) in order to have the baseline of the title aligned with the end of the "vertical blue line" that you can see in the code. Is there a way to have this automatically set?
  • If the frame title (and subtitle) spans over two lines, the new line won't be indented as the first one (whose indent is \SideMargin); I tried with \parbox, but I could not make it work properly.

I tried to clean the code as much as possible to show only the part that is causing these problems. The title page background is an image: TitlePage.png enter image description here All the files which defines the theme are:

beamercolorthemePOLIMI.sty

\mode<presentation>

% Colors
% Footer
\definecolor{POLIblue}{RGB}{0,51,102}
\definecolor{POLIblue1}{RGB}{26,72,118}
\definecolor{POLIblue2}{RGB}{49,91,132}
\definecolor{POLIblue3}{RGB}{111,140,169}
\definecolor{POLIblue4}{RGB}{154,175,195}
\definecolor{POLIblue5}{RGB}{168,187,203}
\definecolor{POLIblue6}{RGB}{159,178,198}
\definecolor{POLIblue7}{RGB}{148,170,191}
\definecolor{POLIblue8}{RGB}{102,133,163}

% Header
\definecolor{POLIblue9}{RGB}{177,202,226}
\definecolor{POLIblue10}{RGB}{103,154,204}
\definecolor{POLIblue11}{RGB}{2,53,102}
\definecolor{POLIblue12}{RGB}{181,186,194}

% Page number
\definecolor{POLIpage}{RGB}{2,62,109}

% Settings
\setbeamercolor*{title page header}{fg=POLIblue}
\setbeamercolor*{author}{fg=black}
\setbeamercolor*{date}{fg=POLIblue}
\setbeamercolor*{item}{fg=POLIblue}
\setbeamercolor*{frametitle}{fg=POLIblue}
\setbeamercolor*{framesubtitle}{fg=POLIblue1}
\setbeamercolor*{page number in head/foot}{fg=POLIpage}
\setbeamercolor*{author in head/foot}{fg=POLIblue}

\mode<all>

beamerinnerthemePOLIMI.sty

\mode<presentation>

\usetikzlibrary{positioning}

\newlength\SideMargin
\setlength\SideMargin{1cm}

\newlength\TopMargin
\setlength\TopMargin{1cm}

\newlength\ImageWidth
\setlength\ImageWidth{\dimexpr\the\paperwidth-2\SideMargin\relax}

\setbeamertemplate{background}{
    \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);

    \ifnum\thepage=1\relax{%

    % Title page background
    \node[anchor=north west,inner sep=0pt,minimum size=0pt] at(\SideMargin,{\the\paperheight-\TopMargin}){\includegraphics[width=\ImageWidth]{TitlePage.png}};

    %%%% VERTICAL BLU LINE - I would like to have the bottom of the title aligned with the end of this line
    \draw[color=POLIblue,line width=0.5pt] (8.186,10)--node[pos=1,inner sep=0pt,minimum size=0pt](b){}(8.186,6);
    }
  \else{%
   \fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
    }
    \fi
  \end{tikzpicture}
}

\setbeamerfont{title}{size=\normalfont\Large,family={\fontfamily{phv}},series=\bfseries}

\setbeamerfont{author}{size=\normalfont\normalsize,family={\fontfamily{phv}}}

\setbeamerfont{date}{size=\normalfont\small,family={\fontfamily{phv}}}

% Title page
\defbeamertemplate*{title page}{POLIMI}[1][]
{
   \vskip10.4cm% TITLE POSITIONING
    \begin{beamercolorbox}[wd=25cm,leftskip=7.85cm,sep=8pt,#1]{title page header}
      \usebeamerfont{title}\inserttitle\par%
    \end{beamercolorbox}%
    \vskip0.75cm%
    \begin{beamercolorbox}[wd=25cm,leftskip=8.5cm,#1]{author}
      \usebeamerfont{author}\insertauthor%
    \end{beamercolorbox}
     \vskip1cm%
    \begin{beamercolorbox}[wd=25cm,leftskip=8.5cm,#1]{date}
      \ifx\insertdate\@empty%
      \else
      \usebeamerfont{date}\insertdate%
      \fi
    \end{beamercolorbox}
  \vfill
}

\mode<all>

beamerouterthemePOLIMI.sty

\mode<presentation>

\setbeamerfont{frametitle}{size=\normalfont\Large,family={\fontfamily{phv}},series=\bfseries}

\setbeamerfont{framesubtitle}{size=\normalfont\large,family={\fontfamily{phv}}}

\setbeamerfont{page number in head/foot}{size=\normalfont\normalsize,family={\fontfamily{phv}},series=\bfseries}

% Frame title
\defbeamertemplate*{frametitle}{POLIMI}[1][]
{
    \vskip\TopMargin%
    \begin{beamercolorbox}[wd=\paperwidth,ht=1cm]{frametitle} 
    \begin{tikzpicture}
    \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,1.2);

    % Rectangles, line and frame number
    \fill[POLIblue9] (19.2,0.75) rectangle (20.2,1);
    \fill[POLIblue10] (20.4,0.75) rectangle (21.4,1);
    \fill[POLIblue11] (21.6,0.75) rectangle (\the\paperwidth-\SideMargin,1);
    \draw[POLIblue12] (19.2,-0.45) -- node[pos=0.1,above=0.2cm](PageN){%
        \begin{beamercolorbox}[wd=1cm,ht=1ex,dp=0ex,left]{page number in head/foot}%
        \usebeamerfont{page number in head/foot}\insertframenumber{}%
        \end{beamercolorbox}} (\the\paperwidth-\SideMargin,-0.45);

    % FRAME TITLE AND SUBTITLE
    \ifx\insertframesubtitle\@empty%
        {\node[anchor=west] at (\SideMargin-1.25cm,0.25){%
            \begin{beamercolorbox}[wd=0.7\paperwidth,ht=5ex,dp=1ex,left]{frametitle}%
            \usebeamerfont{frametitle}\hskip\SideMargin\insertframetitle%
            %\parbox[t]{\dimexpr0.9\paperwidth-1em\relax}{\insertsection}%
            \end{beamercolorbox}};
        }%
    \else%
        {\node[anchor=west] at (\SideMargin-1.25cm,0.6){%
            \begin{beamercolorbox}[wd=0.7\paperwidth,ht=5ex,dp=1ex,left]{frametitle}%
            \usebeamerfont{frametitle}\hskip\SideMargin\insertframetitle%
            \end{beamercolorbox}};
        \node[anchor=west] at (\SideMargin-1.25cm,-0.4){%
            \begin{beamercolorbox}[wd=0.7\paperwidth,ht=5ex,dp=1ex,left]{framesubtitle}%
            \usebeamerfont{framesubtitle}\hskip\SideMargin\insertframesubtitle%
            \end{beamercolorbox}};%
        }%
    \fi
  \end{tikzpicture}
  \end{beamercolorbox}
  \vskip10mm%
}

\mode<all>

beamerthemePOLIMI.sty

\mode<presentation>

%%%% Requirements

% Page layout
\RequirePackage{geometry}

% Tikz pictures
\RequirePackage{tikz}

% Font type
\usepackage[T1]{fontenc}
\RequirePackage{helvet}

% Justified text
\RequirePackage{ragged2e} 
\justifying

% Settings
\geometry{paperwidth=254.0mm,
          paperheight=190.5mm,
          left=0mm,
          right=0mm,
          top=0mm,
          bottom=0mm}
\setbeamersize{text margin left=15mm,text margin right=15mm}

% Themes
\useinnertheme{POLIMI}
\useoutertheme{POLIMI}
\usecolortheme{POLIMI}

\setbeamertemplate{navigation symbols}{}

\mode<all>

Finally, the presentation file that shows these problems:

\documentclass[17pt]{beamer}
\let\Tiny=\tiny

\usepackage{lipsum}

\title{Title, that might span one or two lines (or even more)}
\date{Now}
\author[Me]{Me}

\usetheme{POLIMI}

\begin{document}

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

\begin{frame}{A quite long frame title that cannot be shortened}
    \lipsum[1]
\end{frame}

\begin{frame}{Another quite long frame title that cannot be shortened}
    \framesubtitle{The same might happen for the frame subtitle, if it's too long}
    \lipsum[1]
\end{frame}

\end{document}
2

Just a first idea that you could consider. Instead of fixing the vertical line as part of the background, draw it when you build the title. A \rule command will do the work. And the title can be included inside a bottom aligned \parbox.

I've modified beamerinnerthemePOLIMI.sty in this way and the result looks like

enter image description here

I think similar \parbox can be applied to title and subtitle for regular frames, but I've not tested it.

modified beamerinnerthemePOLIMI.sty

\mode<presentation>

\usetikzlibrary{positioning}

\newlength\SideMargin
\setlength\SideMargin{1cm}

\newlength\TopMargin
\setlength\TopMargin{1cm}

\newlength\ImageWidth
\setlength\ImageWidth{\dimexpr\the\paperwidth-2\SideMargin\relax}

\setbeamertemplate{background}{
    \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);

    \ifnum\thepage=1\relax{%

    % Title page background
    \node[anchor=north west,inner sep=0pt,minimum size=0pt] at(\SideMargin,{\the\paperheight-\TopMargin}){\includegraphics[width=\ImageWidth]{TitlePage.png}};

%    %%%% VERTICAL BLU LINE - I would like to have the bottom of the title aligned with the end of this line
%    \draw[color=POLIblue,line width=0.5pt] (8.186,10)--node[pos=1,inner sep=0pt,minimum size=0pt](b){}(8.186,6);
%    }
%  \else{%
%   \fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
    }
    \fi
  \end{tikzpicture}
}

\setbeamerfont{title}{size=\normalfont\Large,family={\fontfamily{phv}},series=\bfseries}

\setbeamerfont{author}{size=\normalfont\normalsize,family={\fontfamily{phv}}}

\setbeamerfont{date}{size=\normalfont\small,family={\fontfamily{phv}}}

% Title page
\defbeamertemplate*{title page}{POLIMI}[1][]
{
    \vskip5.4cm% TITLE POSITIONING
    \begin{beamercolorbox}[wd=25cm,leftskip=7.85cm,sep=8pt,#1]{title page header}
      \rule{.5pt}{4cm}\ \usebeamerfont{title}\parbox[b]{15cm}{\inserttitle}\par%
    \end{beamercolorbox}%
    \vskip0.75cm%
    \begin{beamercolorbox}[wd=25cm,leftskip=8.5cm,#1]{author}
      \usebeamerfont{author}\insertauthor%
    \end{beamercolorbox}
     \vskip1cm%
    \begin{beamercolorbox}[wd=25cm,leftskip=8.5cm,#1]{date}
      \ifx\insertdate\@empty%
      \else
      \usebeamerfont{date}\insertdate%
      \fi
    \end{beamercolorbox}
  \vfill
}

\mode<all>
  • Thank you very much! The \rule is a nice idea! I tested \parbox even with the frame title, and after some adjustment I managed to solve all the issues! (probably the code could be improved further, but this is much better than before!). May I ask you a quick question? As last thing I would like to make the title image "un-clickable", if it is even possible; I tried with \usebackgroundtemplate{\includegraphics{TitlePage.png}} but it this way the image just disappears... – MarcoG Sep 25 '15 at 22:05
  • @MarcoG I think bein unclickable is a question of viewer. In Texworks or pdf-xchange viewer, the image is unclickable. In adobe reader, when you click on it the image is marked. Why is this a problem? – Ignasi Sep 28 '15 at 7:31
  • I didn't know that it was a question of viewer. I'm trying to reproduce a power-point template, and in this case the background image is not clickable (in the pdf produced). However, it is a matter of perfectionism :-)! In the meantime I'm going to accept your answer, thank you again for your help! – MarcoG Sep 28 '15 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.