7

I'm trying to port a Powerpoint template to beamer, and I'm trying to replicate this font style:

Font style

I am using this font in two places:

  • Title page. This text is a paragraph (3 lines) inside a beamercolorbox. I cannot split the paragraph because I'm using \inserttitle. But I could use a TikZ node if necessary.
  • Frame titles. This text is just one line inside a TikZ node.

I tried:

  • Package shadowtext: it converts the paragraph to a line (that overflows)
  • I tried this: it converts the paragraph to a line (that overflows)
  • I tried TikZ drop shadow: it draws a box shadow instead of a text shadow
  • I tried this: it is contour, and doesn't look good.

I am using pdflatex.

Current working example (without any type of shadow):

presentation.tex

\documentclass{beamer}

\usepackage[utf8]{inputenc} % UTF8
\usetheme{ABS}

\title{This is a very long title that spans over several lines. It is very long, isn't it?}
\author{Mr. Me}
\institute{
Faculty of applied Internet\\
University of somewhere
}
\date{28 June 2016}

\begin{document}
\frame{\titlepage}
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents
\end{frame}

\section{Introduction}
\begin{frame}
\frametitle{This is the first slide}
%Content goes here
\end{frame}
\begin{frame}
\frametitle{This is the second slide}
\framesubtitle{A bit more information about this}
%More content goes here
\end{frame}
% etc
\end{document}

beamerthemeABS.sty

\mode<presentation>

% http://www.r-bloggers.com/create-your-own-beamer-template/
% https://tex.stackexchange.com/questions/146529/design-a-custom-beamer-theme-from-scratch

\mode<presentation>
\usepackage{tikz}
\usepackage{color}

\usetikzlibrary{shadows}

% Color definitions
\definecolor{green-abs}{RGB}{45, 137, 115}
\definecolor{light-green-abs}{RGB}{53, 159, 133}
\definecolor{light-blue-abs}{RGB}{208, 240, 245}

\definecolor{titlecolor-abs}{RGB}{255, 255, 255}
\definecolor{textcolor-abs}{RGB}{0, 0, 0}

% Color assignments
\setbeamercolor{frametitle}{fg = titlecolor-abs}
\setbeamercolor{title}{fg = titlecolor-abs}

\setbeamercolor{section in toc}{fg = textcolor-abs}
\setbeamercolor{section in toc shaded}{fg = textcolor-abs}

\setbeamercolor{item}{fg = textcolor-abs}
\setbeamercolor{subitem}{fg = textcolor-abs}
\setbeamercolor{subsubitem}{fg = textcolor-abs}

\setbeamercolor{description item}{fg = textcolor-abs}

\setbeamercolor{caption}{fg = textcolor-abs}
\setbeamercolor{caption name}{fg = textcolor-abs}

\setbeamercolor{normal text}{fg = textcolor-abs}

% Background
\setbeamertemplate{background canvas}{
    \ifnum\c@framenumber=1
        % First slide
        \begin{tikzpicture}[remember picture, overlay]
        \shade[outer color=green-abs, inner color=light-green-abs]
            (current page.north east) rectangle (current page.south west);
        \end{tikzpicture}
    \else
        % Other slides
        \begin{tikzpicture}[remember picture, overlay]
        \shade[top color=light-blue-abs, bottom color=white]
            (current page.north east) rectangle (current page.south west);
        \end{tikzpicture}
    \fi
}

% Inner theme
\useinnertheme{rounded}

% Outer theme
\setbeamerfont{frametitle}{size = \Large}

\setbeamertemplate{frametitle}{
    \begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
    \begin{tikzpicture}[remember picture, overlay]
        \shade[outer color=green-abs, inner color=light-green-abs]
            (0, 0) rectangle (\the\paperwidth, 1.55cm);
        %%%%%%
        % I'd like to set the style of frametitles
        %%%%%%
        \node[anchor = west, titlecolor-abs] at (0.5, 0.8)
            {\usebeamerfont{frametitle}\insertframetitle};
    \end{tikzpicture}
    \end{beamercolorbox}
}

% Title
\setbeamerfont{title}{size = \huge}

\setbeamertemplate{title page}{
    \vfill
    \centering
    \begin{beamercolorbox}[sep=8pt, center]{title}
        %%%%%%
        % I'd like to set the style of titles, which may be very long
        %%%%%%
        \usebeamerfont{title}\inserttitle\par
    \end{beamercolorbox}
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center]{author}
    \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center]{institute}
    \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center]{date}
    \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
    %\endgroup
    \vfill
}

\mode<all>
  • 2
    Welcome! And the code you'd like us to start from is? Please supply a Minimum Working Example (MWE). This will make it easier to help you and less likely that solutions won't work for your case. Also, you'd best tell us which engine you're using I think. – cfr Jun 22 '16 at 0:15
  • Probably a duplicate of tex.stackexchange.com/questions/306526/…. At least, it is hard to know without some code. – cfr Jun 22 '16 at 0:42
  • 1
    @markmb I have the felling that the title of the question is hard to find for future users. Proposal: what do you think of changing it to something a bit closer to central part: adding shadow to font in beamer title? – user36296 Jun 22 '16 at 22:59
