在 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}