# Single equation number for empheq

Currently, each equation in empheq has its own number. How can I number them as one system of equations?

Edit:

Here's the current situation, each equation has its own number:

Here's what I want to do:

• As always on this site please post a full minimal example so we have an idea of what you're doing Nov 10, 2020 at 19:46

## 2 Answers

No need to use empheq, where \left\{ suffices.

Actually, I can suggest two easier ways to input your equation.

\documentclass{article}
\usepackage{amsmath,siunitx}

\numberwithin{equation}{section}
\sisetup{output-decimal-marker={,}}

\begin{document}

\setcounter{section}{1}\setcounter{equation}{3}

$$\left\{ \setlength{\arraycolsep}{0pt}% \renewcommand{\arraystretch}{1.2}% \begin{array}{ *{5}{ r >{{}}c<{{}} } r } x_1 &=& & & \num{0.25} x_2 &+& \num{0.25} x_3 & & &+& 50 \\ x_2 &=& \num{0.25} x_1 &+& & & &+& \num{0.25} x_4 &+& 50 \\ x_3 &=& \num{0.25} x_1 &+& & & &+& \num{0.25} x_4 &+& 25 \\ x_4 &=& & & \num{0.25} x_2 &+& \num{0.25} x_3 & & &+& 25 \end{array} \right.$$

$$\begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ x_4 \end{bmatrix} = \begin{bmatrix} 0 & \num{0.25} & \num{0.25} & 0 \\ \num{0.25} & 0 & 0 & \num{0.25} \\ \num{0.25} & 0 & 0 & \num{0.25} \\ 0 & \num{0.25} & \num{0.25} & 0 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ x_4 \end{bmatrix} + \begin{bmatrix} 50 \\ 50 \\ 25 \\ 25 \end{bmatrix}$$

\end{document}


What's the magic *{5}{ r >{{}}c<{{}} }?

In general, *{<number>}{<col specs>} tells LaTeX that we want <number> copies of the <col specs>; for instance, *{12}{c} means twelve centered columns and *{4}{lc} means four pairs of left and center aligned columns (so eight in total).

If we count the columns, we see that we need eleven of them, but the first ten are pairs of right aligned (for the polynomial term) and center aligned (for the operation or relation symbol) columns.

However, we want that the operation or relation symbol is surrounded by the right amount of space, which could be achieved by typing {}+{} or {}={}. However, we can do better! If we specify a column as

>{x} c <{y}


(the array package is needed), we are telling LaTeX that each entry in the eventually centered column will be preceded by x and followed by y. So we can do >{{}}c<{{}} and there we are! Typing + or = in the column will result is getting {}+{} and {}={}.

In the group opened by \left\{ I set to zero the intercolumn space for array, so only the spaces inserted as specified before around the operation and relation symbols will appear. Also, in order to emulate cases, aligned and so on, the factor 1.2 is applied to the interline spacing inside the array.

• *{5}{ r >{{}}c<{{}} } r what is this magic sir? Nov 11, 2020 at 10:38
• @MinhNghĩa I added some comments Nov 11, 2020 at 10:52
• I think the arraycolsep and arraystretch are very, very delicate, and they indeed fix the problems I had before I resorted to empheq, and it seems to match exactly with empheq. Is there anywhere that I can read about these variables/settings, so that I can consistently recreate these math-like mode? Or did you just straight up read empheq source and found these values? Nov 11, 2020 at 11:03

I found it! Just nest alignedat inside an equation empheq. I think that:

• alignedat groups the equations as one thing
• equation numbers it
\begin{empheq}[left = \empheqlbrace]{equation}\begin{alignedat}{5}
x_1 &=                &     & \num{0.25} x_2 &{}+{}& \num{0.25} x_3 &     &                &{}+{}& 50  \\
x_2 &= \num{0.25} x_1 &{}+{}&                &     &                &{}+{}& \num{0.25} x_4 &{}+{}& 50  \\
x_3 &= \num{0.25} x_1 &{}+{}&                &     &                &{}+{}& \num{0.25} x_4 &{}+{}& 25  \\
x_4 &=                &     & \num{0.25} x_2 &{}+{}& \num{0.25} x_3 &     &                &{}+{}& 25
\end{alignedat}\end{empheq}


The result (it is the above image, I found the answer before I updated my question):

• There is no need to use empheq: just \left\{\begin{alignedat}{5}...\end{alignedat}\right. Nov 11, 2020 at 10:22