在我的总体文档中,我有许多子方程式,例如:
\documentclass[a4paper]{report}
\usepackage{mleftright}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
These two operators, which in turn map pairs of operators $ \mleft( \hat{A} ; \hat{B} \mright) $ onto another operator, are defined as:
\newline
\begin{subequations}
\begin{minipage}[t]{0.5\textwidth}
\begin{equation}
\label{DefComm}
\mleft[ \hat{A} ; \hat{B} \mright] \coloneqq \hat{A} \hat{B} - \hat{B} \hat{A}
\end{equation}
\end{minipage}\hfill
\begin{minipage}[t]{0.5\textwidth}
\begin{equation}
\label{DefAntiComm}
\text{and } \{ \hat{A} ; \hat{B} \} \coloneqq \hat{A} \hat{B} + \hat{B} \hat{A} \, ,
\end{equation}
\end{minipage}
\end{subequations}
\newline
\newline
\newline
respectively.
\end{document}
我希望 Latex/tex 能够自行完成间距,我只需指定哪些部分属于不同的子方程。这可能吗?照这样下去,我必须手动调整小页面的大小,而且文本间看起来也不好看。我希望结尾位于中心,并与括号 (1a) 和下一个方程等距。或者无论你对它应该是什么样子的建议是什么,但它看起来肯定不好看。
答案1
这里有一个建议,可以测量表达式的宽度并据此分配小页面的宽度。
\documentclass[a4paper]{report}
\usepackage{mleftright}
\usepackage{xfp}
\usepackage{mathtools}
\newcommand\SideBySideEquations[3][3em]{%
\setbox0\hbox{$\displaystyle#2$}%
\setbox1\hbox{$\displaystyle#3$}%
\par\noindent
\begin{minipage}[t]{\fpeval{(\wd0+#1)/(\wd0+\wd1+#1+#1)}\textwidth}
\begin{equation}
#2\vphantom{#3}
\end{equation}
\end{minipage}%
\begin{minipage}[t]{\fpeval{(\wd1+#1)/(\wd0+\wd1+#1+#1)}\textwidth}
\begin{equation}
#3\vphantom{#2}
\end{equation}
\end{minipage}\vskip\belowdisplayskip\par\noindent
}
\begin{document}
These two operators, which in turn map pairs of operators $ \mleft( \hat{A} ; \hat{B} \mright) $ onto another operator, are defined as
\begin{subequations}
\SideBySideEquations{%
\mleft[ \hat{A} ; \hat{B} \mright] \coloneqq \hat{A}\hat{B} - \hat{B} \hat{A}}{%
\text{and}\quad \{ \hat{A} ; \hat{B} \} \coloneqq \hat{A} \hat{B} + \hat{B} \hat{A}}
\end{subequations}
respectively.
Here is another example,
\begin{subequations}
\SideBySideEquations{%
\hat{A}}{%
\text{and}\quad \{ \hat{A} ; \hat{B} \} \coloneqq \hat{A} \hat{B} + \hat{B} \hat{A}}
\end{subequations}
and another one
\begin{subequations}
\SideBySideEquations{%
\mleft[ \hat{A} ; \hat{B} \mright] \coloneqq \hat{A}\hat{B} - \hat{B} \hat{A}}{%
\text{and}\quad \hat{A}}
\end{subequations}
and a normal equation
\begin{equation}
E=\hbar\omega\;.
\end{equation}
\end{document}
仅供记录:我个人不会使用这样的符号,但这只是个人意见。