公式文本标签未正确右对齐

公式文本标签未正确右对齐

这就是我所拥有的:

代码:

\documentclass[12pt]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\pgfpagesuselayout{resize to}[a4paper,landscape]
%\pgfpagesuselayout{2 on 1}[a4paper]
%\usetheme{Singapore}
\usetheme{Boadilla}
\usepackage{bm}
%\usefonttheme[?options?]{structuresmallcapsserif}
%\definecolor{beamer@blendedblue}{RGB}{203,140,55} % changed this
\definecolor{beamer@blendedblue}{RGB}{0,102,102} % changed this
%\definecolor{beamer@blendedblue}{RGB}{0,153,153} % changed this
\usefonttheme{professionalfonts} %To get the accents aligned correctly, albeit in Computer Modern Roman
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]
\begin{document}
    %-----------------------------------------------------------------New slide ----------------------------------------------------%
    \begin{frame}{Sample}
        \setcounter{equation}{200}
        \begin{align}
            &\hspace{-0.6cm}\mathcal{H}\left(\mathbf{x}, \mathbf{u}, \bm{\lambda}, t\right) = \mathcal{L}\left(\mathbf{x}, \mathbf{u}, t\right) + \bm{\lambda}^{\textrm{T}}\left(t\right)\mathbf{f}\left(\mathbf{x},\mathbf{u}, t\right).\quad \text{(Hamiltonian)}&\\
            &\hspace{-0.6cm}
            \begin{aligned}[b]
                \dot{\mathbf{x}}^*\left(t\right) &= \frac{\partial}{\partial\bm{\lambda}}\mathcal{H}\left(\mathbf{x}^*, \mathbf{u}^*,\bm{\lambda}^*, t\right),\\ &= \mathbf{f}\left(\mathbf{x}^*, \mathbf{u}^*, t\right).
            \end{aligned}\quad 
            \text{(State equations)}&\\
            &\hspace{-0.6cm}
            \begin{aligned}[b]
                \dot{\bm{\lambda}}^*\left(t\right) &= -\frac{\partial}{\partial\mathbf{x}}\mathcal{H}\left(\mathbf{x}^*, \mathbf{u}^*,\bm{\lambda}^*, t\right)\\
                &= -\left(\frac{\partial\mathbf{f}}{\partial\mathbf{x}}\right)^{\hspace{-0.1cm}\textrm{T}}\bm{\lambda}^* - \frac{\partial\mathcal{L}}{\partial\mathbf{x}}.
            \end{aligned}
            \quad \text{(Costate equations)}&
        \end{align}
    \end{frame}
\end{document}

输出:

在此处输入图片描述

从输出中我们可以看到,文本描述(如 (State equations) 和 (Costate equations))没有右对齐。如何修复这个问题?

顺便提一下,\hspace{-0.6cm}由于方程式标签,我已经对每一行都做了。有没有办法为方程式的所有三行编写一行代码?

答案1

文本标签右对齐:

\documentclass[12pt]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\usepackage{bm}
\definecolor{beamer@blendedblue}{RGB}{0,102,102}
\usefonttheme{professionalfonts}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]
\begin{document}
    \begin{frame}{Sample}
        \setcounter{equation}{200}
        \begin{alignat}{2}
            \mathcal{H}\left(\mathbf{x}, \mathbf{u}, \bm{\lambda}, t\right) & = \mathcal{L}\left(\mathbf{x}, \mathbf{u}, t\right) + \bm{\lambda}^{\textrm{T}}\left(t\right)\mathbf{f}\left(\mathbf{x},\mathbf{u}, t\right). \hspace{-8mm}
            & \text{(Hamiltonian)} \\
            \dot{\mathbf{x}}^*\left(t\right) 
                &= \frac{\partial}{\partial\bm{\lambda}}\mathcal{H}\left(\mathbf{x}^*, \mathbf{u}^*,\bm{\lambda}^*, t\right), \notag \\ 
                &= \mathbf{f}\left(\mathbf{x}^*, \mathbf{u}^*, t\right).
            & \text{(State equations)} \\
            \dot{\bm{\lambda}}^*\left(t\right) 
                &= -\frac{\partial}{\partial\mathbf{x}}\mathcal{H}\left(\mathbf{x}^*, \mathbf{u}^*,\bm{\lambda}^*, t\right) \notag \\
                &= -\left(\frac{\partial\mathbf{f}}{\partial\mathbf{x}}\right)^{\hspace{-0.1cm}\textrm{T}}\bm{\lambda}^* - \frac{\partial\mathcal{L}}{\partial\mathbf{x}}.
            & \text{(Costate equations)}
        \end{alignat}
    \end{frame}
