![如何在乳胶中的“对齐”环境中对齐方程式左侧项的中心](https://linux22.com/image/470613/%E5%A6%82%E4%BD%95%E5%9C%A8%E4%B9%B3%E8%83%B6%E4%B8%AD%E7%9A%84%E2%80%9C%E5%AF%B9%E9%BD%90%E2%80%9D%E7%8E%AF%E5%A2%83%E4%B8%AD%E5%AF%B9%E9%BD%90%E6%96%B9%E7%A8%8B%E5%BC%8F%E5%B7%A6%E4%BE%A7%E9%A1%B9%E7%9A%84%E4%B8%AD%E5%BF%83.png)
在 latex 中,我定义了一个名为“myequation”的新环境。这里,对于左侧项,它们的端点是对齐的。除了对齐“等于”符号外,我还想对齐左侧项的中心点而不是它们的端点。我该如何修改我的新环境来进行此更改。此外,如果我愿意,是否可以在某些步骤之间设置分页符,并将特定步骤放在框中?
\documentclass[12pt, arrowdel]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\def\l{\left}
\def\r{\right}
\def\d{\mathrm{d}}
\def\pt{(\tau)}
%To align the equation number below for multiple line of equations
\newenvironment{myequation}{%
\begin{equation}
\begin{aligned}[b]
}{%
\end{aligned}
\end{equation}
}
\begin{document}
\begin{myequation}
\dot{\rho} &= 3 \frac{\dot{a}}{a} \l(\rho + w \rho\r) =0\\
\d \ln \rho &= -3\; \d \ln a (1+w(a))\\
\int_{\rho_*}^{\rho} \d \ln \rho &= -3 \int_{a_*}^{a\pt}\d \ln a (1+w(a))\\
\rho\pt &= \rho_* e^{-3\int_{a_*}^{a\pt}\d \ln a (1+w(a))}
\end{myequation}
\end{document}
答案1
如果我修改示例以便它产生输出
\hfil
然后,您可以在所使用的前导码中添加一个额外内容,以aligned
使其居中,但结果实际上并不可用:
\documentclass[12pt]{article}
\usepackage{amsmath}
%To align the equation number below for multiple line of equations
\makeatletter
\newenvironment{myequation}{%
\renewcommand{\start@aligned}[2]{%eek centred lhs
\RIfM@\else
\nonmatherr@{\begin{\@currenvir}}%
\fi
\savecolumn@ % Assumption: called inside a group
\alignedspace@left
\ams@start@box{##1}\bgroup
\maxfields@##2\relax
\ifnum\maxfields@>\m@ne
\multiply\maxfields@\tw@
\let\math@cr@@@\math@cr@@@alignedat
\alignsep@\z@skip
\else
\let\math@cr@@@\math@cr@@@aligned
\alignsep@\minalignsep
\fi
\Let@ \chardef\dspbrk@context\@ne
\default@tag
\spread@equation % no-op if already called
\global\column@\z@
\ialign\bgroup
&\column@plus
\hfil
\strut@
$\m@th\displaystyle{####}$%
\hfil%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\tabskip\z@skip
&\column@plus
$\m@th\displaystyle{{}####}$%
\hfil
\tabskip\alignsep@
\crcr
\ams@return@opt@arg
}%
\begin{equation}
\begin{aligned}[b]
}{%
\end{aligned}
\end{equation}
}
\makeatother
\begin{document}
\begin{myequation}
\dot{\rho} &= 3 \frac{dot{a}}{a} (\rho + w \rho) =0\\
d \log \rho &= -3\; d \log a (1+w(a))\\
\int_{\rho_*}^{\rho} d \log \rho &= -3 \int_{a_*}^{ap}d \log a (1+w(a))\\
\rho p &= \rho_* e^{-3\int_{a_*}^{ap}d \log a (1+w(a))}
\end{myequation}
\end{document}