
考慮以下投影機框架代碼:
\begin{frame}{Test}
\begin{block}{Single column}
\justifying
This is a block.
\end{block}
\begin{columns}[onlytextwidth]
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Left}
\justifying
This is the first column.
\end{exampleblock}
\end{column}
\begin{column}[right]{0.45\textwidth}
\begin{exampleblock}{Right}
\justifying
This is the second column.
\end{exampleblock}
\end{column}
\end{columns}
\end{frame}
它產生以下結果:
問題在於右側方塊未與全文寬度右對齊。
如何正確對齊?
編輯:
我加載以下包:
\usepackage{marvosym} %
\usepackage{ragged2e} % define justifying
\usepackage{hyperref} %
\usepackage{transparent} %
答案1
正如 @barbarabeeton 在評論中所觀察到的那樣,事實證明有必要在左側環境中插入類似\strut
--也會這樣做 -- 的內容,即包含單字 的環境,該環境不包含帶有下行字母的字母——然而確實如此。\mathstrut
exampleblock
Left
Right
在 LaTeX 內核中,\strut
被定義為零寬度,因此不可見具有高度0.7\baselineskip
和深度的垂直規則0.3\baselineskip
;因此它的總高度等於\baselineskip
。相反, a\mathstrut
的總高度是)
字元的總高度。因此A\strut
比 a 稍高\mathstrut
。無論哪種方式,\strut
和都\mathstrut
為左側塊提供了足夠的深度。
一般來說,可能需要提供支柱兩個都左側和右側範例區塊環境,特別是如果一個區塊包含具有上行字母但沒有下行字母的單字(例如,left
, black
),而另一個區塊包含具有下行字母但沒有上行字母的單字(例如,green
, uvwxyz
)。
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{marvosym} %
\usepackage{ragged2e} % define justifying
\usepackage{transparent} %
\usepackage{hyperref} %
\begin{document}
\begin{frame}{Test}
\begin{block}{Single column}
\justifying
This is a block.
\end{block}
\begin{columns}[onlytextwidth]
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Left\strut}
\justifying
This is the first column.
\end{exampleblock}
\end{column}
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Right}
\justifying
This is the second column.
\end{exampleblock}
\end{column}
\end{columns}
\end{frame}
\end{document}
答案2
\documentclass{beamer}
\usetheme{Boadilla}
\newsavebox{\squaredblocktext}
\setbeamertemplate{block begin}{
\par\vskip\medskipamount%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex]{block title}
\usebeamerfont*{block title}\insertblocktitle%
\end{beamercolorbox}}%
\begin{lrbox}{\squaredblocktext}%
\begin{minipage}[t]{\textwidth}%
\ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\setbeamertemplate{block end}{
\end{minipage}%
\end{lrbox}%
{\parskip0pt\par}%
\ifbeamercolorempty[bg]{block title}{}
{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body}%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
\usebox{\squaredblocktext}
\end{beamercolorbox}%
}\vskip\smallskipamount%
}
\setbeamertemplate{block example begin}{
\par\vskip\medskipamount%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex]{block title example}
\usebeamerfont*{block titleexample}\insertblocktitle%
\end{beamercolorbox}}%
\begin{lrbox}{\squaredblocktext}%
\begin{minipage}[t]{\textwidth}%
\ifbeamercolorempty[bg]{block body example}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\setbeamertemplate{block example end}{
\end{minipage}%
\end{lrbox}%
{\parskip0pt\par}%
\ifbeamercolorempty[bg]{block title example}{}
{\ifbeamercolorempty[bg]{block body example}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body example}%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex,vmode]{block body example}%
\usebox{\squaredblocktext}
\end{beamercolorbox}%
}\vskip\smallskipamount%
}
\begin{document}
\begin{frame}{Test}
\begin{block}{Single column}
This is a block.
\end{block}
\begin{columns}[onlytextwidth]
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Left}
This is the first column.
\end{exampleblock}
\end{column}
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Right}
This is the second column.
\end{exampleblock}
\end{column}
\end{columns}
\end{frame}
\end{document}