![排版优化问题](https://linux22.com/image/354408/%E6%8E%92%E7%89%88%E4%BC%98%E5%8C%96%E9%97%AE%E9%A2%98.png)
我对 LaTeX 还不太熟悉,想排版一个优化问题。我在https://jcnts.wordpress.com/2009/11/11/formatting-optimization-problems-with-latex/:
唯一的问题是它没有为每行显示一个新的方程编号。所以我修改了它,现在得到了方程编号,但现在最小值/受制于和成本函数/约束之间存在巨大差距。是否有可能将两种方法的优点结合起来?
两种方法的代码:
\documentclass{report}
\usepackage{amsmath}
\usepackage{hyperref}
\newcommand{\norm}[1]{\lVert#1\rVert_2}
\begin{document}
my approach
\begin{subequations}
\begin{align}
&\underset{x}{\text{min}}
&&\norm{f(x)}^2\label{eq:optProb}\\
&\text{subject to}
&&\alpha \geq 0,\label{eq:constraint1}\\
&&&\beta \geq 0.\label{eq:constraint2}
\end{align}
\end{subequations}
%
%
approach from\\ \url{https://jcnts.wordpress.com/2009/11/11/formatting-optimization-problems-with-latex/}:
\begin{equation}
\begin{aligned}
&\underset{x}{\text{min}}&&\norm{f(x)}^2\\
&\text{subject to} &&\alpha \geq 0,\\
&&&\beta \geq 0.
\end{aligned}
\end{equation}
\end{document}
答案1
只需align
改为alignat
:
\documentclass{report}
\usepackage{amsmath}
\newcommand{\norm}[1]{\lVert#1\rVert_2}
\begin{document}
\begin{subequations}
\begin{alignat}{2}
&\!\min_{x} &\qquad& \norm{f(x)}^2\label{eq:optProb}\\
&\text{subject to} & & \alpha \geq 0,\label{eq:constraint1}\\
& & & \beta \geq 0.\label{eq:constraint2}
\end{alignat}
\end{subequations}
\end{document}