0

I want that frametitles in my Beamer presentation:

  • have a smaller width than paperwidth
  • are horizontally degraded
  • have rounded corners

This post gave my the two first points described above. But I don't get how to put rounded corners.

If I add the line \setbeamertemplate{frametitle}[rounded corners] it changes nothing.

Should I indicate the parameter rounded corners in the \defbeamertemplate command? If yes, where?

Here is a related MWE:

\documentclass[xcolor={dvipsnames,svgnames,table},10pt]{beamer}

\usepackage[T1]{fontenc}

\colorlet{titleleft}{Red}
\colorlet{titleright}{Green}

\setbeamercolor*{frametitle}{fg=white}

\makeatletter
\pgfdeclarehorizontalshading[titleleft,titleright]{beamer@frametitleshade}{0.7\paperheight}{%
  color(50pt)=(titleleft);
  color(0.85\paperwidth)=(titleright)}

\defbeamertemplate*{frametitle}{horizontal shading}
{%
  \nointerlineskip%
  \vskip+3pt%
  \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

\setbeamertemplate{frametitle}[rounded corners]

\begin{document}

\begin{frame}{$\hspace{5em}$\textbf{Test}}
 a Test frame
\end{frame}

\end{document}
1

In order to get rounded corners I replaces \pgfpathrectangle{}{} by \pgfpathrectanglecorners{}{}. I did not find where you specified the width of your custom frametitle, so you might want to adjust the .2 and .8 to what you actually want.

\documentclass[xcolor={dvipsnames,svgnames,table},10pt]{beamer}

\usepackage[T1]{fontenc}

\colorlet{titleleft}{Red}
\colorlet{titleright}{Green}

\setbeamercolor*{frametitle}{fg=white}

\makeatletter
\pgfdeclarehorizontalshading[titleleft,titleright]{beamer@frametitleshade}{0.7\paperheight}{%
  color(50pt)=(titleleft);
  color(0.85\paperwidth)=(titleright)}

\defbeamertemplate*{frametitle}{horizontal shading}
{%
  \nointerlineskip%
  \vskip+3pt%
  \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%
          \leftskip2.8cm%
          \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}} 
         \pgfsetcornersarced{\pgfpoint{3mm}{3mm}}
         \pgfpathrectanglecorners{\pgfpoint{.2\paperwidth}{0}}{\pgfpoint{.8\paperwidth}{\beamer@tempdim}}
        \pgfusepath{clip}
        \pgftext[left,base]{\pgfuseshading{beamer@frametitleshade}}
      \end{pgfpicture}
      \hskip-\paperwidth%
      \box\beamer@tempbox%
    }%
    \hskip-\Gm@rmargin%
  }%
    \vskip-2pt
}
\makeatother

\setbeamerfont{frametitle}{size=\Large,series=\bfseries}

\begin{document}

\begin{frame}{Test}
 a Test frame
\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.