如何强制多层数学环境为列宽

如何强制多层数学环境为列宽

我在一篇两栏文章中有一个多层数学环境。方程式超出了列宽。我该如何避免这种情况?以下是我的 MWE。

PS 我已经加载了 breqn 包,但我不知道如何在这种环境下使用它。

\documentclass[journal]{IEEEtran}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsfonts, amsmath, amsthm, amssymb}
\usepackage{breqn}

%================%
%  New Commands  %
%================%
% Bold math variables
\newcommand{\fb}{\mathbf{f}}
\newcommand{\xb}{\mathbf{x}}
\newcommand{\ub}{\mathbf{u}}
\newcommand{\chib}{\boldsymbol{\chi}}

\begin{document}

\begin{gather*}\label{eq:unscented_problem_formulation}
    \xb_i := (x_i,y_i,h_i,v_i,\gamma_i,\sigma_i,\phi_i) \in \mathbb{R}^7 \qquad 
    \ub := (u_\phi,u_L) \in \mathbb{R}^2 \qquad \\
    \chib_i \in supp(\varepsilon_T,\phi_T) \qquad
    \forall\,i=1,\dots,N_\chi \\  
    \begin{array}{l l}
        \textsf{Min}   
        & J[\xb(\cdot),t_f] := \displaystyle \sum_{i=1}^{N_\chi}w_i\left[(\gamma_i(t_f) - \overline{\gamma}_f)^2 + (\sigma_i(t_f) - \overline{\sigma}_f)^2\right] \\
        \textsf{s.t.} 
        & \dot{\xb}_1 = \fb(\xb_1,\ub,t) \\
        & \vdots \\
        & \dot{\xb}_{N_\chi} = \fb(\xb_{N_\chi},\ub,t) \\
        &\xb_i(t_0) = (0\text{ m},0\text{ m},1\text{ m},1\text{ m/s},0\text{ rad},0\text{ rad},0\text{ rad}) \qquad \forall\,i=1,\dots,N_\chi. \\
        & (t_0,t_f) = (0,1) \text{ s} \\
        & \displaystyle \sum_{i=1}^{N_\chi}w_i\gamma_i(t_f) = \overline{\gamma}_f = 0 \\
        & \displaystyle \sum_{i=1}^{N_\chi}w_i\sigma_i(t_f) = \overline{\sigma}_f = 0 \\
        & u_\phi \in [-4\pi,4\pi] \text{ rad} \\
        & u_L    \in [-10000,10000] \text{ N} \\
        & \varepsilon_T\, \sim\, \mathcal{N}(0.001,0.001^2) \text{ rad} \\
        & \phi_T\, \sim\, \mathcal{U}[0,2\pi] \text{ rad} 
    \end{array}
\end{gather*}

\end{document}

答案1

我认为将所有数学术语放在一个gather*环境中没有任何用处。我建议在前面插入一个换行符,\forall\ i=1,\dots,N_{\chi}以使材料适合列的宽度。帮自己一个忙,加载希尼奇包,以访问其\unit\qty语句。而且,由于该文档使用了 Times Roman 文本字体克隆,因此您可能需要加载包newtxtmath以获取与文本字体匹配的数学字体。

在此处输入图片描述

\documentclass[journal]{IEEEtran}
\usepackage{graphicx} 
\usepackage{mathtools, amsthm, amssymb}
\usepackage{newtxtext, newtxmath} % Times Roman clone text and math fonts
\DeclareMathOperator{\rad}{rad}
\DeclareMathOperator{\supp}{supp}
\usepackage[per-mode=symbol]{siunitx} % for \qty and \unit macros
\usepackage{lipsum} % for filler text

\newcommand{\fb}{\mathbf{f}}
\newcommand{\xb}{\mathbf{x}}
\newcommand{\ub}{\mathbf{u}}
\newcommand{\chib}{\boldsymbol{\chi}}

\begin{document}

