13

I'm wondering how to change the vertical position of the text in a frametitle? Take for instance this frametitle:

enter image description here

I'd like to place the text, in this case "Introduction", a bit higher such that it is exactly in the vertical center.

\documentclass{beamer}
\usepackage{textpos}
\usepackage{tikz}

%remove navigation symbols
\setbeamertemplate{navigation symbols}{}

\definecolor{TUeRed}{RGB}{170,0,0}
\definecolor{TUeBlue}{RGB}{0,68,170}

\addtobeamertemplate{frametitle}{}{% 
\begin{textblock*}{100mm}(.95\textwidth,-1cm) \tikz {\fill[white] (0,0) -- %
(2cm,0) -- (2cm,1.1cm) -- (0.5cm,1.1cm) -- cycle;\node[TUeBlue] at %
(0.8cm,0.5cm) {\normalsize\insertpagenumber};} \end{textblock*} }

\setbeamercolor{frametitle}{bg=TUeRed}
\setbeamercolor{frametitle}{fg=white}

\begin{document}

\begin{frame}
\frametitle{Introduction}
Some text
\end{frame}

\end{document} 

[Edit] Changed the LaTeX code, thanks @Percusse!

Ailurus
  • 1,163
  • As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again. – Tobi Mar 20 '12 at 10:51
  • Can you put a working example with two slides? I don't know where to obtain the textblock environment. – percusse Mar 20 '12 at 12:04
  • Which beamer theme are you using? Please add to your question a complete, minimal example (with only those relevant settings) of your document settings. – Gonzalo Medina Mar 20 '12 at 12:04
  • @percusse, it's from the textpos package. I'll add a working example. Gonzalo, I don't use a theme, I'm trying to create my own. – Ailurus Mar 20 '12 at 13:14
  • Just to clarify the code I replaced your template declarations with the following: \addtobeamertemplate{frametitle}{}{% \begin{textblock*}{100mm}(.95\textwidth,-1cm) \tikz {\fill[white] (0,0) -- (2cm,0) -- (2cm,1.1cm) -- (0.5cm,1.1cm) -- cycle;\node[TUeBlue] at (0.8cm,0.5cm) {\normalsize\insertpagenumber};} \end{textblock*} }. (Using tikz package) – percusse Mar 20 '12 at 13:43
  • @percusse, very nice! I didn't know enough TikZ to do it like this. – Ailurus Mar 20 '12 at 14:31
  • Actually, a few years ago I did my Delft template using TU/e template so you can also start reading the inner theme file of the template. Or why not using it directly? ;). – percusse Mar 20 '12 at 14:33
  • @percusse, I don't want to use it because it's much too complex for what it does; obviously it's possible to create the same looks using only a few lines of LaTeX and TikZ :) – Ailurus Mar 21 '12 at 10:47
  • Hmm, adding \addtolength{\topmargin}{-1mm} seems to move the entire frametitle upwards. Now my text is vertically centered, but of course the height of the frametitle is less. Is there perhaps a way to change the margin/padding inside the frametitle? – Ailurus Mar 21 '12 at 15:11
  • 3
    A look into the beamer sources (beamerouterthemedefault.sty, ll. 140-160) shows that the off-centering of the frame title is caused by inserted \struts (l. 150). If they were removed, the frame title would be exactly vertically centered. I strongly advise you, however, not to do that - different frame titles with different heights would wiggle around vertically, which would look rather horrible in a presentation! – diabonas Mar 26 '12 at 11:16
  • @diabonas: Can you provide an answer please? – Marco Daniel Apr 14 '12 at 12:57

1 Answers1

17

A look into the beamer sources (beamerouterthemedefault.sty, ll. 140-160) shows that the off-centering of the frame title is caused by inserted \struts (l. 150). If they were removed, the frame title would be exactly vertically centered. I strongly advise you, however, not to do that - it would either cause the height of the colored frame title box to change for different frame titles, or the title would wiggle around vertically (if you set the box to a fixed height). Both would look rather horrible in a presentation...

If you feel that all frame titles are a little too low and you want to raise them just a tiny bit, you can try something like

\addtobeamertemplate{frametitle}{\vskip-0.5ex}{}
diabonas
  • 25,784