0

when I split \left[ and \right] in the align environment and use breqn the equation doesn't compile. When I add \left. and \right. as virtual left and right delimiters, it works, but the \right] bracket does not have the right size.

Here is the minimal example:

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

and it generates this:

enter image description here

How can I obtain the right size for the bracket in the \right] command? Thanks!

1
  • 3
    you have not specified that they should be the same size. However it is usually best to avoid \left\right and use \Biggl[ and \Biggr] choosing a suitable big variant name, then the issue does not arise. Mar 16 '20 at 16:09
2

Also Papeeria, that it is a tool online to write in LaTeX, it starts with a \documentclass named article (see the important comments of Schrödinger's cat). After you should read also the important comment of @David Carlisle: \Biggl+( or with [ etc. can be used when you split a formula without mistakes. To the end I have moved & of the your code to have a fine alignment.

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

enter image description here

1
  • 1
    I found an answere here stating that breqn helps with this issue, it doesn't. I have to remove it.
    – tmaric
    Mar 16 '20 at 17:10
3

You can use a \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}

enter image description here

1
  • Thanks for the additional info about the other packages I am misusing. The answer with \Biggl and \Biggr seems cleaner than injecting additional \left. and \right...
    – tmaric
    Mar 16 '20 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.