2

I'd like to input a long equation, so I had to cut it into two lines. But, there's a couple of {} at the start of the first line of the equation and the end of the second line of the equation, and the 'equal height brackets' doesn't support \\ in it. I've used the \qty{} command of the package physics, or the \ab\{\} command of the package physics2, just like the code below:

\documentclass[9pt,a4paper]{article}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{extarrows}
\usepackage{fixdif,physics2}
\def\e{\mathrm{e}}
\usephysicsmodule{ab,ab.legacy,braket,nabla.legacy}
\def\Re{\mathrm{Re}}
\begin{document}
\begin{equation}
    \begin{aligned}
        J_L(t)&=\frac{2e}{\hbar}\Re\ab\{\sum_{k,\alpha\in L}{V_{k\alpha,n(t)}G_{n,k\alpha}^<(t,t)}\}\\
        &\xlongequal{\sum_{n}\sum_m=\sum_{n,m}}\frac{2e}{\hbar}\Re\ab\{\sum_{\substack{k,\alpha\in L\\n,m}}V_{k\alpha,n}(t)\int_{-\infty}^t\d t_1V_{k\alpha,m}^*\ab(t_1)\times\ab[G_{nm}^r\ab(t,t_1)\times\ab(\i f\ab(\epsilon_{k\alpha}^0)\exp\ab[-\i\int_{t}^{t_1}{\d t_2\epsilon_{k\alpha}(t_2)}])\\
        &\ \ +G_{nm}^<\ab(t,t_1)\times\ab(\i\theta\ab(-t_1+t)\exp\ab[-\i\int_{t}^{t_1}{\d t_2\epsilon_{k\alpha}(t_2)}])\vphantom{\int_t^{t_1}}]\}\\
      \end{aligned}
\end{equation}
\end{document}

they all returned me errors:

Extra }, or forgotten \right.
<template> }
Missing } inserted.
<inserted text> 

Then, I used the command \left\{ at the at the start of the first line of the equation and \right\} at the end of the second line of the equation, however it also returned me the errors above.

Then, I used the command \left\{ at the start of the first line and \right. at the end of the first line, used the command \left. at the start of the second line and \right\} at the end of the second line, the errors disappeared, however, the height of the right bracket } doesn't equal to the height of the left bracket {. enter image description here

The code is just like below:

\documentclass[9pt,a4paper]{article}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{extarrows}
\usepackage{fixdif,physics2}
\def\e{\mathrm{e}}
\usephysicsmodule{ab,ab.legacy,braket,nabla.legacy}
\def\Re{\mathrm{Re}}
\begin{document}
\begin{equation}
    \begin{aligned}
        J_L(t)&=\frac{2e}{\hbar}\Re\ab\{\sum_{k,\alpha\in L}{V_{k\alpha,n(t)}G_{n,k\alpha}^<(t,t)}\}\\
        &\xlongequal{\sum_{n}\sum_m=\sum_{n,m}}\frac{2e}{\hbar}\Re\left\{\sum_{\substack{k,\alpha\in L\\n,m}}V_{k\alpha,n}(t)\int_{-\infty}^t\d t_1V_{k\alpha,m}^*\ab(t_1)\times\left[G_{nm}^r\ab(t,t_1)\times\ab(\i f\ab(\epsilon_{k\alpha}^0)\exp\ab[-\i\int_{t}^{t_1}{\d t_2\epsilon_{k\alpha}(t_2)}])\right.\right.\\
        &\ \ \left.\left.+G_{nm}^<\ab(t,t_1)\times\ab(\i\theta\ab(-t_1+t)\exp\ab[-\i\int_{t}^{t_1}{\d t_2\epsilon_{k\alpha}(t_2)}])\vphantom{\int_t^{t_1}}\right]\right\}\\
      \end{aligned}
\end{equation}
\end{document}

Finally, I found that I can add a 'virtual' height of the first line, is just add the command \vphantom{\sum_{\substack{k,\alpha\in L\\n,m}}} before the \right\} at the end of the second line, just like the code below:

\documentclass[9pt,a4paper]{article}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{extarrows}
\usepackage{fixdif,physics2}
\def\e{\mathrm{e}}
\usephysicsmodule{ab,ab.legacy,braket,nabla.legacy}
\def\Re{\mathrm{Re}}
\begin{document}
\begin{equation}
    \begin{aligned}
        J_L(t)&=\frac{2e}{\hbar}\Re\ab\{\sum_{k,\alpha\in L}{V_{k\alpha,n(t)}G_{n,k\alpha}^<(t,t)}\}\\
        &\xlongequal{\sum_{n}\sum_m=\sum_{n,m}}\frac{2e}{\hbar}\Re\left\{\sum_{\substack{k,\alpha\in L\\n,m}}V_{k\alpha,n}(t)\int_{-\infty}^t\d t_1V_{k\alpha,m}^*\ab(t_1)\times\left[G_{nm}^r\ab(t,t_1)\times\ab(\i f\ab(\epsilon_{k\alpha}^0)\exp\ab[-\i\int_{t}^{t_1}{\d t_2\epsilon_{k\alpha}(t_2)}])\right.\right.\\
        &\ \ \left.\left.+G_{nm}^<\ab(t,t_1)\times\ab(\i\theta\ab(-t_1+t)\exp\ab[-\i\int_{t}^{t_1}{\d t_2\epsilon_{k\alpha}(t_2)}])\vphantom{\int_t^{t_1}}\right]\vphantom{\sum_{\substack{k,\alpha\in L\\n,m}}}\right\}\\
      \end{aligned}
