2

I am trying to apply vertical shading to the title frame but I am unable to get the title into the frame.

Thanks for your help.

enter image description here

\documentclass{beamer}

\definecolor{lightgreen}{RGB}{140,238,144}
\definecolor{darkgreen}{RGB}{0,100,0}
\makeatletter
\pgfdeclareverticalshading{beamer@frametitleshade}{\paperwidth}{%
    color(3pt)=(darkgreen);
    color(30pt)=(lightgreen)
    }

\setbeamertemplate{headline}
{
  \begin{beamercolorbox}{section in head/foot}
  \vskip2.5pt\insertnavigation{\paperwidth}\vskip3pt
  \end{beamercolorbox}%
}

\setbeamertemplate{frametitle}
{
    \begin{beamercolorbox}[sep=0cm,ht=2em,wd=\paperwidth]{frametitle}
    \pgfuseshading{beamer@frametitleshade}
    \end{beamercolorbox}
}

\begin{document}        

\begin{frame}{Test Title 1}
Sample Text 1
\end{frame}

\begin{frame}{Test Title 2|}
Sample Text 2
\end{frame}     

\end{document}
1

you need to dig deeper into the frametitle template before inserting the shading, like this:

\defbeamertemplate*{frametitle}{vertical shading}
{%
    \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-.75ex%
                    \leftskip0.3cm%
                    \rightskip0.3cm plus1fil\leavevmode
                    \insertframetitle%
                    \ifx\insertframesubtitle\@empty%
                    \strut\par%
                    \else
                    \par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
                    \fi%
                    \nointerlineskip
                    \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%
    }%
    \vskip-2pt
}

This replace your setbeamer template.

MWE:

\documentclass{beamer}

\definecolor{lightgreen}{RGB}{140,238,144}
\definecolor{darkgreen}{RGB}{0,100,0}
\makeatletter
\pgfdeclareverticalshading{beamer@frametitleshade}{\paperwidth}{%
    color(3pt)=(darkgreen);
    color(30pt)=(lightgreen)
    }

\setbeamertemplate{headline}
{
  \begin{beamercolorbox}{section in head/foot}
  \vskip2.5pt\insertnavigation{\paperwidth}\vskip3pt
  \end{beamercolorbox}%
}

\defbeamertemplate*{frametitle}{vertical shading}
{%
    \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-.75ex%
                    \leftskip0.3cm%
                    \rightskip0.3cm plus1fil\leavevmode
                    \insertframetitle%
                    \ifx\insertframesubtitle\@empty%
                    \strut\par%
                    \else
                    \par{\usebeamerfont*{framesubtitle}{\usebeamercolor[fg]{framesubtitle}\insertframesubtitle}\strut\par}%
                    \fi%
                    \nointerlineskip
                    \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%
    }%
    \vskip-2pt
}
\makeatother

\begin{document}        

\begin{frame}{Test Title 1}
Sample Text 1
\end{frame}

\begin{frame}{Test Title 2|}
Sample Text 2
\end{frame}     

\end{document}

enter image description here

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.