# How do I produce a horizontal space the size of an underbracket?

I have an equation that is too long to fit on one line, so I put a few terms on a second line using amsmath's aligned environment. However, the first line of the equation contains an underbrace that causes the second line to be placed too far down below the original equation, like so:

I was able to reduce the gap by eye using a negative space after the first line break, but I would like to know how to reduce the gap in a way such that the spacing between the first and second line remains exactly the same as it would be without the underbrace, like this:

I believe that the answer to my question involves getting the height of just the underbrace without the text above and inserting a negative space of that magnitude after the first line break, but I'm not sure how to do it.

My code is the following:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\begin{document}

\begin{equation*}
\begin{aligned}
P(\underbrace{C_{t}^{d}+I_{t}^{d}+G_{t}^{d}}_{=Y_{t}^{d}}-Y_{t}^{s})+\left(B_{t}^{p}+B_{t}^{g}\right)+\left(M_{t}^{d}-M_{t}^{s}\right)&=\left(1+r_{t-1}\right)\left(B_{t-1}^{p}+B_{t-1}^{g}\right)\\
&+\left(M_{t-1}^{d}-M_{t-1}^{s}\right)
\end{aligned}
\end{equation*}

\end{document}


\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\begin{document}

You have:
\begin{equation*}
\begin{aligned}
P(\underbrace{C_{t}^{d}+I_{t}^{d}+G_{t}^{d}}_{=Y_{t}^{d}}-Y_{t}^{s})+\left(B_{t}^{p}+B_{t}^{g}\right)+\left(M_{t}^{d}-M_{t}^{s}\right)&=\left(1+r_{t-1}\right)\left(B_{t-1}^{p}+B_{t-1}^{g}\right)\\
&+\left(M_{t-1}^{d}-M_{t-1}^{s}\right)
\end{aligned}
\end{equation*}

You want:
\begin{equation*}
\begin{aligned}
P(\smash{\underbrace{C_{t}^{d}+I_{t}^{d}+G_{t}^{d}}_{=Y_{t}^{d}}}-Y_{t}^{s})+\left(B_{t}^{p}+B_{t}^{g}\right)+\left(M_{t}^{d}-M_{t}^{s}\right)&=\left(1+r_{t-1}\right)\left(B_{t-1}^{p}+B_{t-1}^{g}\right)\\
&+\left(M_{t-1}^{d}-M_{t-1}^{s}\right)
\end{aligned}
\end{equation*}
or rather
\begin{equation*}
\begin{aligned}
P(\smash{\underbrace{C_{t}^{d}+I_{t}^{d}+G_{t}^{d}}_{=Y_{t}^{d}}}-Y_{t}^{s})+\left(B_{t}^{p}+B_{t}^{g}\right)+\left(M_{t}^{d}-M_{t}^{s}\right)&=\left(1+r_{t-1}\right)\left(B_{t-1}^{p}+B_{t-1}^{g}\right)\\