I have an equation in which I want to use underbrace , but the braces appear in different heights since one term is longer than the other. Here is an example:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{physics}
\begin{document}
\begin{align}
\underbrace{-\frac{1}{M}\vec{p}{\partial\vec{p}}\frac{\partial\mathcal{P}}{\partial\vec{x}}}_{\frac{\partial\mathcal{H}} {\partial\vec{p}}}+\underbrace{\mathcal{U}'}_{\frac{\partial\mathcal{H}}{\partial\vec{x}}}\mathcal{P}
\end{align}
\end{document}
I tried using vphantom, but then my equation got distorted noticeably. How can I fix this ? Thank you in advance.
\vphantom{\frac{\partial\mathcal{P}}{\partial\vec x}}
inside the secondunderbrace
.