为什么使用阴影外主题时,框架标题高度会减小?

为什么使用阴影外主题时,框架标题高度会减小?

我想在框架标题中添加水平阴影,这样我就可以在标题右侧放置徽标。要在我的框架中添加此功能,似乎我必须使用阴影外部主题。问题是,使用此主题后,框架标题高度会降低,而当尝试通过 \setbeamertemplate{frametitle} 定义框架标题高度时...框架标题会消失。

代码如下(输出如第一张图所示),如果我删除阴影外主题和阴影描述,框架标题高度将恢复到其正常值(如第二张图所示)。

\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

图片编号 1

图片编号2

答案1

如果您不喜欢shadow外部主题中框架标题的定义方式,您可以根据需要进行调整。参见下面的示例,有两个地方可以增加字体上方和下方的间距。我用 标记了我的添加内容%%%%%%%%%%%

\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}

在此处输入图片描述

相关内容