2

I want to have a horizontal shading in my frame title, so I can put a logo on the right side of the title. To have this in my frames, It seems that I have to use shadow outer theme. the problem is that by using this theme the frame title height decreases and when trying to define frame title height by \setbeamertemplate{frametitle} ... the frame title disappears.

The code is as below (The output is as the first image) and if I remove shadow outer theme and shading description, the frame title height goes back to its normal value (as in the second image).

\documentclass[t]{beamer}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shading}
\useoutertheme{shadow}

\mode<presentation>
{
\usetheme{Madrid}
}

\colorlet{titleleft}{blue!50!black}
\colorlet{titlethreequarter}{blue!50!black}
\colorlet{titleright}{white}
\setbeamercolor*{frametitle}{fg=white}
\makeatletter
\pgfdeclarehorizontalshading[titleleft,titlethreequarter,titleright]
{beamer@frametitleshade}{\paperheight}{
color(0pt)=(titleleft);
color(0.75\paperwidth)=(titlethreequarter)
color(0.9\paperwidth)=(titleright)}
\makeatother

\begin{document}

\begin{frame}
\frametitle{Frame Title}
\end{frame}

\end{document

Image No. 1

Image No. 2

  • 1
    Welcome to TeX.SE. Please provide minimal working example, a complete small document,which show your problem. – Zarko Apr 29 '16 at 21:10
2

If you do not like how the frametitle is defined in the shadow outer theme, you can tweak it according to your needs. See the example below, there are two places where you can increase the spacing above and below the font. I marked my additions by %%%%%%%%%%%.

\documentclass[t]{beamer}
\useoutertheme{shadow}

\mode<presentation>
{
    \usetheme{Madrid}
}

\colorlet{titleleft}{blue!50!black}
\colorlet{titlethreequarter}{blue!50!black}
\colorlet{titleright}{white}
\setbeamercolor*{frametitle}{fg=white}
\makeatletter
\pgfdeclarehorizontalshading[titleleft,titlethreequarter,titleright]{beamer@frametitleshade}{\paperheight}{
    color(0pt)=(titleleft);
    color(0.75\paperwidth)=(titlethreequarter);
    color(0.9\paperwidth)=(titleright)
}

\setbeamertemplate{frametitle}
{%
    \nointerlineskip%
    \vskip-2pt%
    \hbox{\leavevmode
        \advance\beamer@leftmargin by -12bp%
        \advance\beamer@rightmargin by -12bp%
        \beamer@tempdim=\textwidth%
        \advance\beamer@tempdim by \beamer@leftmargin%
        \advance\beamer@tempdim by \beamer@rightmargin%
        \hskip-\Gm@lmargin\hbox{%
            \setbox\beamer@tempbox=\hbox{\begin{minipage}[b]{\paperwidth}%
                    \vbox{}\vskip.5ex%%%%%%%%%%% above the font
                    \leftskip0.3cm%
                    \rightskip0.3cm plus1fil\leavevmode
                    \insertframetitle%
                    \ifx\insertframesubtitle\@empty%
                    \strut\par%
                    \else
                    \par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
                    \fi%
                    \nointerlineskip
                    \vskip.65ex%%%%%%%%%%%%%%% below the font
                    \vbox{}%
                \end{minipage}}%
                \beamer@tempdim=\ht\beamer@tempbox%
                \advance\beamer@tempdim by 2pt%
                \begin{pgfpicture}{0pt}{0pt}{\paperwidth}{\beamer@tempdim}
                    \usebeamercolor{frametitle right}
                    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\beamer@tempdim}}
                    \pgfusepath{clip}
                    \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
                \end{pgfpicture}
                \hskip-\paperwidth%
                \box\beamer@tempbox%
            }%
            \hskip-\Gm@rmargin%
        }%
        \nointerlineskip
        \vskip-0.2pt
        \hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@topshade}\hskip-\Gm@rmargin}
        \vskip-2pt
    }




\makeatother

\begin{document}

    \begin{frame}
        \frametitle{Frame Title}
    \end{frame}

    \begin{frame}
        \frametitle{Frame Title}
    \end{frame} 

\end{document}

enter image description here

  • Thank you Sam. It solved my problem. I really appreciate your help. – Yousef Ahmadi Apr 30 '16 at 16:58

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.