为长框架标题文本添加阴影

为长框架标题文本添加阴影

想要在框架标题中添加阴影,可以是多行的。尝试了几种解决方案,但都不起作用。有什么帮助吗?

添加代码来自这里,MWE:

\documentclass{beamer}

\usepackage{pgfplots, pgfplotstable,stackengine}

\newcommand\shadowfy[1]{\expandafter\shadowfypars#1\par\relax\relax}
\long\def\shadowfypars#1\par#2\relax{%
    \ifx#1\relax\else
    \shadowfywords#1 \relax\relax%
    \fi%
    \ifx\relax#2\else\par\shadowfypars#2\relax\fi%
}
\def\shadowfywords#1 #2\relax{%
    \ifx#1\relax\else
    \shadowfyletters#1\relax\relax%
    \fi%
    \ifx\relax#2\else\ \shadowfywords#2\relax\fi%
}
\def\shadowfyletters#1#2\relax{%
    \shadow{#1}%
    \ifx\relax#2\else\shadowfyletters#2\relax\fi}

\newlength\shadowHoffset
\newlength\shadowVoffset

\setlength\shadowHoffset{.3pt}%
\setlength\shadowVoffset{-.3pt}%
\def\primarycolor{black}%
\def\secondarycolor{black!30}%

\def\shadow#1{\kern\shadowHoffset%
    \raisebox{\shadowVoffset}{%
        \stackinset{c}{-\shadowHoffset}{c}{-\shadowVoffset}%
        {\textcolor{\primarycolor}{#1}}{\textcolor{\secondarycolor}{#1}}}%
    \kern-\shadowHoffset}

\setbeamercolor{frametitle}{fg = black}%, bg = black
\setbeamertemplate{frametitle}{%
    \vskip-3pt
    \begin{beamercolorbox}[sep=0.6em,wd=\paperwidth,leftskip=0cm,rightskip=0cm]{frametitle}%
        \vspace{-2pt}\par
        %\hspace{.4cm}\centering{\textbf{\textcolor{frameTitle}{\shadowoffset{0.5pt}\shadowcolor{frameTitleShadow}\shadowtext{\insertframetitle}}}}\strut
        % ^ This does work with shadow, but not for long multiline title
        %\hspace{.4cm}\centering{\textbf{\textcolor{black}{\insertframetitle}}}\strut
        % ^ This does work with multiline long title, but with no shadow
    \hspace{.4cm}\centering{\textbf{\shadowfy{\insertframetitle}}}\strut
    \end{beamercolorbox}%
}

\begin{document}
\begin{frame}{Long long looonnngggg, veryyyieee loooonnnnggggg frame title}
test
\end{frame}
\end{document}

答案1

您可以手动创建阴影效果:

\documentclass{beamer}

\usepackage{pgfplots, pgfplotstable,stackengine}



\setbeamercolor{frametitle}{fg = black}%, bg = black
\setbeamertemplate{frametitle}{%
    \vskip-3pt
    \begin{beamercolorbox}[sep=0.6em,wd=\paperwidth,leftskip=0cm,rightskip=0cm]{frametitle}%
    \smash{\raisebox{-0.04cm}{\begin{minipage}[t]{\columnwidth}
    \color{lightgray}\insertframetitle
    \end{minipage}}}
    
    \hspace{-0.02cm}\begin{minipage}{\columnwidth}
    \insertframetitle
    \end{minipage}%
    \end{beamercolorbox}%
}



\begin{document}
\begin{frame}{Long long looonnngggg, veryyyieee loooonnnnggggg frame title}
test
\end{frame}
\end{document}

在此处输入图片描述

相关内容