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
\newif\ifismemoirloaded\ismemoirloadedfalse
\newif\ifisabntexloaded\isabntexloadedfalse
\@ifclassloaded{memoir}{%
\ismemoirloadedtrue%
}{}
\@ifclassloaded{abntex2}{%
\isabntexloadedtrue%
}{}
\newcommand{\addGoToSummary}
{%
\@ifundefined{printpartnum}{\message{printpartnum patch for addGoToSummary could NOT
be applied because there is no printpartnum command available!^^J}}{%
\let\oldAddGoToprintpartnum\printpartnum
\xapptocmd{\printpartnum}{~\protect\goToSummaryText}{}{}
}
}
\makeatother
\let\oldAddGoTotableofcontents\tableofcontents
% Insert internal document link
\renewcommand{\tableofcontents}{%
\hypertarget{summary}%
\oldAddGoTotableofcontents%
}
\begin{document}
\addGoToSummary
\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
\printpartname \partnamenum \printpartnum
\midpartskip
\fi
\printparttitle{#2}\par}%
\@endpart}
Related questions:
- Why abntex2 class is inserting a new line after the chapter title?
- How to automatically put a [Go To Summary] | [Go Back] on each section?
- How can the go to summary be fixed so the \section[Some]{Some more} does not throw all these errors?
- What is the equivalent to `\Sectionformat` on memoir class for `\Chapterformat`?
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:
\newif\ifismemoirloaded\ismemoirloadedfalse
\@ifclassloaded{memoir}{%
\ismemoirloadedtrue%
}{}
\newcommand{\addGoToSummary}
{%
\@ifundefined{printparttitle}{\message{printparttitle patch for addGoToSummary could NOT
be applied because there is no printparttitle command available!^^J}}{%
\let\oldAddGoToprintparttitle\printparttitle
\let\oldAddGoToprintpartnum\printpartnum
\xapptocmd{\printpartnum}{%
\let\oldAddGoTomidpartskip\midpartskip%
\renewcommand{\midpartskip}{\par\vskip 30pt}%
}{}{}
\xapptocmd{\printparttitle}{%
\let\midpartskip\oldAddGoTomidpartskip%
~\protect\goToSummaryText%
}{}{}
}
}
\newcommand{\removeGoToSummary}
{%
\@ifundefined{printparttitle}{\message{printparttitle patch for removeGoToSummary could NOT
be applied because there is no printparttitle command available!^^J}}{%
\let\printparttitle\oldAddGoToprintparttitle
\let\printpartnum\oldAddGoToprintpartnum
}
}
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.
\let\oldAddGoToprintparttitle\printparttitle
\let\oldAddGoToprintpartnum\printpartnum
\xapptocmd{\printpartnum}{%
\let\oldAddGoTomidpartskip\protect\midpartskip%
}{}{}
\xapptocmd{\printparttitle}{%
\let\midpartskip\oldAddGoTomidpartskip%
~\protect\goToSummaryText%
}{}{}
Correction, this did not work at all. When I tried to set:
\begin{document}
\addGoToSummary
\setlength\midchapskip{50pt}
\part{My}
\end{document}
I was completely ignored and the distance still about 32pt.

