beamer 与 adjustwidth 中的文本边距(changepage.sty)

beamer 与 adjustwidth 中的文本边距(changepage.sty)

我的 Beamer 演示文稿中的一些(并非全部)幻灯片需要更宽的文本块。我知道我可以使用任意宽度的columns单个 env column,但这有点冗长。当我发现changepage.sty乍一看,\adjustwidth环境确实满足了我的要求。

但是,我无法让 beamer 的block环境很好地运行\adjustwidth(参见下面 MWE 的第 5 部分)。我做错了什么?

\documentclass{beamer}

\usecolortheme{orchid}
\setbeamertemplate{blocks}[rounded][shadow]

\usepackage{changepage}

\begin{document}
\begin{frame}

  \centerline{1}
  \rule{\linewidth}{1pt} % 1: used for reference

  \bigskip
  \bigskip
  \centerline{2}
  \begin{adjustwidth}{0pt}{0pt}
      \rule{\linewidth}{1pt} % looks fine
  \end{adjustwidth}

  \bigskip
  \bigskip
  \centerline{3}
  \begin{adjustwidth}{-1cm}{-1cm}
    \rule{\linewidth}{1pt} % looks fine too (i.e. full \paperwidth) 
  \end{adjustwidth}

  \bigskip
  \bigskip
  \centerline{4}
  \begin{adjustwidth}{-1cm}{-1cm}
    \rule{128mm}{1pt} % still fine (paper is 128mm wide by default)
  \end{adjustwidth}

  \bigskip
  \bigskip

  \centerline{5}
  \begin{adjustwidth}{-1cm}{-1cm}
    \begin{block}{}
      \rule{128mm}{1pt} % goes beyond the edge of the page

      \rule{\linewidth}{1pt} % does not have the intented length
    \end{block}
  \end{adjustwidth}

\end{frame}
\end{document}

答案1

你可以定义自己的adjustwidth环境(基于columns环境):

\documentclass{beamer}

\usecolortheme{orchid}
\setbeamertemplate{blocks}[rounded][shadow]

%\usepackage{changepage}

\newenvironment{adjustwidth}[2]{
  \begin{columns}
    \column{\dimexpr\linewidth-#1-#2}
}{\end{columns}}

\begin{document}
\begin{frame}

  \centerline{1}
  \rule{\linewidth}{1pt} % 1: used for reference

  \bigskip
  \bigskip
  \centerline{2}
  \begin{adjustwidth}{0pt}{0pt}
      \rule{\linewidth}{1pt} % looks fine
  \end{adjustwidth}

  \bigskip
  \bigskip
  \centerline{3}
  \begin{adjustwidth}{-1cm}{-1cm}
    \rule{\linewidth}{1pt} % looks fine too (i.e. full \paperwidth) 
  \end{adjustwidth}

  \bigskip
  \bigskip
  \centerline{4}
  \begin{adjustwidth}{-1cm}{-1cm}
    \rule{128mm}{1pt} % still fine (paper is 128mm wide by default)
  \end{adjustwidth}

  \bigskip
  \bigskip

  \centerline{5}
  \begin{adjustwidth}{-1cm}{-1cm}
    \begin{block}{}
      \rule{128mm}{1pt} % goes beyond the edge of the page

      \rule{\linewidth}{1pt} % does not have the intented length
    \end{block}
  \end{adjustwidth}

\end{frame}
\end{document}

相关内容