\end{equation}
\end{document}

The question is 'solved', this is the effect that I want: enter image description here

However, this is too much trouble... I'd like to know if there's a simple command just like the command \qty of package physics or \ab of package physics2 can achieve the effect I want?

Axia
  • 514

1 Answers1

4

Rather than define and use various \vphantom contstructs, do learn how to use \Bigg[lr] and \bigg[lr]. Incidentally, your formula needs to be spread across four rows, not just three, in order for it not to protrude into the margins. Oh, and don't use \def unless you are willing to take the risk of clobbering pre-existing macros; the macro \Re is a case in point.

enter image description here

\documentclass[%9pt, % "9pt" is not a recognized option
               a4paper]{article}
\usepackage{geometry}
\usepackage{mathtools} % for "\smashoperator" macro
\usepackage{extarrows,fixdif}
\let\Re\relax % first, undefine the existing '\Re' macro
\DeclareMathOperator\Re{\mathrm{Re}} % next, redefine '\Re'
%\def\e{\mathrm{e}} % not needed 
\providecommand\I{\mathrm{i}} % imag. unit. Use only in math mode

\begin{document}

\begin{equation} \begin{aligned}[b] J_L(t) &=\frac{2e}{\hbar} \Re\Biggl{ , \smashoperator[r]{\sum_{k,\alpha\in L}} V_{k\alpha,n(t)}G_{n,k\alpha}^<(t,t)\Biggr}\ &\xlongequal{\sum_{n}\sum_m=\sum_{n,m}} \frac{2e}{\hbar} \Re\Biggl{ , \smashoperator[r]{\sum_{\substack{k,\alpha\in L\n,m}}} V_{k\alpha,n}(t) \int_{-\infty}^t \d t_1 V_{k\alpha,m}^* (t_1)\ &\quad \times\Biggl[G_{nm}^r(t,t_1)\times \biggl(\I f(\epsilon_{k\alpha}^0) \exp\biggl[-\I\int_{t}^{t_1} \d t_2\epsilon_{k\alpha}(t_2) \biggr]\biggr) \ &\qquad +G_{nm}^< (t,t_1)\times\biggl(\I\theta(-t_1+t) \exp\biggl[-\I\int_{t}^{t_1} \d t_2\epsilon_{k\alpha}(t_2) \biggr]\biggr) \Biggr]\Biggr} \end{aligned} \end{equation} \end{document}

Mico
  • 506,678
  • 1
    \i throws warning in math mode. I'd suggest soething along the lines of \newcommand*{\I}{\text{\i}}, then one can redefine the imaginary unit (I think that's what it's supposed to be) as needed. – campa Nov 07 '23 at 10:15
  • @campa - Good point. Let me fix this right away. – Mico Nov 07 '23 at 10:17
  • Actually, thinking about it \textup might be better. You don't want that to be italic in a theorem environment. – campa Nov 07 '23 at 10:23
  • @campa - I ended up using \mathrm{i}. :-) – Mico Nov 07 '23 at 10:24
  • However, I feel that commands like big, bigg, Big or Bigg cannot control the height of the brackets as finely as the physics package – Axia Nov 07 '23 at 10:38
  • 1
    @Axia - What do you mean? First off, in your code, many of the \ab instructions have no effect at all; I wouldn't call that an example of "fine control". Second, the only time that \bigg and \Bigg fall short is if what's needed is tall delimiters bigger than \Bigg. However, that's not the case here. – Mico Nov 07 '23 at 10:58
  • I think the set of 'big' commands can’t set the height of the brackets finely, for example, the elements in the bracket is higher than the height of the bracket '\biggl{' but lower than the height of the bracket '\Biggl{', I want to control the height of bracket very accurate, how can I achieve this? – Axia Nov 07 '23 at 12:23
  • @Axia - I have to disagree with the premise of your comment, which is that the sizes provided by \big, \Big, and \bigg and \Bigg are somehow not "fine enough". Naturally, you have every right to prefer to pursue an alternative approach, which by necessity will involve providing lots of \left. and \right. directives and coming up with lots of cleverly chosen \vphantom commands. If that's what you would rather do, I'm certainly not going to stop you. That said, I also have absolutely no desire to bicker with you on this subject. – Mico Nov 07 '23 at 14:32