Why a matrix equation is not vertically aligned?
Because \dfrac
is higher than other elements of your matrices. Here are two possibilities: use \tfrac
or \vphantom
s.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Arguably simplest solution (thanks to David Carlisle)
\begin{equation} \label{eq:system_dynamics_0}
\begin{bmatrix}
m_1+m_2 & \tfrac{1}{2}m_2 L \\[4mm]
\tfrac{1}{2}m_2 L & \tfrac{1}{2}m_2 L^2
\end{bmatrix}
\begin{bmatrix}
\ddot{x} \\[4mm] \ddot{\theta}
\end{bmatrix}
+ \begin{bmatrix}
b & 0 \\[4mm]
0 & c
\end{bmatrix}\begin{bmatrix}
\dot{x} \\[4mm] \dot{\theta}
\end{bmatrix}
+\begin{bmatrix}
k & 0 \\[4mm] 0 & m_2g\tfrac{L}{2}
\end{bmatrix}\begin{bmatrix}
x \\[4mm] \theta
\end{bmatrix}
=\begin{bmatrix}
0 \\[4mm] 0
\end{bmatrix}
\end{equation}
Original proposal 1:
\begin{equation} \label{eq:system_dynamics_l}
\begin{bmatrix}
m_1+m_2 & \tfrac{1}{2}m_2 L \\[4mm]
\tfrac{1}{2}m_2 L & \tfrac{1}{2}m_2 L^2
\end{bmatrix}
\begin{bmatrix}
\ddot{x} \\[4mm] \ddot{\theta}
\end{bmatrix}
+ \begin{bmatrix}
b & 0 \\[4mm]
0 & c
\end{bmatrix}\begin{bmatrix}
\dot{x} \\[4mm] \dot{\theta}
\end{bmatrix}
+\begin{bmatrix}
k & 0 \\[4mm] 0 & m_2g\tfrac{L}{2}
\end{bmatrix}\begin{bmatrix}
x \\[4mm] \theta
\end{bmatrix}
=\begin{bmatrix}
0 \\[4mm] 0
\end{bmatrix}
\end{equation}
In case you want to keep the \verb|\dfrac|s, which is perfectly fine IMHO
\begin{equation} \label{eq:system_dynamics_2}
\begin{bmatrix}
m_1+m_2 & \dfrac{1}{2}m_2 L \\[4mm]
\dfrac{1}{2}m_2 L & \dfrac{1}{2}m_2 L^2
\end{bmatrix}
\begin{bmatrix}\vphantom{\dfrac{1}{2}}
\ddot{x} \\[4mm] \vphantom{\dfrac{1}{2}}\ddot{\theta}
\end{bmatrix}
+ \begin{bmatrix}
\vphantom{\dfrac{1}{2}}b & 0 \\[4mm]
\vphantom{\dfrac{1}{2}}0 & c
\end{bmatrix}\begin{bmatrix}
\vphantom{\dfrac{1}{2}}\dot{x} \\[4mm] \vphantom{\dfrac{1}{2}}\dot{\theta}
\end{bmatrix}
+\begin{bmatrix}
\vphantom{\dfrac{1}{2}}k & 0 \\[4mm] 0 & m_2g\dfrac{L}{2}
\end{bmatrix}\begin{bmatrix}
\vphantom{\dfrac{1}{2}}x \\[4mm] \vphantom{\dfrac{1}{2}} \theta
\end{bmatrix}
=\begin{bmatrix}
\vphantom{\dfrac{1}{2}}0 \\[4mm] \vphantom{\dfrac{1}{2}}0
\end{bmatrix}
\end{equation}
\end{document}
The easiest way to handle Ratios Of Unusual Size (ROUS) is to increase \arraystretch
(macro). Every row starts with a strut of height \arraystretch\ht\strutbox
.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation} \label{eq:system_dynamics_l}
\def\arraystretch{1.7}%
\begin{bmatrix}
m_1+m_2 & \dfrac{1}{2}m_2 L \\
\dfrac{1}{2}m_2 L & \dfrac{1}{2}m_2 L^2
\end{bmatrix}
\begin{bmatrix}
\ddot{x} \\ \ddot{\theta}
\end{bmatrix}
+ \begin{bmatrix}
b & 0 \\
0 & c
\end{bmatrix}\begin{bmatrix}
\dot{x} \\ \dot{\theta}
\end{bmatrix}
+\begin{bmatrix}
k & 0 \\ 0 & m_2g\dfrac{L}{2}
\end{bmatrix}\begin{bmatrix}
x \\ \theta
\end{bmatrix}
=\begin{bmatrix}
0 \\ 0
\end{bmatrix}
\end{equation}
\end{document}