6

A quick hack would be to write the title a second time, a bit offset and in a darker colour. The following example uses a mixture of the background colour and black \color{black!20!green-abs} and is a bit darker than the shadow shown in your example, but this can be adjusted to fir your needs.

\setbeamertemplate{frametitle}{
    \begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
        \begin{tikzpicture}[remember picture, overlay]
        \shade[outer color=green-abs, inner color=light-green-abs]
        (0, 0) rectangle (\the\paperwidth, 1.55cm);
        %%%%%%
        % I'd like to set the style of frametitles
        %%%%%%
        \node[anchor = west, titlecolor-abs] at (0.53, 0.77)
        {\usebeamerfont{frametitle}\color{black!20!green-abs}\insertframetitle};
        \node[anchor = west, titlecolor-abs] at (0.5, 0.8)
        {\usebeamerfont{frametitle}\insertframetitle};
        \end{tikzpicture}
    \end{beamercolorbox}
}

enter image description here

Edit:

And for a smoother shadow, one could stack more layers of different shades. In the following example 5 layers are used to create a smoother shadow:

\setbeamertemplate{frametitle}{
    \begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
        \begin{tikzpicture}[remember picture, overlay]
        \shade[outer color=green-abs, inner color=light-green-abs]
        (0, 0) rectangle (\the\paperwidth, 1.55cm);
        %%%%%%
        % I'd like to set the style of frametitles
        %%%%%%
        \foreach \x in {0,5,...,20}
            \node[anchor = west, titlecolor-abs, xshift=\x*-0.002cm, yshift=\x*0.002cm] at (0.5, 0.8) {%
                \usebeamerfont{frametitle}%
                \color{black!\x!green-abs}%
                \insertframetitle%
            };
        \node[anchor = west, titlecolor-abs] at (0.5-0.002*20, 0.8+0.002*20)
        {\usebeamerfont{frametitle}\insertframetitle};
        \end{tikzpicture}
    \end{beamercolorbox}
}

enter image description here

  • Would it be possible to do it without TikZ (like a text property)? If that is not possible: is it possible to do it relative to the current position of the text? It would be nice if it could be wrapped in a function. – markmb Jun 22 '16 at 12:59
  • 2
    @markmb For relative positioning, maybe have a look at tex.stackexchange.com/a/58968/36296 or the TikZ user manual. – user36296 Jun 22 '16 at 13:17
  • I added an answer with modifications to your code. Thanks for the answer! – markmb Jun 22 '16 at 23:56
2

I'll complete samcarter's answer with a couple modifications I added: I moved the code to a function, and I darkened the shadow.

Function:

\tikzset{
    text shadow/.code args={[#1]#2at#3(#4,#5)#6}{
        \pgfkeysalso{/tikz/.cd,#1}
        \foreach \x in {0,10,...,40}{%
            \node[#1, xshift=\x*-0.001cm, yshift=\x*0.001cm] at (#4,#5){%
            \color{black!\x!green-abs}
            #6
            };
        }
        \node[#1] at (#4-0.001*40, #5+0.001*40){#6};
    }
}

(tzset example from here)

Frametitle:

\setbeamertemplate{frametitle}{
    \begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
    \begin{tikzpicture}[remember picture, overlay]
        \shade[outer color=green-abs, inner color=light-green-abs]
            (0, 0) rectangle (\the\paperwidth, 1.55cm);
        \node[text shadow={[anchor = west, titlecolor-abs] at (0.5, 0.8)
            {\usebeamerfont{frametitle}\insertframetitle}}] {};
    \end{tikzpicture}
    \end{beamercolorbox}
}

Title page:

\setbeamertemplate{title page}{
    \vfill
    \centering
    \begin{beamercolorbox}[sep=25pt, center]{title}
        \begin{tikzpicture}[remember picture, overlay]
        \node[text shadow={[titlecolor-abs, text width=0.85\paperwidth, text centered] at (0, 0)
            {\usebeamerfont{title}\inserttitle\par}}] {};
        \end{tikzpicture}
    \end{beamercolorbox}
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center]{author}
        \usebeamerfont{author}\insertauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center]{institute}
        \usebeamerfont{institute}\insertinstitute
    \end{beamercolorbox}
    \begin{beamercolorbox}[sep=8pt,center]{date}
        \usebeamerfont{date}\insertdate
    \end{beamercolorbox}\vskip0.5em
    {\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
    \vfill
}

These would be the results for the title page:

Title page

It looks really good!!

  • 1
    Another idea [untested]: It might be better to give the unit of the shift 0.001cm in something fontsize dependent, maybe in units of em to be more flexible. – user36296 Jun 23 '16 at 0:04
  • I've used the same function also for the footline, with font size \tiny, and it looks better with cm than em. Anyway, it's time to stop looking at the design and start working on the presentation. – markmb Jun 23 '16 at 11:11

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.