如何在包含 beamer 上的列环境的 itemize 中左对齐项目

如何在包含 beamer 上的列环境的 itemize 中左对齐项目

我需要自动左对齐所有items。问题是我必须有一个columns中间的环境。但该环境会将项目移到左侧。我尝试设置\setlength{\itemindent}{0em}以修复移位问题。

在某些情况下,这种方法是有效的。但是,这种方法确实很耗时,而且总体上行不通,因为我必须不断检查项目符号是否对齐。我想找到一种自动对齐它们的方法。

\documentclass{beamer}

\begin{document}
\begin{frame}{test}
\begin{itemize}
\item This is a really long sentence that I used to demonstrate how strange it is to shift the items.
\item This is another sentence.
\begin{columns}
\begin{column}{0.5\linewidth}
\item Test of one sentence in the column.
\item Test of another sentence in the same column.
\end{column}
\begin{column}{0.5\linewidth}
\rule{\linewidth}{0.3\linewidth}
\end{column}
\end{columns}
\item Another sentence after the columns environment.
\end{itemize}
\end{frame}
\end{document}

在此处输入图片描述

答案1

只需在环境的左端添加另一个空白列columns。在这种情况下,使用第 1 列的宽度\leftmargini(即itemize缩进),而第 2 列和第 3 列的宽度之和必须为\linewidth。关闭环境后,我还添加了 1ex 的 vspace columns

\documentclass{beamer}
\usepackage{calc}
\begin{document}
\begin{frame}{test}
\begin{itemize}
\item This is a really long sentence that I used to demonstrate how strange it is to shift the items.
\item This is another sentence.
\begin{columns}
\begin{column}{\leftmargini}
\end{column}
\begin{column}{.5\linewidth}
\item Test of one sentence in the column.
\item Test of another sentence in the same column.
\end{column}
\begin{column}{0.5\linewidth}
\rule{\linewidth}{0.3\linewidth}
\end{column}
\end{columns}\vspace{1ex}
\item Another sentence after the columns environment.
\end{itemize}
\end{frame}
\end{document}

在此处输入图片描述

答案2

columns环境有一个可选参数,用于固定列宽

\begin{columns}[totalwidth=...]    

如果不修复,则\textwidthbeamer 会放大位线宽度。要避免这种情况,请使用选项onlytextwidth(相当于totalwidth=\textwidth)。

\documentclass{beamer}
\begin{document}
\begin{frame}{test}
\begin{itemize}
\item This is a really long sentence that I used to demonstrate how strange it is to shift the items.
\item This is another sentence.
\end{itemize}
%
\begin{columns}[onlytextwidth]
\begin{column}{.5\linewidth}
\begin{itemize}
\item Test of one sentence in the column.
\item Test of another sentence in the same column.
\end{itemize}
\end{column}
\begin{column}{0.5\linewidth}
\rule{\linewidth}{0.3\linewidth}
\end{column}
\end{columns}
%
\begin{itemize}
\item Another sentence after the columns environment.
\end{itemize}
\end{frame}
\end{document}

在此处输入图片描述

相关内容