\begin{gather*}%  \label{eq:unscented_problem_formulation}
\begin{aligned}
    &\xb_i \coloneqq (x_i,y_i,h_i,v_i,\gamma_i,\sigma_i,\phi_i) \in \mathbb{R}^7 \\ 
    &\ub \coloneqq (u_\phi,u_L) \in \mathbb{R}^2  \\
    &\chib_i \in \supp(\varepsilon_T,\phi_T) \quad
    \forall\,i=1,\dots,N_{\chi} 
\end{aligned} \\[\jot]
\textsf{Min}\, J[\xb(\cdot),t_f] 
  \coloneqq \displaystyle \sum_{i=1}^{N_{\chi}}w_i
  \bigl[(\gamma_i(t_f) - \bar{\gamma}_f)^2 
    + (\sigma_i(t_f) - \bar{\sigma}_f)^2 \bigr]
\end{gather*}
such that
\[
\begin{aligned}
    &\dot{\xb}_1 = \fb(\xb_1,\ub,t) \\
    &\,\,\vdots \\
    &\dot{\xb}_{N_{\chi}} = \fb(\xb_{N_{\chi}},\ub,t) \\
    &\xb_i(t_0) = (\qty{0}{\meter},\qty{0}{\meter},\qty{1}{\meter}, 
                   \qty{1}{\meter\per\second}, \qty{0}{\rad}, 
                   \qty{0}{\rad}, \qty{0}{\rad}) \\
    &\qquad\qquad \forall\ i=1,\dots,N_{\chi}. \\
    &(t_0,t_f) = (\qty{0}{\second},\qty{1}{\second}) \\
    &\sum\nolimits_{i=1}^{N_{\chi}} w_i\gamma_i(t_f) 
        = \bar{\gamma}_f = 0 \\[\jot]
    &\sum\nolimits_{i=1}^{N_{\chi}} w_i\sigma_i(t_f) 
        = \bar{\sigma}_f = 0 \\
    &u_\phi \in [-4\pi,4\pi]\,\unit{\rad} \\
    &u_L    \in [-10000,10000]\, \unit{\newton} \\
    &\varepsilon_T \sim \mathcal{N}(0.001,0.001^2)\,\unit{\rad} \\
    &\phi_T \sim \mathcal{U}[0,2\pi]\,\unit{\rad}
\end{aligned}
\]

\lipsum % filler text

\end{document}

答案2

我想保持原始格式与论文的其余部分一致(抱歉我之前没有提到这一点)。我从 Mico 和 Celdor 那里得到了一个提示,并通过在数组环境中添加另一行来分解长表达式。我修改后的代码如下:

\documentclass[journal]{IEEEtran}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsfonts, amsmath, amsthm, amssymb}
\usepackage{breqn}

%================%
%  New Commands  %
%================%
% Bold math variables
\newcommand{\fb}{\mathbf{f}}
\newcommand{\xb}{\mathbf{x}}
\newcommand{\ub}{\mathbf{u}}
\newcommand{\chib}{\boldsymbol{\chi}}

\begin{document}

\begin{gather*}\label{eq:unscented_problem_formulation}
\xb_i := (x_i,y_i,h_i,v_i,\gamma_i,\sigma_i,\phi_i) \in \mathbb{R}^7 \qquad 
\ub := (u_\phi,u_L) \in \mathbb{R}^2 \qquad \\
\chib_i \in supp(\varepsilon_T,\phi_T) \qquad
\forall\,i=1,\dots,N_\chi \\  
\begin{array}{l l}
    \textsf{Min}   
    & J[\xb(\cdot),t_f] := \displaystyle \sum_{i=1}^{N_\chi}w_i\left[(\gamma_i(t_f) - \overline{\gamma}_f)^2 + (\sigma_i(t_f) - \overline{\sigma}_f)^2\right] \\
    \textsf{s.t.} 
    & \dot{\xb}_1 = \fb(\xb_1,\ub,t) \\
    & \vdots \\
    & \dot{\xb}_{N_\chi} = \fb(\xb_{N_\chi},\ub,t) \\
    & \xb_i(t_0) = (0\text{ m},0\text{ m},1\text{ m},1\text{ m/s},0\text{ rad},0\text{ rad},0\text{ rad}) 
    & \qquad \forall\,i=1,\dots,N_\chi. \\
    & (t_0,t_f) = (0,1) \text{ s} \\
    & \displaystyle \sum_{i=1}^{N_\chi}w_i\gamma_i(t_f) = \overline{\gamma}_f = 0 \\
    & \displaystyle \sum_{i=1}^{N_\chi}w_i\sigma_i(t_f) = \overline{\sigma}_f = 0 \\
    & u_\phi \in [-4\pi,4\pi] \text{ rad} \\
    & u_L    \in [-10000,10000] \text{ N} \\
    & \varepsilon_T\, \sim\, \mathcal{N}(0.001,0.001^2) \text{ rad} \\
    & \phi_T\, \sim\, \mathcal{U}[0,2\pi] \text{ rad} 
