setbeamertemplate中Beamercolorbox与普通文本的区别

setbeamertemplate中Beamercolorbox与普通文本的区别

beamercolorbox在和普通文本中都使用了 es \setbeamertemplate。但是它们的阴影看起来不同。代码如下:

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}

\newlength\barheight\setlength\barheight{\paperheight}
\divide\barheight by 12

\setbeamertemplate{frametitle}
{
  \begin{beamercolorbox}[wd=1.2\paperwidth,ht=2.5\barheight]{Title bar}
  \begin{tikzpicture}[remember picture,overlay]
    \node [xshift=\paperwidth/2,yshift=-\headheight] (mybar) at (current page.north west)
        [rectangle,fill,inner sep=0pt,minimum width=\paperwidth,
        minimum height=2.5\barheight,top color=frametitle.bg,
        bottom color=frametitle.bg]{};% bar
    \node[below of=mybar,yshift=-0.7mm,rectangle,shade,inner sep=0pt,minimum
        width=128mm,minimum height=1.2mm,top color=black!50,bottom
    color=black!10]{};% shadow
    \end{tikzpicture}%
  \end{beamercolorbox}

  \vskip -1.79cm
  \linethickness{0.0pt}
  \framelatex{
  \begin{beamercolorbox}[wd=\paperwidth,ht=0.4\barheight]{Title bar}
            \begin{columns}
            \begin{column}{0.03\paperwidth}
            \end{column}
            \begin{column}{0.87\paperwidth}
                \insertframetitle
            \end{column}
        \end{columns}
    \end{beamercolorbox}
    }

    \makeatletter
    \ifx\insertframesubtitle\@empty%
    \makeatother
    \else
        \vskip10pt
        \begin{beamercolorbox}[wd=0.6\paperwidth,shadow=true,rounded=true]{title}
            \usebeamerfont{framesubtitle}\insertframesubtitle
        \end{beamercolorbox}
    \fi}

\begin{document}
\begin{frame}
    \frametitle{There Is No Largest Prime Number}
    \framesubtitle{The proof uses \textit{reductio ad absurdum}.}
    \begin{beamercolorbox}[wd=0.5\paperwidth,shadow=true,rounded=true]{title}
        There is no largest prime number.
    \end{beamercolorbox}
\end{frame}
\end{document}

得到以下结果:

在此处输入图片描述

答案1

Beamer 会根据背景颜色自动计算阴影颜色。您可以使用以下命令将此背景设置为白色\setbeamercolor{frametitle}{bg=white}

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}

\newlength\barheight\setlength\barheight{\paperheight}
\divide\barheight by 12


\setbeamercolor{frametitle}{bg=white}

\setbeamertemplate{frametitle}
{
  \begin{beamercolorbox}[wd=0.5\paperwidth,shadow=true,rounded=true]{title}
    \usebeamerfont{framesubtitle}\insertframesubtitle
  \end{beamercolorbox}
}

\begin{document}
\begin{frame}
    \frametitle{There Is No Largest Prime Number}
    \framesubtitle{The proof uses \textit{reductio ad absurdum}.}
    \begin{beamercolorbox}[wd=0.5\paperwidth,shadow=true,rounded=true]{title}
        There is no largest prime number.
    \end{beamercolorbox}
\end{frame}
\end{document}

在此处输入图片描述

相关内容