6

I'd like to place two equations on one line, but each has to be numbered separately.

For example, in this figure:

Enter image description here

This figure is created with minipage:

\noindent\begin{minipage}{.5\linewidth}
\begin{equation}
\varepsilon_k = \lfloor \dfrac{\varepsilon}{K} \rfloor,
\end{equation}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\begin{equation}
\mathbb{P}_k = \dfrac{\mathbb{P}}{k}.
\end{equation}
\end{minipage}

But I don't like using this solution, because it seems to be unprofessional (e.g, it occupies the blank space before and after equations).

I prefer using align, like this:

\begin{align}
& \varepsilon_k = \dfrac{\varepsilon}{K}
& \mathbb{P}_k = \dfrac{\mathbb{P}}{k}
\end{align}

This yields:

Enter image description here

But how can I make these two equations be numbered separately?

1
  • 2
    Off topic, but I would recommend against doing this. It breaks the structure and makes reading and finding equation 9 harder, with no real gain.
    – mickep
    Mar 15, 2023 at 12:22

2 Answers 2

8

I wouldn't use such an approach, which makes for difficult reading.

Anyway…

\documentclass{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{lipsum} % for mock text

\ExplSyntaxOn
\NewDocumentEnvironment{multiequation}{b}
 {
  \vantiempham:n { #1 }
 }
 {}

\seq_new:N \l__vantiempham_md_seq

\cs_new_protected:Nn \vantiempham:n
 {
  \seq_set_split:Nnn \l__vantiempham_md_seq { \\ } { #1 }
  $$
  \seq_map_function:NN \l__vantiempham_md_seq \__vantiempham_md_item:n
  $$
 }
\cs_new_protected:Nn \__vantiempham_md_item:n
 {
  \begin{minipage}{\dim_eval:n {\displaywidth/(\seq_count:N \l__vantiempham_md_seq)} }
  \begin{equation}
  \cs_set_eq:Nc \label { ltx@label }
  #1
  \vphantom{\seq_use:Nn \l__vantiempham_md_seq {}}
  \end{equation}
  \end{minipage}
 }

\ExplSyntaxOff  

\begin{document}

\eqref{A}, \eqref{B}, \eqref{C}, \eqref{D}, \eqref{E}

\lipsum[1][1-4]
\begin{multiequation}
  \varepsilon_k = \left\lfloor\frac{\varepsilon}{K}\right\rfloor,
  \label{A}
\\
  \mathbb{P}_k = \frac{\mathbb{P}}{k}.
  \label{B}
\end{multiequation}
\lipsum[2][1-4] % filler text
\begin{multiequation}
  \varepsilon_k = \left\lfloor\frac{\varepsilon}{K}\right\rfloor,
  \label{C}
\\
  \mathbb{P}_k = \frac{\mathbb{P}}{k},
  \label{D}
\\
  a=b.
  \label{E}
\end{multiequation}
\lipsum[3][1-4]

\end{document}

Equations are separated by the standard \\ (in this case it doesn't mean “new line”).

Note that the equation numbers are aligned, because in each of the items we typeset a vertical phantom of all of them, No manual adjustment, contrary to what happens with Mico's answer.

enter image description here

5

If your main concern is having enough vertical whitespace padding above and below the equations, I suggest you place the side-by-side minipage environments in a center environment.

enter image description here

\documentclass{article}

\usepackage{mathtools,amssymb,lipsum}
\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}

\begin{document}
\lipsum[1][1-4] % filler text
\begin{center}
\begin{minipage}{.5\linewidth}
  \begin{equation}
  \varepsilon_k = \floor*{\frac{\varepsilon}{K}}\,,
  \end{equation}
\end{minipage}%
\begin{minipage}{.5\linewidth}
  \begin{equation}
  \mathbb{P}_k = \frac{\mathbb{P}}{k}\,.
  \end{equation}
\end{minipage}
\end{center}
\lipsum[2][1-4] % filler text
\end{document}

Addendum: If the formulas in the two minipage environments have different heights and/or depths, the solution suggested above is not guaranteed to align the equation numbers perfectly. Luckily, this problem can be easily taken care of by inserting a suitable typographical strut -- created, in practice, with a \vphantom directive -- in the equation that's less tall and/or less deep.

Take the two equations above: Visual inspection reveals that the one on the right (\frac{\mathbb{P}}{k}) is both taller and -- impportantly -- deeper than the one on the left. It therefore suffices to change the

  \begin{equation}
  \varepsilon_k = \floor*{\frac{\varepsilon}{K}}\,,
  \end{equation}

to

  \begin{equation}
  \varepsilon_K = \floor*{\frac{\varepsilon}{K}}
     \vphantom{\frac{\mathbb{P}}{k}}\,,
  \end{equation}

to obtain the desired even alignment:

enter image description here

3
  • The equation numbers are not aligned. You also introduce an unwanted page break point at center.
    – egreg
    Mar 15, 2023 at 18:34
  • @egreg - Please see the addendum I just posted for a straightforward fix for the alignment issue.
    – Mico
    Mar 15, 2023 at 19:19
  • 1
    I saw and modified the comment in the answer accordingly.
    – egreg
    Mar 15, 2023 at 21:00

You must log in to answer this question.

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