LaTeX/Beamer、柱环境。叠加层的水平对齐

发布于 2024-08-06 07:34:22 字数 913 浏览 9 评论 0原文

我正在尝试使用 beamer 准备演示文稿。我想要两列来演练一些代数运算。左边是对所采取步骤的解释,右边是结果。

\documentclass{beamer}
\begin{document}

   \begin{frame}[t]
   Not in a column
   \begin{columns}[t]
      \begin{column}{0.5\textwidth}
            \only<2->{Some text}

            \only<3->{
                      Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                     }
      \end{column}
      \begin{column}{0.5\textwidth}
         \only<2->
         {
         \begin{equation}
            E = mc^2
         \end{equation}
         }

         \only<3->
         {
         \begin{equation}
            F = ma
         \end{equation}
         }
      \end{column}
   \end{columns}
   \end{frame}
\end{document}

这里有一些 LaTeX 可以做到这一点(用垃圾词和方程)。编译时,文本和数学彼此不一致。我真的不希望它们是这样,因为 LaTeX 会将文本单独放置在每一列中,而不关心其他框架。

有谁对如何实现我想要的结果有任何想法。我根本不致力于专栏,但我致力于方程式数字。

I am trying to prepare a presentation using beamer. I want to have two columns that walkthrough some algebraic manipulations. On the left an explanation of the steps taken, on the right the results.

\documentclass{beamer}
\begin{document}

   \begin{frame}[t]
   Not in a column
   \begin{columns}[t]
      \begin{column}{0.5\textwidth}
            \only<2->{Some text}

            \only<3->{
                      Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                     }
      \end{column}
      \begin{column}{0.5\textwidth}
         \only<2->
         {
         \begin{equation}
            E = mc^2
         \end{equation}
         }

         \only<3->
         {
         \begin{equation}
            F = ma
         \end{equation}
         }
      \end{column}
   \end{columns}
   \end{frame}
\end{document}

And here's some LaTeX which does that (with junk words and equations). When this is compiled the text and maths are not aligned with each other. I wouldn't really expect them to be either as LaTeX will position the text in each column individually, not caring about the other frames.

Does anyone have any ideas on how to achieve the result I am after. I'm not committed to the columns at all, but I am committed to the equation numbers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷夜 2024-08-13 07:34:22

通过编号获得对齐方程的首选方法是 amsmath 包的 align 环境。请参阅其文档以获取相关帮助。这很简单,就像:

\begin{align}
     f(x) & = \cos^2 x \\
     g(x) & = \sin^2 x
\end{align}

有很多变体试图满足大多数可能的方程对齐需求(再次,请查看文档)。

至于你的两列证明格式,我不确定最好的方法。一种快速而肮脏的方法是将其添加为环境中的第二列,例如:

\begin{align}
     f(x) & = \cos^2 x & \text{this is the first function} \\
     g(x) & = \sin^2 x & \text{this is the second function} 
\end{align}

但这对于多行解释没有好处,并将编号放在文本的右侧。我会尝试想出一种方法(一种不涉及大量自定义环境的方法,因为肯定有人以前这样做过)。

编辑:作为一个起点,这[有点]有效:

您不能在对齐环境中进行任何对齐( & 混淆了事情),并且存在一些垂直对齐问题 - 对齐环境本身在上方和下方进行填充,以及右侧单元格中的文本。不过,也许它正朝着好的方向发展!

\begin{tabular}{p{3 in}|l}
\begin{align} f(x) = \sin^2 x \end{align} & 
this is the first equation \\
\begin{align} g(x) = \cos^2 x \end{align} & 
this is the second equation
\end{tabular}

The preferred way to get aligned equations with numbering is amsmath package's align environment. See its documentation for help with that. It's quite simple, something like:

\begin{align}
     f(x) & = \cos^2 x \\
     g(x) & = \sin^2 x
\end{align}

There are a lot of variations trying to cover most conceivable equation alignment needs (again, check out the documentation).

As for your two-column proof format, I'm not as sure about the best way. A quick and dirty way would be to add it as a second column within the environment, something like:

\begin{align}
     f(x) & = \cos^2 x & \text{this is the first function} \\
     g(x) & = \sin^2 x & \text{this is the second function} 
\end{align}

but this is no good for multi-line explanation, and puts the numbering to the right of the text. I'll try and think of a way (one that doesn't involve a lot of custom-defined environments, since surely someone's done this before).

Edit: As a starting point, this [sort of] works:

You can't do any alignment within the align environment (the & confuses things), and there are some vertical alignment issues - the align environment pads itself above and below, and the text in the right-hand cell. Maybe it's heading in a good direction, though!

\begin{tabular}{p{3 in}|l}
\begin{align} f(x) = \sin^2 x \end{align} & 
this is the first equation \\
\begin{align} g(x) = \cos^2 x \end{align} & 
this is the second equation
\end{tabular}
油饼 2024-08-13 07:34:22

通常你会使用amsmath的align或align*环境,但不幸的是它与beamer不能很好地配合(出于根本原因,没有人愿意修复)。

Beamer 用户指南有一个关于第 106 页的这个完全符合您所做的操作。显然该文档中也描述了一种解决方法。

Usually you'd use amsmath's align or align* environment, but unfortunately it doesn't play nicely with beamer (for fundamental reasons that nobody wants to fix).

The Beamer user guide has a section on this at page 106 that does exactly what you've done. Apparently there's a workaround described in that document too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文