1

I'm using the following code (roughly) to install a left-right shaded background behind a beamer headline. The contents of the headline is set using the outertheme tree. The shading method is based roughly on that for Singapore. The problem is that I have a line of light green at the very top of the slide, whereas I would like the dark green to go all the way to the top.

\PassOptionsToPackage{rgb}{xcolor}
\documentclass{beamer}
\definecolor{acol}{rgb}{.5,1,.5}
\definecolor{bcol}{rgb}{.1,.6,.2}
\colorlet{bcol1}{bcol!25!black}
\setbeamercolor{title in head/foot}{fg=acol,bg=}
\setbeamercolor{section in head/foot}{fg=acol,bg=}
\setbeamercolor{subsection in head/foot}{fg=acol,bg=}
\setbeamercolor{upper separation line head}{bg=bcol1}
\setbeamercolor{lower separation line head}{bg=bcol1}
\makeatletter
\useoutertheme{tree}
\pgfdeclarehorizontalshading{beamer@headfade}{\dimexpr5.4375ex+3pt}
{%
  color(0cm)=(bcol1);
  color(\paperwidth)=(acol)%
}
\addtoheadtemplate{\vskip 3pt\pgfuseshading{beamer@headfade}\vskip\dimexpr -3pt-10.875ex}{}
\makeatother
\begin{document}

  \title{Title}
  \section{A Section}
  \subsection{A Subsection}

  \begin{frame}{A Frame}{A Subframe}
    Some text
  \end{frame}

\end{document}

Presumably I've miscalculated or used the wrong values somewhere but every time I push something, something or other pushes back and I just can't seem to get it right. (Probably because I'm mesmerised, as usual, by the maze of beamer's code.)

Any hint would be much appreciated!

light green peeking at very top

6
  • 1
    No time to dig in for a proper answer now but if you use \addtoheadtemplate{\vskip 2.5pt... the upper line goes to the top: picture here – user11232 Sep 29 '14 at 0:30
  • @HarishKumar Thanks very much! That works perfectly. If you would like to write a proper answer (ideally explaining how to figure out the right value), I'd be happy to accept/up-vote it. (I'm hoping to accept an answer which explains but I'm happy to up-vote an answer which just works in the meantime!) – cfr Sep 29 '14 at 1:10
  • @HarishKumar I'm now even more puzzled. When I used these slides today, it turns out there is a light vertical line at the far left of the slide. So clearly I'm missing something here! However, I cannot see it in Okular at all. – cfr Sep 29 '14 at 20:48
  • There's a question related to this somewhere... I'm almost sure I've seen this issue asked about but I can't remember... If I zoom in and then return to fit-page view, I see the pale vertical line - or, more, a wide rectangle - for a moment before the shading covers it over. Something like this came up - somebody asked. If anybody has a clue where that question is, please let me know! – cfr Sep 29 '14 at 20:54
  • 1
    Looks so. I forgot yesterday. Later today when I get some time, I will check it out. – user11232 Sep 29 '14 at 23:20
1

I get an error with the MWE you provided. It's given in this line, saying that \dimexpr can not be used in vertical mode:

\pgfdeclarehorizontalshading{beamer@headfade}{\dimexpr5.4375ex+3pt}

I just removed it, and it works for me (there's no line at the top):

\pgfdeclarehorizontalshading{beamer@headfade}{5.4375ex+3pt}

\PassOptionsToPackage{rgb}{xcolor}
\documentclass{beamer}
\definecolor{acol}{rgb}{.5,1,.5}
\definecolor{bcol}{rgb}{.1,.6,.2}
\colorlet{bcol1}{bcol!25!black}
\setbeamercolor{title in head/foot}{fg=acol,bg=}
\setbeamercolor{section in head/foot}{fg=acol,bg=}
\setbeamercolor{subsection in head/foot}{fg=acol,bg=}
\setbeamercolor{upper separation line head}{bg=bcol1}
\setbeamercolor{lower separation line head}{bg=bcol1}
\makeatletter
\useoutertheme{tree}
\pgfdeclarehorizontalshading{beamer@headfade}{5.4375ex+3pt}
{%
  color(0cm)=(bcol1);
  color(\paperwidth)=(acol)%
}
\addtoheadtemplate{\vskip 3pt\pgfuseshading{beamer@headfade}\vskip\dimexpr -3pt-10.875ex}{}
\makeatother
\begin{document}

  \title{Title}
  \section{A Section}
  \subsection{A Subsection}

  \begin{frame}{A Frame}{A Subframe}
    Some text
  \end{frame}

\end{document}

enter image description here

3
  • That's odd. It compiles fine here. Moreover, removing it does not resolve the issue for me. I get exactly the same visual result. – cfr Sep 29 '14 at 1:05
  • Just added a picture and the full code I've used. I'm using MiKTeX and compiling with pdflatex. I don't know if that could make the difference. – U.Martinez-Corral Sep 29 '14 at 1:14
  • 1
    I'm using pdflatex but I'm using TeX Live. I can compile either way. With exactly the same results either way. I don't doubt it is different for you, but this is not, unfortunately, of help to me. Thanks anyway. – cfr Sep 29 '14 at 1:23

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.