# Why xapptocmd is reducing the vertical space between \partname and \parttile?

Running this example:

\documentclass[
10pt,
a5paper
]{memoir}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}

\definecolor{ultramarine}{RGB}{0,32,96}
\RequirePackage{xpatch}
\RequirePackage{amssymb}
\RequirePackage{hyperref}
\newcommand{\goToSummaryText}{%
\small\mdseries
\hyperlink{summary}{\textcolor{ultramarine}{$\leftleftarrows$}}
{$|$}
\Acrobatmenu{GoBack}{\textcolor{ultramarine}{$\leftarrow$}}
}
\makeatletter
}{}
}{}
{%
\@ifundefined{printpartnum}{\message{printpartnum patch for addGoToSummary could NOT
be applied because there is no printpartnum command available!^^J}}{%
\xapptocmd{\printpartnum}{~\protect\goToSummaryText}{}{}
}
}
\makeatother

\renewcommand{\tableofcontents}{%
\hypertarget{summary}%
}

\begin{document}
\part{My}
\end{document}

We get this PDF:

If if I change \printpartnum to \printparttitle, the vertical spacing between the \printpartname and \printparttitle is reduced:

How can I patch the \printpartname while keeping the original spacing between \printpartname and \printparttitle?

Looking at the memoir class code for the \part command, I cannot understand why the spacing is breaking:

{\centering
\interlinepenalty \@M
\parskip\z@
\normalfont
\ifnum \c@secnumdepth >-2\relax
\midpartskip
\fi
\printparttitle{#2}\par}%
\@endpart}

Related questions:

# Update

I managed to fix it with this hack, but still not working correctly.

I would prefer a generic solution than this, if this is an actual solution because if someone changes the \midpartskip to something else as 50pt, their value would be overridden by 30pt set here:

}{}
{%
\@ifundefined{printparttitle}{\message{printparttitle patch for addGoToSummary could NOT
be applied because there is no printparttitle command available!^^J}}{%
\xapptocmd{\printpartnum}{%
\renewcommand{\midpartskip}{\par\vskip 30pt}%
}{}{}
\xapptocmd{\printparttitle}{%
~\protect\goToSummaryText%
}{}{}
}
}
\newcommand{\removeGoToSummary}
{%
\@ifundefined{printparttitle}{\message{printparttitle patch for removeGoToSummary could NOT
be applied because there is no printparttitle command available!^^J}}{%
}
}

This other thing also a similar effect, but the distance did not get 100% equal. The distance was a little bigger than 30pt. I added \protect to \midpartskip and set \midpartskip back on the other command.

\xapptocmd{\printpartnum}{%
}{}{}
\xapptocmd{\printparttitle}{%
~\protect\goToSummaryText%
}{}{}

Correction, this did not work at all. When I tried to set:

\begin{document}
\setlength\midchapskip{50pt}
\part{My}
\end{document}

I was completely ignored and the distance still about 32pt.

\hyperlink{summary}{\textcolor{ultramarine}{$\leftleftarrows$}}
{$|$}
\Acrobatmenu{GoBack}{\textcolor{ultramarine}{$\leftarrow$}}%