4

I have the following code:

\documentclass{article}
\usepackage{subfigure,graphicx,amsmath,amssymb, amsfonts,physics,empheq}


\begin{document}


    \begin{empheq}[left=\empheqlbrace]{align}
    Q_2(s) &= \frac{k_{21} Q_1(s)}{s+k_{12} + k_{02}} \\
    Q_3(s) &= \frac{k_{31} Q_1(s)}{s+k_{13} + k_{03}} \\
    s \, Q_1(s) + (k_{21} + k_{01}) Q_1(s) - \frac{k_{12}k_{21} Q_1(s)}{s+k_{12} + k_{02}} - \frac{k_{13}k_{31} Q_1(s)}{s+k_{13} + k_{03}} &= U_1(s) \\
    Y_1(s) &= \frac{Q_1(s)}{V_1} \\
    H(s) &= \frac{Y_1(s)}{U_1(s)}
    \end{empheq}



\end{document}

The problem is that the numbers of equations are not on the same row of equations, but on another row. How can I fix it?

Thank you so much for your time.

5

If you can load geometry, you get more sensible margins, and the equations fit the text width. Other than that, you can split the middle row. In my opinion, the long part of the middle line should be on the right, unless you have serious reasons to do the other way:

\documentclass{article}
\usepackage{subfigure,graphicx,amssymb, amsfonts,physics,empheq}
\usepackage{geometry}

\begin{document}

    \begin{empheq}[left=\empheqlbrace]{align}
    Q_2(s) &= \frac{k_{21} Q_1(s)}{s+k_{12} + k_{02}} \\
    Q_3(s) &= \frac{k_{31} Q_1(s)}{s+k_{13} + k_{03}} \\
    s \, Q_1(s) + (k_{21} + k_{01}) Q_1(s) - \frac{k_{12}k_{21} Q_1(s)}{s+k_{12} + k_{02}} - \frac{k_{13}k_{31} Q_1(s)}{s+k_{13} + k_{03}} &= U_1(s) \\
    Y_1(s) &= \frac{Q_1(s)}{V_1} \\
    H(s) &= \frac{Y_1(s)}{U_1(s)}
    \end{empheq}
    \bigskip

    \begin{empheq}[left=\empheqlbrace]{align}
    Q_2(s) &= \frac{k_{21} Q_1(s)}{s+k_{12} + k_{02}} \\
    Q_3(s) &= \frac{k_{31} Q_1(s)}{s+k_{13} + k_{03}} \\
    U_1(s)&=s \, Q_1(s) + (k_{21} + k_{01}) Q_1(s) - \frac{k_{12}k_{21} Q_1(s)}{s+k_{12} + k_{02}} - \frac{k_{13}k_{31} Q_1(s)}{s+k_{13} + k_{03}}\\
    Y_1(s) &= \frac{Q_1(s)}{V_1} \\
    H(s) &= \frac{Y_1(s)}{U_1(s)}
    \end{empheq}
    \bigskip

    \begin{empheq}[left=\empheqlbrace]{align}
    Q_2(s) &= \frac{k_{21} Q_1(s)}{s+k_{12} + k_{02}} \\
    Q_3(s) &= \frac{k_{31} Q_1(s)}{s+k_{13} + k_{03}} \\
    U_1(s)&=\begin{multlined}[t] s \, Q_1(s) + (k_{21} + k_{01}) Q_1(s) \\- \frac{k_{12}k_{21} Q_1(s)}{s+k_{12} + k_{02}} - \frac{k_{13}k_{31} Q_1(s)}{s+k_{13} + k_{03}}\end{multlined}\\
    Y_1(s) &= \frac{Q_1(s)}{V_1} \\
    H(s) &= \frac{Y_1(s)}{U_1(s)}
    \end{empheq}

\end{document} 

enter image description here

Unrelated: the subfigure package is obsolete and is no more maintained. You should replace it with the subcaption package, and its subfigure environment. Also, you don't have to load amsmath, nor mathtools with empheq: it does it for you.

  • Excellent @Bernard. Just what I wanted. – Gennaro Arguzzi Jan 19 '18 at 15:46
  • @GennaroArguzzi, Bernard is an excellent user and excellent prof. +1 – Sebastiano Jan 19 '18 at 20:35
3

Your equation is very close to the text width which causes problems, as you can see. This is a known issue, that is not likely to be fixed.

You could try this

\documentclass{article}
\usepackage{subfigure,graphicx,amsmath,amssymb, amsfonts,physics,empheq}
\begin{document}
%show the text width
\noindent\rule\textwidth{2mm}

\begin{empheq}[left=\empheqlbrace]{align}
  Q_2(s) &= \frac{k_{21} Q_1(s)}{s+k_{12} + k_{02}} \\
  Q_3(s) &= \frac{k_{31} Q_1(s)}{s+k_{13} + k_{03}} \\
  \begin{aligned}[b]
    s \, Q_1(s) &+ (k_{21} + k_{01}) Q_1(s)
    \\
    &- \frac{k_{12}k_{21}
      Q_1(s)}{s+k_{12} + k_{02}} - \frac{k_{13}k_{31} Q_1(s)}{s+k_{13}
      + k_{03}}
  \end{aligned}
&= U_1(s) \\
  Y_1(s) &= \frac{Q_1(s)}{V_1} \\
  H(s) &= \frac{Y_1(s)}{U_1(s)}
\end{empheq}
\end{document}
1

You could stack the long line.

\documentclass{article}
\usepackage{subfigure,graphicx,amsmath,amssymb, amsfonts,physics,empheq}
\usepackage{tabstackengine}
\TABstackMath
\TABstackMathstyle{\displaystyle}
\setstackgap{S}{6pt}
\begin{document}
    \begin{empheq}[left=\empheqlbrace]{align}
    Q_2(s) &= \frac{k_{21} Q_1(s)}{s+k_{12} + k_{02}} \\
    Q_3(s) &= \frac{k_{31} Q_1(s)}{s+k_{13} + k_{03}} \\
    {\tabbedShortstack[l]{s \, Q_1(s) + &(k_{21} + k_{01}) Q_1(s)-\\
     &\frac{k_{12}k_{21} Q_1(s)}{s+k_{12} + k_{02}} - 
     \frac{k_{13}k_{31} Q_1(s)}{s+k_{13} + k_{03}}}} &= U_1(s) \\
    Y_1(s) &= \frac{Q_1(s)}{V_1} \\
    H(s) &= \frac{Y_1(s)}{U_1(s)}
    \end{empheq}
\end{document}

enter image description here

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.