当我在环境中拆分\left[
和并使用时,公式无法编译。当我添加和作为虚拟左和右分隔符时,它可以工作,但括号的大小不正确。\right]
align
breqn
\left.
\right.
\right]
以下是一个最简单的例子:
\documentclass{minimal}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{breqn}
\newcommand{\Sf}{\mathbf{S}_f}
\newcommand{\gradphi}[1]{(\nabla\phi)_{#1}}
\newcommand{\U}{\mathbf{U}}
\begin{document}
\begin{align}
\left(\frac{\partial \phi}{\partial t}\right)_c^{n+1} =
\dfrac{0.5}{\Omega_c} & \left[ \sum_f D_f \gradphi{f}^{n+1} \cdot \Sf + \sum_f D_f \gradphi{f}^n \cdot \Sf - \right. \nonumber \\
& - \sum_f \U_f \phi_f^{n+1} \cdot \Sf - \sum_f \U_f \phi_f^{n} \cdot \Sf \nonumber \\
& \left. + S(\phi_c^n) + S(\phi_c^{n+1}) \right] + O(\delta t^2) + O(h^2)
\label{eq:phicrank}
\end{align}
\end{document}
并生成以下内容:
如何获取\right]
命令中括号的正确大小?谢谢!
答案1
还纸属植物,它是一个在线写作的工具LaTeX
,它以一个\documentclass
命名的文章(参见薛定谔的猫)之后你还应该阅读@大卫·卡莱尔:\Biggl+(
或 with[
等可用于拆分公式而不会出错。最后,我已将&
您的代码移出,以便进行精细对齐。
\documentclass[12pt]{article}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{breqn}%<---Why do you use this package?
\newcommand{\Sf}{\mathbf{S}_f}
\newcommand{\gradphi}[1]{(\nabla\phi)_{#1}}
\newcommand{\U}{\mathbf{U}}
\begin{document}
\begin{align}
\Bigl(\frac{\partial \phi}{\partial t}\Bigr)_c^{n+1} & =
\dfrac{0.5}{\Omega_c}\Biggl[ \sum_f D_f \gradphi{f}^{n+1} \cdot \Sf + \sum_f D_f \gradphi{f}^n \cdot \Sf \nonumber \\
& - \sum_f \U_f \phi_f^{n+1} \cdot \Sf - \sum_f \U_f \phi_f^{n} \cdot \Sf \nonumber \\
& + S(\phi_c^n) + S(\phi_c^{n+1}) \Biggr] + O(\delta t^2) + O(h^2)
\label{eq:phicrank}
\end{align}
\end{document}
答案2
您可以使用\vphantom
。
\documentclass{article}% don't use \documentclass{minimal} see https://tex.stackexchange.com/q/42114
\usepackage{mathtools}% loads \usepackage{amsmath}
\usepackage{amssymb}
%\usepackage{breqn} % <-don't use
\newcommand{\Sf}{\mathbf{S}_f}
\newcommand{\gradphi}[1]{(\nabla\phi)_{#1}}
\newcommand{\U}{\mathbf{U}}
\begin{document}
\begin{align}
\left(\frac{\partial \phi}{\partial t}\right)_c^{n+1} =
\dfrac{0.5}{\Omega_c} & \left[ \sum_f D_f \gradphi{f}^{n+1} \cdot \Sf + \sum_f D_f \gradphi{f}^n \cdot \Sf - \right. \nonumber \\
& - \sum_f \U_f \phi_f^{n+1} \cdot \Sf - \sum_f \U_f \phi_f^{n} \cdot \Sf \nonumber \\
& \left. + S(\phi_c^n) + S(\phi_c^{n+1}) \vphantom{\sum_f}\right] + O(\delta t^2) + O(h^2)
\label{eq:phicrank}
\end{align}
\end{document}