代码:
\documentclass[12 pt,handout,notheorems]{beamer}
\usepackage{amsmath}
\usepackage{bm} %For making Greek letters bold
\usepackage{pgfpages}
\usepackage{mleftright}
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\renewcommand{\left}{\mleft}
\renewcommand{\right}{\mright}
\begin{document}
\begin{frame}
\setcounter{equation}{9}
\begin{equation}
\begin{aligned}
\mathcal{H}\left(\mathbf{x}\left(t\right), u\left(t\right), \bm{\lambda}\left(t\right) \right) ={}& 1 + \lambda_1\left(t\right)x_2\left(t\right) \\ &+ \lambda_2\left(t\right)\left[-g - \frac{k}{x_3\left(t\right)}u\left(t\right)\right]+ \lambda_3\left(t\right)u\left(t\right).
\end{aligned}
\end{equation}
\end{frame}
\end{document}
输出:
如何使第二行上的第一个加号与第一行上的 1 对齐?
答案1
\phantom{{}=1}
这是一个基于您的设置的解决方案,通过在第 2 行的第一个符号前插入来实现+
。它在对齐方面“有效”,但现在等式稍微太宽,无法让等式编号正确适应。
无论如何,我认为对齐这两个符号并不那么重要+
。我认为,简单的multline*
环境效果更好。
\documentclass[12pt,handout,notheorems]{beamer}
\usepackage{amsmath}
\usepackage{bm} %For making Greek letters bold
\usepackage{pgfpages}
\usepackage{mleftright}
\mleftright % no need to redefine '\left' and '\right'
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\begin{document}
\begin{frame}
\setcounter{equation}{9}
\begin{equation}
\begin{aligned}[b]
\mathcal{H}\left(\mathbf{x}\left(t\right),
u\left(t\right), \bm{\lambda}\left(t\right) \right)
&= 1 + \lambda_1\left(t\right)x_2\left(t\right) \\
&\phantom{{}=1}+ \lambda_2\left(t\right)\left[-g - \frac{k}{x_3\left(t\right)}u\left(t\right)\right]+ \lambda_3\left(t\right)u\left(t\right).
\end{aligned}
\end{equation}
\begin{multline}
%% also replaced all 10 [!] instances of '\left(t\right)' with '(t)'.
\mathcal{H}\left(\mathbf{x}(t), u(t), \bm{\lambda}(t) \right)
= 1 + \lambda_1(t)x_2(t) \\
+ \lambda_2(t)\left[-g - \frac{k}{x_3(t)}u(t)\right]+ \lambda_3(t)u(t).
\end{multline}
\end{frame}
\end{document}
答案2
aligned
您正在使用的 确实允许您这样做。
\documentclass[12 pt,handout,notheorems]{beamer}
\usepackage{amsmath}
\usepackage{bm} %For making Greek letters bold
\usepackage{pgfpages}
\usepackage{mleftright}
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\renewcommand{\left}{\mleft}
\renewcommand{\right}{\mright}
\begin{document}
\begin{frame}
\setcounter{equation}{9}
\begin{equation}
\begin{aligned}[b]
\mathcal{H}\left(\mathbf{x}\mleft(t\mright), u\mleft(t\mright),
\bm{\lambda}\mleft(t\mright) \right) = 1 &+ \lambda_1\mleft(t\mright)x_2\mleft(t\mright) \\
&+ \lambda_2\mleft(t\mright)\left[-g -\frac{k}{x_3\mleft(t\mright)}u\mleft(t\mright)\right]\\
&+ \lambda_3\mleft(t\mright)u\mleft(t\mright).
\end{aligned}
\end{equation}
or
\begin{equation}
\begin{aligned}[b]
\mathcal{H}\bigl(\mathbf{x}(t), u(t),
\bm{\lambda}(t) \bigr)
= 1 &+ \lambda_1(t)\,x_2(t) \\
&+ \lambda_2(t)\,\left[-g -\frac{k}{x_3(t)}u(t)\right]\\
&+ \lambda_3(t)\,u(t)\;.
\end{aligned}
\end{equation}
\end{frame}
\end{document}
您可以将对齐方式更改为[t]
或将其省略以移动方程编号。由于您正在加载,mleftright
我借此机会将一些\left
and \right
s 替换为\mleft
and \mright
s,但您可以在此处将其省略。我个人还会添加细空格来分隔函数(参见第二个版本)。