如何將1下的加號對齊?

如何將1下的加號對齊?

代碼:

\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

這是一個基於您的設定的解決方案,透過在第 2 行的\phantom{{}=1}第一個符號之前插入來工作。+

無論如何,我認為對齊兩個符號並不那麼重要+。在我看來,簡單的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\rights 替換為\mleft\mrights,但您可以將它們留在這裡。我個人也會加入細空格來分隔功能(請參閱第二個版本)。

相關內容