Beamer:如何制作一个从上到下没有上下空白的盒子?

Beamer:如何制作一个从上到下没有上下空白的盒子?

在此处输入图片描述

\documentclass{beamer}

\usetheme{Warsaw}               % thème
\usecolortheme{wolverine}       % variante de couleur

% Enlève les icônes de navigation
\beamertemplatenavigationsymbolsempty

\setbeamersize{text margin left=0cm}
\setbeamersize{text margin right=0cm}

\begin{document}

\begin{frame}{Title}

\hfill\colorbox{blue!15!white}{%
\rule[-7cm]{0pt}{0pt}
\begin{minipage}{4cm}
\begin{itemize}
\item One.
\item Two.
\item Three.
\end{itemize}
\end{minipage}
}


\end{frame}

\end{document}

答案1

为了正确地做到这一点,我必须阅读 pgf。

我认为最好的方法是将所有颜色都包含在标题样式中,这就是我现在所做的。这将创建框架标题样式和阴影着色器的自定义版本,以使框看起来位于标题栏正下方的阴影下。

\documentclass{beamer}

\usetheme{Warsaw}               % thème
\usecolortheme{wolverine}       % variante de couleur

% Enlève les icônes de navigation
\beamertemplatenavigationsymbolsempty

\setbeamersize{text margin left=0cm}
\setbeamersize{text margin right=0cm}

\makeatletter
% Custom shader that covers only part of the width of the page
\pgfdeclareverticalshading{beamer@whitetopshade}{\dimexpr \paperwidth - 4cm}{%
    color(0pt)=(bg);
    color(4pt)=(black!50!bg)}

% Custom shader covering the remaining part of the page
\pgfdeclareverticalshading{beamer@bluetopshade}{4cm}{%
    color(0pt)=(blue!15!white);
    color(4pt)=(black!50!bg)}

% Custom frametitle template that uses the previous two shaders
\defbeamertemplate*{frametitle}{mytitleshadow}
{%
  \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%
  }%
  \nointerlineskip
    \vskip-0.2pt
    \hbox to\textwidth{\hskip-\Gm@lmargin\pgfuseshading{beamer@whitetopshade}\pgfuseshading{beamer@bluetopshade}%
    \begin{pgfinterruptboundingbox}%
    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{-4cm}{-\dimexpr\textheight-\headheight}}%
    \color{blue!15!white}%
    \pgfusepath{fill}%
    \end{pgfinterruptboundingbox}%
    \hskip-\Gm@rmargin}%
    \vskip-2pt
}
\makeatother


\begin{document}
\setbeamertemplate{frametitle}[myshadowtheme]
\begin{frame}{Title}

\begin{columns}[onlytextwidth]

\column{\dimexpr\textwidth-4cm}
\begin{itemize}
\item stuff on the left
\item more stuff on the left
\end{itemize}

\column{4cm}
\begin{itemize}
\item one
\item two
\item three
\end{itemize}

\end{columns}

\end{frame}

\setbeamertemplate{frametitle}[shadow theme]
\begin{frame}{Second test frame}
Back to normal
\end{frame}
\end{document}

这将为您提供:

在此处输入图片描述

我认为这看起来更好。

我在这里硬编码了一些内容4cm,这些内容可能应该被做成一个宏,或者样式选项(我认为这是可能的),这样就可以更容易地根据你想要的颜色框的宽度进行更改。

相关内容