2

How can I improve the alignment inside this matrix equation?

enter image description here

My Tex code is

\begin{equation}
\begin{bmatrix}
d\varepsilon_v\\
d\varepsilon_q
\end{bmatrix}
= 
\left[
\begin{matrix}
\dfrac{1}{K^{'}} & 0 \\ 
0 & \dfrac{1}{3 G^{'}} 
\end{matrix}
+\ 
\dfrac{
\begin{matrix}
\dfrac{\partial g}{\partial p^{'}} \dfrac{\partial f}{\partial q} & 
\dfrac{\partial g}{\partial p^{'}} \dfrac{\partial f}{\partial q} \\
\dfrac{\partial g}{\partial q} \dfrac{\partial f}{\partial p^{'}} & 
\dfrac{\partial g}{\partial q} \dfrac{\partial f}{\partial q}
\end{matrix}}{P}
\right]
\begin{bmatrix}
dp^{'}\\
dq
\end{bmatrix}
\label{eq:149}
\end{equation}

2
  • 4
    Welcome. I find it hard to guess what the expected output would be.
    – egreg
    Commented Jul 31, 2023 at 9:43
  • 2
    Please always provide MWE (Minimal working example), a small but complete document with your matrix, which we can compile as it is.
    – Zarko
    Commented Jul 31, 2023 at 9:58

1 Answer 1

4

Something like this?

enter image description here

Observe that I've also replaced all instances of ^{'} with '. (Aside: In math mode, ' resolves to ^{\prime}.)

\documentclass{article} % or some other suitable document class
\usepackage{amsmath}    % for 'bmatrix' and 'pmatrix' env. and '\dfrac' macro
\usepackage{booktabs}   % for '\addlinespace' macro
\newcommand\mystrut{\vphantom{\partial p'}} % typographic strut
     % to fine-tune position of cells in first inner 2x2 matrix

\begin{document}

\begin{equation} \label{eq:149}
\begin{bmatrix}
  d\varepsilon_v \\
  \addlinespace
  d\varepsilon_q
\end{bmatrix}
=
\left( % delimiter for sum of 2x2 matrices
  \begin{bmatrix} % first "inner" 2x2 matrix
    \dfrac{1}{K'\mystrut} & 0 \\
    \addlinespace
    0 & \dfrac{1}{3G'\mystrut}
  \end{bmatrix}
  +
  \dfrac{1}{P} % multiply matrix with a scalar
  \begin{bmatrix} % second "inner" 2x2 matrix
    \dfrac{\partial g}{\partial p'} \dfrac{\partial f}{\partial q} &
    \dfrac{\partial g}{\partial p'} \dfrac{\partial f}{\partial q} \\
    \addlinespace
    \dfrac{\partial g}{\partial q}  \dfrac{\partial f}{\partial p'} &
    \dfrac{\partial g}{\partial q}  \dfrac{\partial f}{\partial q}
  \end{bmatrix}
\right)
\begin{bmatrix}
  dp'\\
  \addlinespace
  dq
\end{bmatrix}
\end{equation}

\end{document}
6
  • Interesting guess, but I’d switch parentheses with brac, because matrices seem to use the latter fences.
    – egreg
    Commented Jul 31, 2023 at 12:54
  • @egreg - Thanks for your suggestion. I've modified the code to use square brackets as delimiters of all matrices and column vectors.
    – Mico
    Commented Jul 31, 2023 at 13:32
  • But the outer fences, enclosing the matrix sum, should probably be parentheses
    – egreg
    Commented Jul 31, 2023 at 13:35
  • Oh, +1 for the mind reading :-). But I agree with egreg: if matrices are denoted by brackets then the outer fences should rather be parentheses.
    – campa
    Commented Jul 31, 2023 at 13:41
  • @egreg - Thanks, I got it now. :-)
    – Mico
    Commented Jul 31, 2023 at 13:47

You must log in to answer this question.

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