如何设置 Beamer 块的内边距?

如何设置 Beamer 块的内边距?

我已经陷入困境了。一个非常,非常粗糙、朴素的 TeX-y 常规。

我正在用 制作海报beamerposter。内容按逻辑划分为block环境,并通过 beamer 提供的钩子 ( ) 进行自定义\addtobeamertemplate。这就是 LaTeX 的用途所在。

这是我的代码:

\documentclass{beamer}

\usepackage[english]{babel}
\usepackage[orientation=portrait,size=a0]{beamerposter}
\mode<presentation>{%
  \usetheme{Frankfurt}%
}

\title[short]{Looonnger!!}
\author{me}
\institute{grubby}
\date{\today}

% needed to stretch out title box cleanly, but likely the root of my problem
\setbeamersize{text margin left = -5pt, text margin right = -5pt}

\addtobeamertemplate{block begin}
  {}
  {\vspace{1ex plus 0.5ex minus 0.5ex} % Pads top of block
     % separates paragraphs in a block
   \setlength{\parskip}{24pt plus 1pt minus 1pt}
   \addtolength{\leftskip}{1em}   %%% awful hack for left/right padding
   \addtolength{\rightskip}{1em}} %%% that doesn't even work right
\addtobeamertemplate{block end}
  {\vspace{2ex plus 0.5ex minus 0.5ex}}% Pads bottom of block
  {\vspace{10ex plus 1ex minus 1ex}} % Seperates blocks from each other

\addtobeamertemplate{description item}
  {\hspace{2em}} % trying to compensate for the awful hack
  {}

\usepackage{mwe}

\begin{document}
\begin{frame}[t]{}
  \vspace{-8pt}
  \begin{beamercolorbox}{}
    \maketitle
  \end{beamercolorbox}
  \vspace{10ex}

  \begin{block}{Block A}
    \lipsum

    \begin{description}[longest label]
    \item[short] Short stuff
    \item[long] Longer stuff
    \item[longest label] Longest stuff (insert cat)
    \end{description}

     \begin{itemize}
     \item I'd like to change the margins here, as well.
     \item The macros \texttt{\textbackslash leftskip} and friends
       don't work very well for environment-heavy \LaTeX{} document
       classes such as \texttt{beamer}
     \item Also, for some reason, using \texttt{\textbackslash verb}
       kills \emph{everthing}.
     \end{itemize}  
  \end{block}
\end{frame}
\end{document}

以及它产生的结果:
黑客

请注意,环境的项目符号/球itemize与左边距齐平。如果没有明确的自定义,描述环境也会做同样的事情。所有文本也都太靠近任何一侧;可以穿过\leftskip但不能\rightskip。这绝对是一团糟。

我的直接目标是能够设置右边距,这样文本就不会关闭。我的“更好”目标是为块内容设置内部填充,这样我就不必为每个环境单独设置边距,否则很快就会失控。最后,正如我在代码中的注释中所说,我相信我的问题的根源在于我如何拉伸标题以使其看起来更干净(而不仅仅是白色背景上的彩色块),但我很确定这将是一个单独的问题。


来自评论:
简而言之,我的目标(没什么特别的)是让标题的颜色覆盖整个页面顶部,并将内容分布在块中,每个块的内容根据个人喜好填充大约 2 或 3em。

答案1

当涉及列表时,使用\leftskip\rightskip注定会失败。

\usepackage{changepage}在序言中说

\addtobeamertemplate{block begin}
  {}
  {\vspace{1ex plus 0.5ex minus 0.5ex} % Pads top of block
     % separates paragraphs in a block
   \setlength{\parskip}{24pt plus 1pt minus 1pt}%
   \begin{adjustwidth}{2cm}{2cm}
}
\addtobeamertemplate{block end}
  {\end{adjustwidth}%
   \vspace{2ex plus 0.5ex minus 0.5ex}}% Pads bottom of block
  {\vspace{10ex plus 1ex minus 1ex}} % Seperates blocks from each other

移除该\addtobeamertemplate{description item}部件。

在此处输入图片描述

因为\verb你必须将你的框架声明为fragile

\begin{frame}[fragile,t]

我也会避免这样做

\setbeamersize{text margin left = -5pt, text margin right = -5pt}

但只有我一个人。

答案2

这越来越接近了,我仍然破解了文本宽度以使标题框更宽,如果我知道更多的投影仪,可能就不需要了。你必须\verb使用[fragile]框架选项。我添加了\verb|$\log$|某个地方进行测试。

\documentclass{beamer}

\usepackage[english]{babel}
\usepackage[orientation=portrait,size=a0]{beamerposter}
\mode<presentation>{%
  \usetheme{Frankfurt}%
}

\title[short]{Looonnger!!}
\author{me}
\institute{grubby}
\date{\today}

% needed to stretch out title box cleanly, but likely the root of my problem
\setbeamersize{text margin left = 15pt, text margin right = 15pt}

\addtobeamertemplate{block begin}
  {}
  {\vspace{1ex plus 0.5ex minus 0.5ex} % Pads top of block
     % separates paragraphs in a block
   \setlength{\parskip}{24pt plus 1pt minus 1pt}}

\addtobeamertemplate{block end}
  {\vspace{2ex plus 0.5ex minus 0.5ex}}% Pads bottom of block
  {\vspace{10ex plus 1ex minus 1ex}} % Seperates blocks from each other


\usepackage{mwe}

\begin{document}
\begin{frame}[fragile,t]{}


  \vspace{-8pt}
{\advance\textwidth40pt
 \hspace*{-20pt}%
  \begin{beamercolorbox}{}
    \maketitle
  \end{beamercolorbox}
}
  \vspace{10ex}

  \begin{block}{Block A}
    \lipsum

    \begin{description}[longest label]
    \item[short] Short stuff
    \item[long] Longer stuff
    \item[longest label] Longest stuff (insert cat)
    \end{description}

     \begin{itemize}
     \item I'd like to change the margins here, as well.
     \item The macros \texttt{\textbackslash leftskip} and friends
       don't work very well for environment-heavy \LaTeX{} document
       classes such as \texttt{beamer}
     \item Also, for some \verb|$\log$| reason, using \texttt{\textbackslash verb}
       kills \emph{everthing}.
     \end{itemize}  
  \end{block}
\end{frame}
\end{document}

相关内容