5

I would like to display a list of equations with some braces on the left to group some of them. Something that looks like the example below, with text on the left of each brace (aligned vertically), saying for instance "source-free" and "with sources", and both braces aligned with each other. Also, semantically, it would be better if this is done with a single environment instead of two successive ones.

I would prefer a solution using packages/features as standard as possible, and the least ad-hoc as possible, even if the alignments are not perfect.

(Please, no comment on the typesetting of div, rot, etc. The application I have in mind has nothing to do with Maxwell anyway!)

Thanks.

\documentclass{minimal}
\usepackage{empheq}
\begin{document}
Maxwell's equations:
\begin{empheq}[left=\empheqlbrace]{gather}
div B = 0 \tag{Thomson}\\
rot E + \frac{\partial B}{\partial t} = 0 \tag{Faraday}
\end{empheq}
\begin{empheq}[left=\empheqlbrace]{gather}
div E = \frac{\rho}{\epsilon_0} \tag{Gauss}\\
rot B - \frac1c^2 \frac{\partial E}{\partial t} = \mu_0 J \tag{Amp\`ere}
\end{empheq}
\end{document}

Update (2021-01-31): I accepted Bernard's answer which is satisfying. I would have hoped that an environment exists so that one can write:

\begin{gather}
\begin{group}[\text{source-free }\left\{]
a = 0\\
b = 0  
\end{group}
\begin{group}[\text{with sources }\left\{]
c = 0\\
d = 0  
\end{group}
\end{gather}

(since the two groups are connected (the two left braces should be aligned), some options should be passed at the level of the "gather" environment, probably).

4
  • 1
    Welcome to TeX.SX! Do the equations have to be numbered?
    – Bernard
    Commented Jan 28, 2021 at 23:33
  • Yes, I need the (customized) tags as they appear.
    – user0
    Commented Jan 28, 2021 at 23:42
  • I mean, do these tags have to be referable with `\label{…}?
    – Bernard
    Commented Jan 28, 2021 at 23:56
  • Sorry: no this is not necessary. I plan later to write later things like "by Gauss's equation...", so no need of \label{...} in the present case... Although I can imagine cases when one would want this possibility.
    – user0
    Commented Jan 29, 2021 at 0:00

4 Answers 4

4

You can use eqparbox. The label to use should be unique to the group of boxes to typeset with the same width.

I'd prefer left alignment, change to \eqmath[c]{A}{...} if you want centering.

\documentclass{article}
\usepackage{amsmath}
\usepackage{empheq}
\usepackage{eqparbox}

\DeclareMathOperator{\Div}{div}
\DeclareMathOperator{\Rot}{rot}

\newcommand{\eqmath}[3][l]{%
  % #1 = alignment, default l, #2 = label, #2 = math material
  \eqmakebox[#2][#1]{$\displaystyle#3$}%
}

\begin{document}

Maxwell's equations:
\begin{empheq}[left=\empheqlbrace]{align}
&\eqmath{A}{\Div B = 0\vphantom{\Big|}} \tag{Thomson}\\
&\eqmath{A}{\Rot E + \frac{\partial B}{\partial t} = 0} \tag{Faraday}
\end{empheq}
\begin{empheq}[left=\empheqlbrace]{align}
&\eqmath{A}{\Div E = \frac{\rho}{\epsilon_0}} \tag{Gauss}\\
&\eqmath{A}{\Rot B - \frac{1}{c^2} \frac{\partial E}{\partial t} = \mu_0 J} \tag{Amp\`ere}
\end{empheq}
\end{document}

enter image description here

Please, note that it should be

\frac{1}{c^2}

True, \frac12 works, but…

Actually, I'd prefer not to abuse \tag.

\documentclass{article}
\usepackage{amsmath}
\usepackage{eqparbox}

\DeclareMathOperator{\Div}{div}
\DeclareMathOperator{\Rot}{rot}

\newcommand{\eqmath}[3][l]{%
  % #1 = alignment, default l, #2 = label, #2 = math material
  \eqmakebox[#2][#1]{$\displaystyle#3$}%
}
\newcommand{\eqtext}[3][l]{%
  % #1 = alignment, default l, #2 = label, #2 = text material
  \eqmakebox[#2][#1]{#3}%
}

\begin{document}

Maxwell's equations:
\begin{gather*}
\left\{\begin{alignedat}{2}
&\eqmath{B}{\Div B = 0\vphantom{\Big|}} &\quad&\eqtext{C}{(Thomson)}\\
&\eqmath{B}{\Rot E + \frac{\partial B}{\partial t} = 0} &&\eqtext{C}{(Faraday)}
\end{alignedat}\right.
\\[1ex]
\left\{\begin{alignedat}{2}
&\eqmath{B}{\Div E = \frac{\rho}{\epsilon_0}} &\quad&\eqtext{C}{(Gauss)}\\
&\eqmath{B}{\Rot B - \frac{1}{c^2} \frac{\partial E}{\partial t} = \mu_0 J} &&\eqtext{C}{(Amp\`ere)}
\end{alignedat}\right.
\end{gather*}

\end{document}

enter image description here

With labels before the braces, both realizations:

\documentclass{article}
\usepackage{amsmath}
\usepackage{empheq}
\usepackage{eqparbox}

\DeclareMathOperator{\Div}{div}
\DeclareMathOperator{\Rot}{rot}

\newcommand{\eqmath}[3][l]{%
  % #1 = alignment, default l, #2 = label, #2 = math material
  \eqmakebox[#2][#1]{$\displaystyle#3$}%
}
\newcommand{\eqtext}[3][l]{%
  % #1 = alignment, default l, #2 = label, #2 = text material
  \eqmakebox[#2][#1]{#3}%
}

\begin{document}

\section{With empheq}

Maxwell's equations:
\begin{empheq}[left={\makebox[4em][r]{Source-free }\empheqlbrace}]{align}
&\eqmath{A}{\Div B = 0\vphantom{\Big|}} \tag{Thomson}\\
&\eqmath{A}{\Rot E + \frac{\partial B}{\partial t} = 0} \tag{Faraday}
\end{empheq}
\begin{empheq}[left={\makebox[4em][r]{With sources }\empheqlbrace}]{align}
&\eqmath{A}{\Div E = \frac{\rho}{\epsilon_0}} \tag{Gauss}\\
&\eqmath{A}{\Rot B - \frac{1}{c^2} \frac{\partial E}{\partial t} = \mu_0 J} \tag{Amp\`ere}
\end{empheq}

\section{No empheq}

Maxwell's equations:
\begin{gather*}
\eqtext[r]{1}{Source-free }
\left\{\begin{alignedat}{2}
&\eqmath{B}{\Div B = 0\vphantom{\Big|}} &\quad&\eqtext{C}{(Thomson)}\\
&\eqmath{B}{\Rot E + \frac{\partial B}{\partial t} = 0} &&\eqtext{C}{(Faraday)}
\end{alignedat}\right.
\\[1ex]
\eqtext[r]{1}{With sources }
\left\{\begin{alignedat}{2}
&\eqmath{B}{\Div E = \frac{\rho}{\epsilon_0}} &\quad&\eqtext{C}{(Gauss)}\\
&\eqmath{B}{\Rot B - \frac{1}{c^2} \frac{\partial E}{\partial t} = \mu_0 J} &&\eqtext{C}{(Amp\`ere)}
\end{alignedat}\right.
\end{gather*}

\end{document}

enter image description here

4
  • Thanks. The various blocs are not aligned, though (in the present case, they are, but make an equation longer, or write something long before a brace e.g. "\text{source-free }"), and the blocs will not be aligned anymore).
    – user0
    Commented Jan 31, 2021 at 18:31
  • 1
    @user0 Sorry, I had not noticed them. Added.
    – egreg
    Commented Jan 31, 2021 at 20:42
  • The Flash superhero was an amateur...Impressive speed :-)
    – Sebastiano
    Commented Jan 31, 2021 at 20:49
  • Thank you for your answers. I am going to use the method using \tag since in my case, they are really tags which I cite later in the paper. There are still two minor things (but no need to spend time on it): it looks like the vertical alignment depends on the length of the longest tag in a given bloc, so I added some \; which is not very good practice. Also, there is no indication that the whole thing forms a single entity, so I had to use {samepage} to prevent page break, and some vertical spaces between blocs appear larger (I had to tweak with \vspace{-0.8em}).
    – user0
    Commented Feb 6, 2021 at 11:13
2

If you don't need to cross-reference the equations, you have a solution with the bigdelim package and tabularx. I added the esdiff package for an easy typing of partial derivatives, and cellspace to add some vertical padding to the table rows:

\documentclass{article}
\usepackage{esdiff, empheq}
\DeclareMathOperator{\Div}{div}
\DeclareMathOperator{\rot}{rot}
\usepackage{tabularx, bigdelim}
\usepackage[column=O]{cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}

\begin{document}

Maxwell's equations:

\noindent\begin{tabularx}{\textwidth}{@{}Xr @{}>{$\displaystyle}Ol<{$}>{\raggedleft\arraybackslash}X @{}}
 &\ldelim\{{3}{*}[Source-free~] & \Div B = 0 & \text{(Thomson)}\\
 & & \rot E + \diffp{B}{t} = 0 &\text{(Faraday)} \\ \strut \\
 &\ldelim\{{4}{*}[With sources~] & \Div E = \frac{\rho}{\epsilon} & \text{(Gauss)}\\
 & & \rot B - \frac1{c^2} \diffp{E}{t} = \mu_0 J &\text{(Ampère)}
\end{tabularx}

\end{document} 

enter image description here

4
  • It looks a bit more complicated than I had hoped, but it does the job. Thanks.
    – user0
    Commented Jan 31, 2021 at 12:46
  • What do you find so complicated? Determining the number of rows the braces should expand to?
    – Bernard
    Commented Jan 31, 2021 at 13:06
  • Yes, this is one of the things (together with the fact of using several packages). I'll update my question just to show what would have been ideal imho.
    – user0
    Commented Jan 31, 2021 at 15:09
  • 1
    @user0: I understand what you want. Unfortunately, as far as I know, the left=… construction of empheq does not work with aligned – and the result is that these constructions are only global, for an entire align environment. Now the use of packages is a rather common necessity.
    – Bernard
    Commented Jan 31, 2021 at 15:43
1

This is a solution I came up with, it's not perfect:

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{cases}

\begin{document}
Maxwell's equations:


\begin{numcases}{source-free = }
    div B &= 0 \tag{Thompson} \\
    rot E + \frac{\partial B}{\partial t} &= 0 \tag{Faraday}
\end{numcases} 
\begin{numcases}{With sources  = }
    div E &= $\frac{\rho}{\epsilon}$ \tag{Gauss}\\
    rot B - \frac1c^2 \frac{\partial E}{\partial t} &= $\mu_0$ J \tag{Amp\`ere} 
\end{numcases}

\end{document}
1

With the lastest version of nicematrix (v. 5.10 of 2021-02-05), you can use the environment {NiceTabular*} and add the braces with the built-in command \SubMatrix. All the equations are aligned within the same environment.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{esdiff}
\usepackage{lipsum}
\DeclareMathOperator{\Div}{div}
\DeclareMathOperator{\rot}{rot}

\NiceMatrixOptions{cell-space-limits=4pt}

\begin{document}

\lipsum[1]

Maxwell's equations:

\begingroup
\everymath{\displaystyle}
\noindent
\begin{NiceTabular*}{\textwidth}{r@{\qquad}l@{\extracolsep{\fill}}r@{}}
\Block{2-1}{\hspace{2cm}Source-free~}  
              & $\Div B = 0$                                  & (Thomson) \\
              & $\rot E + \diffp{B}{t} = 0$                   & (Faraday) \\ 
\strut \\
\Block{2-1}{With sources~} 
             & $\Div E = \frac{\rho}{\epsilon}$              & (Gauss) \\
             & $\rot B - \frac1{c^2} \diffp{E}{t} = \mu_0 J$ & (Ampère)
\CodeAfter
\SubMatrix\{{1-2}{2-2}.
\SubMatrix\{{4-2}{5-2}.
\end{NiceTabular*}
\endgroup

\end{document} 

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Ouput of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .