请参阅底部以了解 touhami 反馈后更新的 MWE 和更多分析。
我看到的问题是,itemize
投影仪顶部的环境column
(columns
具有 [t] 对齐)引入了一个空行。我试图将itemize
一列中的行与另一列中的文本行对齐,因此我更改了相关参数(\topsep
和\itemsep
)并修改了投影仪类中的一些代码。但是,问题不是由这样的修改引起的;事实上,如果我在序言中注释这些行(参见 MWE),效果仍然存在。我将它们保留在最小的示例中,以便很明显插入的垂直空间恰好对应一行。我可以通过在\vspace{-\baselineskip}
每个出现此问题的幻灯片的列开头插入来修复垂直空间,但我想知道是否有办法在演示文稿中全局修复它。
一些评论:
- 如果
columns
将对齐方式改为 [T],垂直空间会减少,但两列中的行不再对齐。 - 仅当
itemize
环境位于列顶部时才会发生这种情况:如果在环境之前添加了一些文本,则不会插入垂直空间并且行会对齐。 - 列的顺序无关紧要:如果
itemize
环境位于第一个列,也会出现问题。
一个最小的工作示例:
\documentclass{beamer}
%%% These lines are a modified version of the code from the beamer
%%% class (file beamerbaselocalstructure.sty). If they are commented
%%% out, the effect is still present\makeatletter
\makeatletter
\def\@listi{
\leftmargin\leftmargini
\topsep 0pt
\parsep 0pt
\itemsep 0pt
}
\let\@listI\@listi
\makeatother
\begin{document}
\begin{frame}
% If this is changed to [T] the lines are not aligned
\begin{columns}[t]
\column{5cm}
This is some text only to show the alignment (or the lack of it)
between this column and the following one which starts with an
itemize environment.
\column{5cm}
%%% This vertical space corresponds to normal a text line, but
%%% only happens if the itemize environment is at the beginning of
%%% the column: indeed if we uncomment the next line, the items do
%%% not move.
% Something
%%% This is a manual workaround, but I'd prefer a global fix
% \vspace{-\baselineskip}
\begin{itemize}
\item First
\item Second
\item Third
\item Fourth
\end{itemize}
\end{columns}
\end{frame}
\end{document}
(编辑)对于T
对齐,问题也可以通过设置\partopsep
为零来解决,正如 Ignasi 在其评论中所建议的那样,但这不适用于t
对齐。然后,查看 touhami 的答案开头的两个对齐选项之间的差异,我不明白为什么要插入额外的垂直空间。似乎可以通过 来抑制它\notinterlineskip
,但为什么首先要插入它呢?
(更新)itemize
当环境位于 a 的顶部minipage
(beamer所基于的) 时,也会出现此问题column
。因此,显示此问题的另一个 MWE 如下:
\documentclass{beamer}
\makeatletter
\def\@listi{
\leftmargin\leftmargini
\topsep 0pt
\parsep 0pt
\itemsep 0pt
}
\let\@listI\@listi
\makeatother
\begin{document}
\begin{frame}
\begin{minipage}[t]{3cm}
This is a minipage with some text to show the issue.
\end{minipage}
\begin{minipage}[t]{5cm}
Text in the top line.
\begin{itemize}
\item An item.
\item A second item.
\end{itemize}
\end{minipage}
\vspace{3ex}
\begin{minipage}[t]{3cm}
This is a minipage with some text to show the issue.
\end{minipage}
\begin{minipage}[t]{5cm}
\begin{itemize}
\item Item in the top line.
\item A second item.
\end{itemize}
\end{minipage}
\end{frame}
\end{document}
如您所见,如果右侧小页面顶部有一行文本(第一种情况),则环境的行itemize
与左侧小页面中的行正确对齐。另一方面,如果环境itemize
位于小页面的顶部,则会插入一些垂直空间。经过进一步调查,我得出以下结论:
- 插入的垂直空间比第一个 MWE 中的要小,但如果我添加
\leavevmode
在前面\begin{itemize}
(如在 beamer 环境的定义中column
),它就变得相同了。 - 该问题是由 beamer 类引起的:如果
documentclass
更改为article
(并且frame
环境被删除)则不会插入垂直空间。 itemize
但是,这个问题似乎与类对环境的重新定义无关。如果我注释掉 240-265行中重新定义和beamer
的代码,投影仪项目标记会消失,但垂直空间保持不变。beamerbaselocalstructure.sty
\itemize
\enditemize
答案1
更新(仅一条评论)\column
从这段代码可以看出,问题与命令无关(minipage
在后面)。看来问题的根源是\itemize
(或更深层次的\list
)。
\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{minipage}[t]{.48\textwidth}
These lines are a modified version of the code from the beamer
class (file beamerbaselocalstructure.sty). If they are commented
out, the effect is still present
\end{minipage}
\hfill
\begin{minipage}[t]{.48\textwidth}%\vskip-1ex
%These lines are a modified versio
\begin{itemize}
\item First
\item Second
\item Third
\item Fourth
\end{itemize}
\end{minipage}
\end{frame}
\end{document}
这是一个解决方案。默认情况下
\define@key{beamer@col}{t}[true]{\def\beamer@colmode{t}\def\beamer@colalign{t}\def\beamer@colheadskip{}}
\define@key{beamer@col}{T}[true]{\def\beamer@colmode{T}\def\beamer@colalign{t}\def\beamer@colheadskip{\vskip-1ex\nointerlineskip}}
所以可以尝试
\define@key{beamer@col}{t}[true]{\def\beamer@colmode{t}\def\beamer@colalign{t}\def\beamer@colheadskip{\vskip-1ex\nointerlineskip}}
平均能量损失
\documentclass{beamer}
%%% These lines are a modified version of the code from the beamer
%%% class (file beamerbaselocalstructure.sty). If they are commented
%%% out, the effect is still present\makeatletter
\makeatletter
\define@key{beamer@col}{t}[true]{\def\beamer@colmode{t}\def\beamer@colalign{t}\def\beamer@colheadskip{\vskip-1ex\nointerlineskip}}
\def\@listi{
\leftmargin\leftmargini
\topsep 0pt
\parsep 0pt
\itemsep 0pt
}
\let\@listI\@listi
\makeatother
\begin{document}
\begin{frame}
% If this is changed to [T] the lines are not aligned
\begin{columns}[t]
\column{5cm}
This is some text only to show the alignment (or the lack of it)
between this column and the following one which starts with an
itemize environment.
\column{5cm}
% This vertical space corresponds to normal a text line, but
%%% only happens if the itemize environment is at the beginning of
%%% the column: indeed if we uncomment the next line, the items do
%%% not move.
% Something
%%% This is a manual workaround, but I'd prefer a global fix
% \vspace{-\baselineskip}
\begin{itemize}
\item First
\item Second
\item Third
\item Fourth
\end{itemize}
\end{columns}
\end{frame}
\end{document}