我正在尝试将垂直阴影应用于标题框,但无法将标题放入框架中。
感谢您的帮助。
\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
在插入阴影之前,您需要深入研究 frametitle 模板,如下所示:
\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
}
这将取代你的setbeamer template
。
梅威瑟:
\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}