方程的错误对齐

方程的错误对齐

我有这个方程式,但出现了错误\right],但它在我的代码中。哪里出了问题?

我的代码:

\usepackage{amsmath}
\newcommand{\barU}{\bar{U}}
\newcommand{\barV}{\bar{V}}
\newcommand{\barW}{\bar{W}}
\newcommand{\barP}{\bar{P}}

\begin{equation}
    \begin{aligned}
     \label{eq:mx2}
     %-------------
     \frac{\partial\barU}{\partial t} + \frac{\partial u}{\partial t} &= -\left[\barU\left(\frac{\partial \barU}{\partial x} + 
     \frac{\partial u}{\partial x}\right) + u\left(\frac{\partial \barU}{\partial x} + 
     \frac{\partial u}{\partial x}\right) + \barV\left(\frac{\partial \barU}{\partial y} + 
     \frac{\partial u}{\partial y}\right) + v\left(\frac{\partial \barU}{\partial y} + 
     \frac{\partial u}{\partial y}\right) + \\
     &\barW\left(\frac{\partial \barU}{\partial z} + 
     \frac{\partial u}{\partial z}\right) + w\left(\frac{\partial \barU}{\partial z} + 
     \frac{\partial u}{\partial z}\right)\right] - \left(\frac{\partial \barP}{\partial x} + \frac{\partial p}{\partial x}\right) +
     \frac{1}{Re}(\nabla^2\barU + \nabla^2u)
    \end{aligned}
   \end{equation}

结果:

在此处输入图片描述

为什么\right]不出现?

答案1

确实 \right]缺少了,而且左括号和右括号不在同一行,所以你应该right.在第一行末尾添加一个,\left.在第二行开头添加一个。使用更简单\biggl[ ... \\ ...\biggr],尤其是因为可以保证两个括号的大小相同。至于你之前的帖子,我建议稍微不同的对齐方式,并推荐使用命令\diffp,来自esdiff

\documentclass[a4paper]{article}
\usepackage[showframe]{geometry}
\usepackage{mathtools, esdiff}
\usepackage{booktabs}

\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<5><6><7><8><9><10>
<10.95><12><14.4><17.28><20.74><24.88>
mathx10
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}

\newcommand{\barU}{\widebar{U}}
\newcommand{\barV}{\widebar{V}}
\newcommand{\barW}{\widebar{W}}
\newcommand{\barP}{\widebar{P}}

\begin{document}

\begin{equation}
 %-------------
 \diffp{\barU}{t} + \diffp{u}{t}=
 \label{eq:mx2}
\begin{aligned}[t] -\biggl[\barU\left(\diffp{\barU}{x} +
    \diffp{u}{x}\right) + u\left(\diffp{\barU}{x} +
    \diffp{u}{x}\right) + \barV\left(\diffp{\barU}{y} +
    \diffp{u}{y}\right) + v\left(\diffp{\barU}{y} +
    \diffp{u}{y}\right) + \\
    \barW\left(\diffp{\barU}{z} +
    \diffp{u}{z}\right) + w\left(\diffp{\barU}{z} +
    \diffp{u}{z}\right)\biggr] - \left(\diffp{\barP}{x} + \diffp{p}{x}\right) +
     \frac{1}{Re}\bigl(\nabla^2\barU + \nabla^2u\bigr)
\end{aligned}
\end{equation}

\end{document} 

在此处输入图片描述

答案2

我也建议不自动调整大小大方括号;相反,使用\biggl[\biggr]。为了改进(即,减少) 圆括号周围的间距,考虑加载包并在序言中mleftright运行。\mleftright

在此处输入图片描述

\documentclass{article}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page margins appropriately
\usepackage{mleftright}\mleftright % for better spacing before \left and after \right
\usepackage{amsmath}
\newcommand{\barU}{\bar{U}}
\newcommand{\barV}{\bar{V}}
\newcommand{\barW}{\bar{W}}
\newcommand{\barP}{\bar{P}}
\begin{document}
\begin{equation}\label{eq:mx2}
\begin{aligned}
\frac{\partial\barU}{\partial t} + \frac{\partial u}{\partial t} = 
    -\biggl[
 \barU &\left(\frac{\partial \barU}{\partial x} + \frac{\partial u}{\partial x}\right) 
     + u\left(\frac{\partial \barU}{\partial x} + \frac{\partial u}{\partial x}\right) 
  +\barV\left(\frac{\partial \barU}{\partial y} + \frac{\partial u}{\partial y}\right) 
     + v\left(\frac{\partial \barU}{\partial y} + \frac{\partial u}{\partial y}\right) \\
{}+\barW &\left(\frac{\partial \barU}{\partial z} + \frac{\partial u}{\partial z}\right) 
     + w\left(\frac{\partial \barU}{\partial z} + \frac{\partial u}{\partial z}\right)
     \biggr] 
     -  \left(\frac{\partial \barP}{\partial x} + \frac{\partial p}{\partial x}\right) 
     +  \frac{1}{Re}(\nabla^2\barU + \nabla^2u)
\end{aligned}
\end{equation}
\end{document}

相关内容