编译器显示“包 amsmath 错误:\begin{aligned} 仅允许在数学模式下使用。”我不明白为什么,因为“aligned”位于“方程式”内,而方程式本身就是数学模式。
\documentclass{article}
\usepackage{amsmath}
\usepackage{adjustbox}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{adjustbox}{max totalsize={.4\textwidth},center}
\begin{equation*}
\textnormal{ Min} \qquad
\begin{aligned}
&36x_{11}+32x_{12}+33x_{13}+19x_{14}+\\
&10x_{21}+\; \: 8x_{22}+\; \: 7x_{23}+20x_{24}+\\
&12x_{31}+17x_{32}+16x_{33}+29x_{34}+\\
&23x_{41}+15x_{42}+16x_{43}+28x_{44}
\end{aligned}
\end{equation*}
\end{adjustbox}
\vskip 5mm
\begin{adjustbox}{max totalsize={.4\textwidth},center}
\begin{equation*}
\textnormal{ s.a.} \qquad
\begin{aligned}
&\sum_{i=1}^{4}x_{ij}=b_i \qquad \forall 1=1,2,3,4\\
&\sum_{i=1}^{4}x_{ij}=b_j \qquad \forall j=1,2,3,4\\
&x_{ij}\ge 0\\
&b_1=3\quad b_2=2 \quad b_3=1 \quad b_4=1
\end{aligned}
\end{equation*}
\end{adjustbox}
\end{document}
答案1
使用aligned
环境,此代码基于优化专用包optidef
,完美适合单列:
\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{optidef}
\usepackage{lipsum}
\begin{document}
\lipsum[11]
\begin{mini*}|s|
{}{\begin{aligned}[t]
&36x_{11}+32x_{12}+33x_{13}+19x_{14}+\\
&10x_{21}+\; \: 8x_{22}+\; \: 7x_{23}+20x_{24}+\\
&12x_{31}+17x_{32}+16x_{33}+29x_{34}+\\
&23x_{41}+15x_{42}+16x_{43}+28x_{44}
\end{aligned}}{}{}
\addConstraint{\sum_{i=1}^{4}x_{ij}}{=b_i\quad \forall i=1,2,3,4}
\addConstraint{\sum_{i=1}^{4}x_{ij}}{=b_j\quad\forall j=1,2,3,4}
\addConstraint{x_{ij}}{\ge 0}{}
\addConstraint{b_1=3\quad b_2}{=2 \quad b_3 =1 \quad b_4=1}{}
\end{mini*}
\end{document}
答案2
您可以使用包\medmath
中的宏获得所需的结果nccmath
:
\documentclass{article}
\usepackage{nccmath}
\usepackage{adjustbox}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
Without reducing equations size:
\[
\text{Min} \quad
\begin{aligned}[t]
& 36x_{11}+32x_{12}+33x_{13}+19x_{14}+ \\
& 10x_{21}+\hphantom{3}8x_{22}+ \hphantom{3}7x_{23}+20x_{24}+ \\
& 12x_{31}+17x_{32}+16x_{33}+29x_{34}+ \\
& 23x_{41}+15x_{42}+16x_{43}+28x_{44}
\end{aligned}
\]
With \verb+\adjustbox+:
\[\begin{adjustbox}{max totalsize={.4\textwidth},center}$\displaystyle
\text{Min} \quad
\begin{aligned}[t]
& 36x_{11}+32x_{12}+33x_{13}+19x_{14}+ \\
& 10x_{21}+\hphantom{3}8x_{22}+ \hphantom{3}7x_{23}+20x_{24}+ \\
& 12x_{31}+17x_{32}+16x_{33}+29x_{34}+ \\
& 23x_{41}+15x_{42}+16x_{43}+28x_{44}
\end{aligned}$
\end{adjustbox}
\]
With \verb+\medmath+ from the \verb+nccmath+:
\[\medmath{
\text{Min} \quad
\begin{aligned}[t]
& 36x_{11}+32x_{12}+33x_{13}+19x_{14}+ \\
& 10x_{21}+\hphantom{3}8x_{22}+ \hphantom{3}7x_{23}+20x_{24}+ \\
& 12x_{31}+17x_{32}+16x_{33}+29x_{34}+ \\
& 23x_{41}+15x_{42}+16x_{43}+28x_{44}
\end{aligned}}
\]
\end{document}