\end{array}
\end{gather*}

\end{document}

答案3

以下是格式化这个长表达式的一种方法。

我想指出的是,LaTeX 有很多数学环境,包括它们的内部变体,你可以嵌套它们,它们可以让你格式化和组织非常复杂的表达式。这些都在包的文档中进行了解释数学。我还建议阅读数学工具,这将加载数学并增加了许多改进和附加解决方案。

代码

\documentclass[journal]{IEEEtran}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsthm, amssymb}
\usepackage{breqn}

\usepackage{kantlipsum}

% ================%
% New Commands  %
% ================%
% Bold math variables
\newcommand{\fb}{\mathbf{f}}
\newcommand{\xb}{\mathbf{x}}
\newcommand{\ub}{\mathbf{u}}
\newcommand{\chib}{\boldsymbol{\chi}}

\begin{document}
\kant[1][1]
\begin{gather*}
  \begin{aligned}
    & \xb_i := (x_i,y_i,h_i,v_i,\gamma_i,\sigma_i,\phi_i) \in \mathbb{R}^7 \\
    & \ub := (u_\phi,u_L) \in \mathbb{R}^2
  \end{aligned} \\
  \chib_i \in \operatorname{supp}(\varepsilon_T,\phi_T, \ i=1,\dots,N_\chi \\
  \begin{aligned}
    & \operatorname{Min} J[\xb(\cdot),t_f :={} \sum_{i=1}^{N_\chi}w_i \bigl[ (\gamma_i(t_f) - \overline{\gamma}_f)^2 + (\sigma_i(t_f) - \overline{\sigma}_f)^2 \bigr] \\
    & \footnotesize
      \qquad\textsf{s.t.}\ \begin{aligned}[t]
                             & \dot{\xb}_1 = \fb(\xb_1,\ub,t) \\
                             & \vdots \\
                             & \dot{\xb}_{N_\chi} = \fb(\xb_{N_\chi},\ub,t) \\
                             & xb_i(t_0) = (0\text{ m},0\text{ m},1\text{ m},1\text{ m/s},0\text{ rad},0\text{ rad},0\text{ rad}) \\
                             & \qquad\forall\,i=1,\dots,N_\chi. \\
                             & (t_0,t_f) = (0,1) \text{ s} \\
                             & \displaystyle \sum_{i=1}^{N_\chi}w_i\gamma_i(t_f) = \overline{\gamma}_f = 0 \\
                             & \displaystyle \sum_{i=1}^{N_\chi}w_i\sigma_i(t_f) = \overline{\sigma}_f = 0 \\
                             & u_\phi \in [-4\pi,4\pi] \text{ rad} \\
                             & u_L    \in [-10000,10000] \text{ N} \\
                             & \varepsilon_T\, \sim\, \mathcal{N}(0.001,0.001^2) \text{ rad} \\
                             & \phi_T\, \sim\, \mathcal{U}[0,2\pi] \text{ rad} 
                           \end{aligned}
  \end{aligned}
\end{gather*}

\kant[2-5]
\end{document}

和截图

在此处输入图片描述

相关内容