2

I'm trying to write a system of matrices, but my code is wrong (I'm using empheq):

\documentclass{article}
\usepackage{amsmath, amssymb, amsfonts, empheq}

\begin{document}

\begin{empheq}[left=\empheqlbrace]{align}
\[
\begin{bmatrix}
    \dot{q}_1 \\
    \dot{q}_2
\end{bmatrix}
=
\begin{bmatrix}
    - (k_{21} + k_{01}) & k_{12} \\
    k_{21}              & - (k_{12} + k_{02})
\end{bmatrix}
\begin{bmatrix}
    q_1 \\
    q_2
\end{bmatrix}
+
\begin{bmatrix}
    1 \\
    0
\end{bmatrix}
u
\]

\[
\begin{bmatrix}
    y_1 \\
    y_2
\end{bmatrix}
=
\begin{bmatrix}
    \frac{1}{V_1} \\
    0
\end{bmatrix}
\begin{bmatrix}
    q_1 \\
    q_2
\end{bmatrix}
\]
\end{empheq}

\end{document}

Thank you very much.

6

empheq starts math mode, so don't use \[ .. \] in addition to empheq. Remove all \[ and \], indicate the alignment points with an & before the = in each row, and add a linebreak with \\ after the u in the first line.

output of code

\documentclass{article}
\usepackage{amsmath, amssymb, amsfonts, empheq}

\begin{document}

\begin{empheq}[left=\empheqlbrace]{align}
\begin{bmatrix}
    \dot{q}_1 \\
    \dot{q}_2
\end{bmatrix}
&= % <-- added &
\begin{bmatrix}
    - (k_{21} + k_{01}) & k_{12} \\
    k_{21}              & - (k_{12} + k_{02})
\end{bmatrix}
\begin{bmatrix}
    q_1 \\
    q_2
\end{bmatrix}
+
\begin{bmatrix}
    1 \\
    0
\end{bmatrix}
u \\ % <-- added \\
\begin{bmatrix}
    y_1 \\
    y_2
\end{bmatrix}
&= % added &
\begin{bmatrix}
    \frac{1}{V_1} \\
    0
\end{bmatrix}
\begin{bmatrix}
    q_1 \\
    q_2
\end{bmatrix}
\end{empheq}

\end{document}
| improve this answer | |
5

nested equations in empheq (actually in any math) environments is not allowed. correct code in your case is (if i understand your code correctly):

\documentclass{article}
\usepackage{amssymb, amsfonts, empheq}

\begin{document}

\begin{empheq}[left=\empheqlbrace]{align}
\begin{bmatrix}
    \dot{q}_1 \\
    \dot{q}_2
\end{bmatrix}
=
\begin{bmatrix}
    - (k_{21} + k_{01}) & k_{12} \\
    k_{21}              & - (k_{12} + k_{02})
\end{bmatrix}
\begin{bmatrix}
    q_1 \\
    q_2
\end{bmatrix}
+
\begin{bmatrix}
    1 \\
    0
\end{bmatrix}
u
\begin{bmatrix}
    y_1 \\
    y_2
\end{bmatrix}
=
\begin{bmatrix}
    \frac{1}{V_1} \\
    0
\end{bmatrix}
\begin{bmatrix}
    q_1 \\
    q_2
\end{bmatrix}
\end{empheq}

\end{document}

enter image description here

| improve this answer | |
  • I'm up voting your answer because I wrote the question with typos. This confused the readers. – Gennaro Arguzzi Dec 8 '17 at 11:38

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.