1

I'm trying to improve on the infolines outer theme by adding shading at the edge of each box of the footline. Taking a very simple example, my code is:

\documentclass{beamer}

% use shading packages
\usepackage{tikz}
\usetikzlibrary{shadings}

\useoutertheme{infolines} %current section at the top; author, institution, title, date and page at bottom

% define shading
\makeatletter
\AtBeginDocument{
    \usebeamercolor{author in head/foot}
    \usebeamercolor{institute in head/foot}

    \pgfdeclarehorizontalshading{beamer@authorinstituteshade}{2.25ex}{%
        color(10em)=(author in head/foot.bg);
        color(18em)=(institute in head/foot.bg)
    }
}

% Adjust footline (use just author/institution/date/page)
\setbeamertemplate{footline}
{
\leavevmode%
\hbox{%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
        \usebeamerfont{author in head/foot}\insertshortauthor
        \pgfuseshading{beamer@authorinstituteshade}%
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{institute in head/foot}%
        \usebeamerfont{institute in head/foot}\insertshortinstitute
    \end{beamercolorbox}%
    \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
        \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
        \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
\end{beamercolorbox}}%
\vskip0pt%
}
\makeatother

\usecolortheme{beaver}
\setbeamercolor{author in head/foot}{bg=red!60!black,fg=white}
\setbeamercolor{institute in head/foot}{bg=red!40!,fg=black}

\usefonttheme{structuresmallcapsserif}

\title{Title}
\author{Author}
\institute{Institute}
\date{Date}

\begin{document}

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

\end{document}

And the output looks like this: enter image description here My color choices here are deliberately ugly, to make things more apparent. In practice, what I want is a "blend" feeling at the shared border of the red and pink areas in the footline; same for the pink and grey ones. So, I have the following three problems:

-why is the shaded area not vertically aligned with the box I put it in?

-how can I shift it leftwards to adjust it to the rim of the boxes?

-in the definition of the shading, here:

\pgfdeclarehorizontalshading{beamer@authorinstituteshade}{2.25ex}{%
        color(10em)=(author in head/foot.bg);
        color(18em)=(institute in head/foot.bg)
}

How can I set the height of the shading to automatically match the height of the box it is called in, instead of being manually set to the same height {2.25ex} ?

Thanks in advance for your help!

  • Welcome to TeX.Stackexchange! – user36296 Oct 31 '17 at 20:41
1

Maybe use a single shading instead?

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{shadings}

\useoutertheme{infolines} 
\usecolortheme{beaver}

\setbeamercolor{author in head/foot}{parent=palette primary,bg=,fg=white}
\setbeamercolor{title in head/foot}{parent=palette secondary,bg=,fg=white}
\setbeamercolor{date in head/foot}{parent=palette tertiary,bg=,fg=black}
\setbeamercolor{section in head/foot}{parent=palette primary,bg=}
\setbeamercolor{subsection in head/foot}{parent=palette secondary,bg=}

\colorlet{titleleft}{red!60!black}
\colorlet{titlemiddle}{red!40!}
\colorlet{titleright}{gray!40}

\pgfdeclarehorizontalshading[titleleft,titlemiddle,titleright]      {beamer@frametitleshade}{\paperheight}{%
    color(0\paperwidth)=(titleleft);
    color(0.15\paperwidth)=(titleleft);
  color(0.5\paperwidth)=(titlemiddle);
  color(0.85\paperwidth)=(titleright);
  color(\paperwidth)=(titleright)
}

\makeatletter
\setbeamertemplate{footline}
{
    \leavevmode%
    \setbox\beamer@tempbox=\hbox{%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
            \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
            \usebeamerfont{title in head/foot}\insertshorttitle
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
            \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
            \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
        \end{beamercolorbox}%
        }%
        \vskip-\beamer@tempdim%
        \beamer@tempdim=\ht\beamer@tempbox%
        \advance\beamer@tempdim by 4pt%
        \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
            \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
            \pgfusepath{clip}
            \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
        \end{pgfpicture}
        \vskip-\beamer@tempdim%
        \box\beamer@tempbox%    
}%

\setbeamertemplate{headline}
{
    \leavevmode%
    \setbox\beamer@tempbox=\hbox{%
        \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,right]{section in head/foot}%
            \usebeamerfont{section in head/foot}\insertsectionhead\hspace*{2ex}
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.65ex,dp=1.5ex,left]{subsection in head/foot}%
            \usebeamerfont{subsection in head/foot}\hspace*{2ex}\insertsubsectionhead
        \end{beamercolorbox}%
        }%
        \beamer@tempdim=\ht\beamer@tempbox%
        \advance\beamer@tempdim by 4pt%
        \vskip-\beamer@tempdim%
        \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{20pt}
            \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
            \pgfusepath{clip}
            \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
        \end{pgfpicture}
        \vskip-\beamer@tempdim%
        \box\beamer@tempbox%    
        \vskip0pt%
}
\makeatother


\title{Title}
\author{Author}
\institute{Institute}
\date{Date}

\begin{document}

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

\end{document}

enter image description here

(based on https://tex.stackexchange.com/a/311829/36296 )

  • Thanks, that's great! One issue though: why is there a blank space between the navigation bar and the footline? – Magean Oct 31 '17 at 21:40
  • @Magean fixed :) – user36296 Oct 31 '17 at 22:57
  • Thanks again! Last (very minor) problem: there's a thin blank space to the left of the footline and headline. Can it be filled in? I tried adjusting the positioning of the various boxes but I'm too awkward at it. Also, could you please detail what you did with this chunk of code? I tried understanding it piecewise but I'm not expert enough... I have in mind the part that starts with \vskip-\beamer@tempdim% and ends with: \box\beamer@tempbox% – Magean Nov 1 '17 at 16:54
  • @Magean Sorry, but I don't see a blank space. How are you compiling? – user36296 Nov 1 '17 at 16:58
  • it's weird, the blank space only appears on some zoom percentages, but not all. Here's a zoomed-out example: image.noelshack.com/fichiers/2017/44/3/… It also appears on zoom-in documents, the relationship between the zoom % and the blank space is non-monotonic. I didn't observe it before, on basic infoline. I'm compiling with Mactex, using TexStudio as GUI. Maybe I should update Mactex and see what happens. – Magean Nov 1 '17 at 17:19

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.