![如何将多行方程拟合到列宽](https://linux22.com/image/471725/%E5%A6%82%E4%BD%95%E5%B0%86%E5%A4%9A%E8%A1%8C%E6%96%B9%E7%A8%8B%E6%8B%9F%E5%90%88%E5%88%B0%E5%88%97%E5%AE%BD.png)
我有一个包含多行的方程,超出了列宽。我想修改方程以适应列宽而不分割线。我看过这个问题如何用数学公式拟合线宽,但我不相信它能解决我的问题。我也尝试过 resizebox,但没有成功。这是一个最低限度的工作示例。
\documentclass[journal]{IEEEtran}
\usepackage{amsfonts, amsmath, amsthm, amssymb}
\usepackage{lipsum}
\usepackage{graphicx}
%================%
% New Commands %
%================%
% Bold math variables
\newcommand{\fb}{\mathbf{f}}
\newcommand{\xb}{\mathbf{x}}
\newcommand{\hb}{\mathbf{h}}
\newcommand{\ub}{\mathbf{u}}
\newcommand{\eb}{\mathbf{e}}
\newcommand{\pb}{\mathbf{p}}
\newcommand{\qb}{\mathbf{q}}
\newcommand{\gb}{\mathbf{g}}
\newcommand{\Xb}{\mathbf{X}}
\newcommand{\Zb}{\mathbf{Z}}
\newcommand{\lambdab}{\boldsymbol{\lambda}}
\newcommand{\nub}{\boldsymbol{\nu}}
\newcommand{\mub}{\boldsymbol{\mu}}
\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},2000\text{ m},40\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.2) \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.003,0.0015^2) \text{ rad} \\
& \phi_T\, \sim\, \mathcal{U}[0,2\pi] \text{ rad}
\end{array}
\end{gather*}
\lipsum
\end{document}
理想情况下,我希望“Min”和“st”在列宽内尽可能靠左。我还希望“Min”和“st”后面的表达式对齐。有什么建议吗?
答案1
以下是一些建议(无特定顺序):
由于主文档字体为 Times Roman,因此加载
newtxtext
和newtxmath
包以确保文本和数学字体的一致性使用
aligned
环境排版从第三行开始的所有内容加载
siunitx
包并学习使用\unit
和\qty
排版科学单位及其相关数量。由于
gather*
环境不显示方程式编号,更不用说增加方程式编号了,因此指令\label{eq:unscented_problem_formulation}
将尝试将标签字符串与最近可能增加的任何计数器相关联。这不是您想要的,对吗?
\documentclass[journal]{IEEEtran}
\usepackage{%amsfonts, % is loaded by amssymb
%amsmath, % is loaded by mathtools
mathtools, % for \coloneqq macro
amsthm,
amssymb,
array} % for \newcolumntype macro
\newcolumntype{C}{>{{}}c<{{}}}
\DeclareMathOperator{\supp}{supp}
\newcommand\tf{t_{\mkern-2mu f}} % snug up the subscript "f"
\usepackage{lipsum,graphicx}
\usepackage{newtxtext,newtxmath} % Times Roman text and math fonts
\newcommand{\fb}{\mathbf{f}}
\newcommand{\xb}{\mathbf{x}}
\newcommand{\hb}{\mathbf{h}}
\newcommand{\ub}{\mathbf{u}}
\newcommand{\eb}{\mathbf{e}}
\newcommand{\pb}{\mathbf{p}}
\newcommand{\qb}{\mathbf{q}}
\newcommand{\gb}{\mathbf{g}}
\newcommand{\Xb}{\mathbf{X}}
\newcommand{\Zb}{\mathbf{Z}}
\newcommand{\lambdab}{\boldsymbol{\lambda}}
\newcommand{\nub}{\boldsymbol{\nu}}
\newcommand{\mub}{\boldsymbol{\mu}}
\newcommand{\chib}{\boldsymbol{\chi}}
\usepackage[per-mode=symbol]{siunitx} % for \unit and \qty macros
\begin{document}
\begin{gather*} %%%%\label{eq:unscented_problem_formulation}
\xb_i \coloneqq (x_i,y_i,h_i,v_i,\gamma_i,\sigma_i,\phi_i) \in \mathbb{R}^7
\qquad
\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} \\
\begin{aligned}
\textsf{Min}\
& J[\xb(\cdot),\tf] \coloneqq \sum_{i=1}^{N_{\chi}}
w_i\bigl[(\gamma_i(\tf) - \bar{\gamma}_f)^2
+ (\sigma_i(\tf) - \bar{\sigma}_f)^2\bigr] \\
\textsf{s.t.}\ \
& \setlength\arraycolsep{0pt}
\begin{array}[t]{ r C l } % horizontal alignment on "=" symbols
\dot{\xb}_1 &=& \fb(\xb_1,\ub,t) \\
&\vdots& \\
\dot{\xb}_{N_{\chi}} &=& \fb(\xb_{N_{\chi}},\ub,t)
\end{array} \\
&\xb_i(t_0) = (\qty{0}{\meter}, \qty{0}{\meter},
\qty{2000}{\meter}, \qty{40}{\meter\per\second},
\qty{0}{rad}, \qty{0}{rad}, \qty{0}{rad}) \\
&\qquad\quad \forall\ i=1,\dots,N_{\chi}. \\
& (t_0,\tf) = (0,1.2)\,\unit{\second} \\
& {\sum\nolimits_{i=1}^{N_{\chi}}}w_i\gamma_i(\tf) = \bar{\gamma}_f = 0 \\
& {\sum\nolimits_{i=1}^{N_{\chi}}}w_i\sigma_i(\tf) = \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.003,0.0015^2)\,\unit{rad} \\
& \phi_T\sim \mathcal{U}[0,2\pi]\,\unit{rad}
\end{aligned}
\end{gather*}
\lipsum[1-5]
\end{document}