在排版偏微分方程的定解问题的时候遇到的问题,希望能够在一个大环境内实现,部分行居中对齐(类似于 gather
环境的罗列即可),部分行按照等号对齐(即 align
环境),且均需要逐行编号。
e.g.
\begin{equation}
\frac{\partial^2u}{\partial x^2}+\frac{\partial^2u}{\partial y^2}=0,
\end{equation}
\begin{align}
u|_{x=0}&=0,& u|_{x=a}&=0,\\
u|_{y=0}&=\varphi(x),& u|_{y=b}&=\psi(x).
\end{align}
align
环境中嵌套 gathered
环境,但是会产生位移\begin{align}
\begin{gathered}
\frac{\partial^2u}{\partial x^2}+\frac{\partial^2u}{\partial y^2}=0,
\end{gathered}\\
u|_{x=0}&=0,& u|_{x=a}&=0,\\
u|_{y=0}&=\varphi(x),& u|_{y=b}&=\psi(x).
\end{align}
求助各位大佬这个简单的公式效果应该如何实现呢?
可以换一个环境:
\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[width=210mm, height=297mm, left=2cm, right=2cm, top=2cm, bottom=2cm]{geometry}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{xcolor}
\usepackage{ctex}
\begin{document}
\begin{gather}
\frac{\partial^2 u}{\partial x^2}+\frac{\partial^2 u}{\partial y^2}=0 \\
\left.u\right|_{x=0}=0,\left.\quad u\right|_{x=a}=0, \\
\left.u\right|_{y=0}=\varphi(x),\left.\quad u\right|_{y=b}=\psi(x)
\end{gather}
\end{document}
效果如下:
但是同时希望下面两行能够按照等号对齐。
begin{gather}
frac{partial^2 u}{partial x^2}+frac{partial^2 u}{partial y^2} \
begin{array}{ll}
left.uright|_{x=0}=0, & left.uright|_{x=a}=0 \
left.uright|_{y=0}=varphi(x), & left.uright|_{y=b}=psi(x)
end{array}
end{gather}
begin{gather}
frac{partial^2 u}{partial x^2}+frac{partial^2 u}{partial y^2} \
begin{alignat}{3}
left.uright|_{x=0}=&0, qquad & left.uright|_{x=a}=&0 \
left.uright|_{y=0}=&varphi(x), qquad & left.uright|_{y=b}=&psi(x)
end{alignat}
end{gather}
Oh,
alignat
can be used insidegather
, I know it is a weird overleaf error: Weird overleaf error: Align used inside gather.Thank you all the same!