\end{document}

文本标签左对齐:

\documentclass[12pt]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\usepackage{bm}
\definecolor{beamer@blendedblue}{RGB}{0,102,102}
\usefonttheme{professionalfonts}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]
\begin{document}
    \begin{frame}{Sample}
        \setcounter{equation}{200}
        \begin{alignat}{2}
            \hspace{-8mm}
            \mathcal{H}\left(\mathbf{x}, \mathbf{u}, \bm{\lambda}, t\right) & = \mathcal{L}\left(\mathbf{x}, \mathbf{u}, t\right) + \bm{\lambda}^{\textrm{T}}\left(t\right)\mathbf{f}\left(\mathbf{x},\mathbf{u}, t\right)\!. \ 
            && \text{(Hamiltonian)} \\
            \dot{\mathbf{x}}^*\left(t\right) 
                &= \frac{\partial}{\partial\bm{\lambda}}\mathcal{H}\left(\mathbf{x}^*, \mathbf{u}^*,\bm{\lambda}^*, t\right), \notag \\ 
                &= \mathbf{f}\left(\mathbf{x}^*, \mathbf{u}^*, t\right).
            && \text{(State equations)} \\
            \dot{\bm{\lambda}}^*\left(t\right) 
                &= -\frac{\partial}{\partial\mathbf{x}}\mathcal{H}\left(\mathbf{x}^*, \mathbf{u}^*,\bm{\lambda}^*, t\right) \notag \\
                &= -\left(\frac{\partial\mathbf{f}}{\partial\mathbf{x}}\right)^{\hspace{-0.1cm}\textrm{T}}\bm{\lambda}^* - \frac{\partial\mathcal{L}}{\partial\mathbf{x}}.
            && \text{(Costate equations)}\! 
        \end{alignat}
    \end{frame}
\end{document}

答案2

也许

在此处输入图片描述

\documentclass[12pt]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\pgfpagesuselayout{resize to}[a4paper,landscape]
%\pgfpagesuselayout{2 on 1}[a4paper]
%\usetheme{Singapore}
\usetheme{Boadilla}
\usepackage{bm}
%\usefonttheme[?options?]{structuresmallcapsserif}
%\definecolor{beamer@blendedblue}{RGB}{203,140,55} % changed this
\definecolor{beamer@blendedblue}{RGB}{0,102,102} % changed this
%\definecolor{beamer@blendedblue}{RGB}{0,153,153} % changed this
\usefonttheme{professionalfonts} %To get the accents aligned correctly, albeit in Computer Modern Roman
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]
\begin{document}
    %-----------------------------------------------------------------New slide ----------------------------------------------------%
    \begin{frame}{Sample}
        \setcounter{equation}{200}
\hspace*{-1cm}\begin{minipage}{\dimexpr\textwidth+1cm}
        \begin{alignat}{2}
  \mathcal{H}(\mathbf{x}, \mathbf{u}, \bm{\lambda}, t) 
&= \mathcal{L}(\mathbf{x}, \mathbf{u}, t) + \bm{\lambda}^{\textrm{T}}(t)\mathbf{f}(\mathbf{x},\mathbf{u}, t).
&\text{(Hamiltonian)}\\
                \dot{\mathbf{x}}^*(t)&
\begin{aligned}[t]
&= \frac{\partial}{\partial\bm{\lambda}}\mathcal{H}\left(\mathbf{x}^*, \mathbf{u}^*,\bm{\lambda}^*, t\right),\\ 
&= \mathbf{f}\left(\mathbf{x}^*, \mathbf{u}^*, t\right).
            \end{aligned}
&\text{(State equations)}\\
\dot{\bm{\lambda}}^*(t)&
            \begin{aligned}[t]
                &= -\frac{\partial}{\partial\mathbf{x}}\mathcal{H}\left(\mathbf{x}^*, \mathbf{u}^*,\bm{\lambda}^*, t\right)\\
                &= -\left(\frac{\partial\mathbf{f}}{\partial\mathbf{x}}\right)^{\hspace{-0.1cm}\textrm{T}}\bm{\lambda}^* - \frac{\partial\mathcal{L}}{\partial\mathbf{x}}.
            \end{aligned}
&\text{(Costate equations)}
        \end{alignat}
\end{minipage}
    \end{frame}
\end{document}

相关内容