0

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:

enter image description here

Here's what I want to do:

enter image description here

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

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}

\begin{equation}
\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.
\end{equation}

\begin{equation}
\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{equation}

\end{document}

enter image description here

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? – Minh Nghĩa Nov 11 '20 at 10:38
  • @MinhNghĩa I added some comments – egreg Nov 11 '20 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? – Minh Nghĩa Nov 11 '20 at 11:03
0

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):

  • 1
    There is no need to use empheq: just \begin{equation}\left\{\begin{alignedat}{5}...\end{alignedat}\right.\end{equation} – egreg Nov 11 '20 at 10:22

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.