
環境内で物事を垂直方向に中央揃えする「簡単な方法」はありますかoverprint
?
現在の回答に基づいて、これが私のテスト文書です
\documentclass{beamer}
\usepackage{listings}
\long\def\opcenter#1{\vfill\smash{\begin{minipage}[c]{\linewidth}#1\end{minipage}}}
\begin{document}
\begin{frame}[fragile]
\begin{overprint}
\onslide<1>
\opcenter{A short paragraph}
\onslide<2>
\opcenter{A\\
longer\\
paragraph\\
with\\
a\\
few\\
lines}
\onslide<3>
\opcenter{
\begin{block}{Title}
A block \\
with\\
a\\
few lines
\end{block}
}
\onslide<4>
\opcenter{
One paragraph
Plus something else
}
\onslide<5>
\opcenter{
\begin{lstlisting}
And verbatim stuff
\end{lstlisting}
}
\end{overprint}
\end{frame}
\end{document}
そして、問題は段落区切り(?の代わり\smash
)と逐語的内容(listings
)にあります。
答え1
アイデアとしては、\smash
テキストの高さを隠すために使用し、\vfill
垂直方向に中央揃えするためにsを使用し、次にminibox
テキストに改行を挿入します。
minipage
の代わりにを使用することもできますminibox
が、前者の場合は幅を指定する必要があります。
\documentclass{beamer}
\usepackage{minibox}
\begin{document}
\long\def\opcenter#1{\vfill\smash{\minibox{#1}}}
\begin{frame}
\begin{overprint}
\onslide<1>
\opcenter{A short paragraph}
\onslide<2>
\opcenter{A\\
longer\\
paragraph\\
with\\
a\\
few\\
lines}
% This frame uses minipage instead of minibox. minibox
% does not accept a block as its argument.
\onslide<3>
\vfill\smash{\begin{minipage}[c]{1.0\linewidth}
\begin{block}{Title}
A block \\
with\\
a\\
few lines
\end{block}
\end{minipage}}\vfill
\end{overprint}
\end{frame}
\end{document}