我尝试在一个框架中并排呈现两个概念。我希望每个项目都垂直对齐。下面是一个它们未对齐的示例。
\begin{frame}{An Example of using columns in beamer}
\begin{columns}
\begin{column}{0.48\textwidth}
\color{red}\rule{\linewidth}{4pt}
foo
\begin{itemize}
\item this is line 1 of foo
\item this is line 2 of foo which is long
\item this is line 3 of foo
\end{itemize}
\end{column}
\begin{column}{0.48\textwidth}
\color{blue}\rule{\linewidth}{4pt}
bar
\begin{itemize}
\item this is line 1 of bar
\item this is line 2 of bar
\item need this line to be aligned with line 3 of foo
\end{itemize}
\end{column}
\end{columns}
\end{frame}
答案1
一种方法是在两列中添加一些幻影文本,以便每个项目符号“占用”相同数量的行:
笔记:
- 还添加了
[t]
顶部对齐列
代码:
\documentclass{beamer}
\begin{document}
\begin{frame}{An Example of using columns in beamer}
\begin{columns}
\begin{column}[t]{0.48\textwidth}
\color{red}\rule{\linewidth}{4pt}
foo
\begin{itemize}
\item this is line 1 of foo
\item this is line 2 of foo which is long
\item this is line 3 of foo
\end{itemize}
\end{column}
\begin{column}[t]{0.48\textwidth}
\color{blue}\rule{\linewidth}{4pt}
bar
\begin{itemize}
\item this is line 1 of bar
\item this is line 2 of bar \phantom{which is long}
\item need this line to be aligned with line 3 of foo
\end{itemize}
\end{column}
\end{columns}
\end{frame}
\end{document}
答案2
以下是通过两个新命令解决的解决方案:\parallelcontent
和\parallelitem
。
\documentclass{beamer}
\newcommand\parallelcontent[2]{
\begin{columns}[t]
\column{0.48\textwidth} #1
\column{0.48\textwidth} #2
\end{columns}
}
\newcommand\parallelitem[2]{
\parallelcontent
{\begin{itemize} \item #1 \end{itemize}}
{\begin{itemize} \item #2 \end{itemize}}
}
\begin{document}
\begin{frame}{An Example of using columns in beamer}
\parallelcontent
{\textcolor{red}{\rule{\linewidth}{4pt} foo}}
{\textcolor{blue}{\rule{\linewidth}{4pt} bar}}
\parallelitem
{this is line 1 of foo}
{this is line 1 of bar}
\parallelitem
{this is line 2 of foo which is long}
{this is line 2 of bar}
\parallelitem
{this is line 3 of foo}
{need this line to be aligned with line 3 of foo}
\end{frame}
\end{document}