更新

更新

运行此示例:

\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}

我们得到这个PDF:

在此处输入图片描述

如果我将其改为\printpartnum,则和\printparttitle之间的垂直间距就会减小:\printpartname\printparttitle

在此处输入图片描述

我怎样才能修补并保持和\printpartname之间的原始间距?\printpartname\printparttitle

查看该\part命令的回忆录类代码,我不明白为什么间距会中断:

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

相关问题:

  1. 为什么 abntex2 类在章节标题后插入新行?
  2. 如何在每个部分自动添加[转至摘要] | [返回]?
  3. 如何修复转到摘要以便 \section[Some]{Some more} 不会抛出所有这些错误?
  4. 回忆录类中的“\Sectionformat”与“\Chapterformat”等效的是什么?

更新

我设法用这个技巧修复了它,但仍然无法正常工作。

如果这是一个实际的解决方案,我更喜欢通用的解决方案,因为如果有人将更改为\midpartskip其他内容50pt,则它们的值将被30pt此处的设置覆盖:

    \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
        }
    }

这另一个东西也有类似的效果,但距离没有达到 100% 相等。距离比 稍大30pt。我添加了\protect\midpartskip\midpartskip另一个命令上设置了 。

            \let\oldAddGoToprintparttitle\printparttitle
            \let\oldAddGoToprintpartnum\printpartnum
            \xapptocmd{\printpartnum}{%
                \let\oldAddGoTomidpartskip\protect\midpartskip%
            }{}{}
            \xapptocmd{\printparttitle}{%
                \let\midpartskip\oldAddGoTomidpartskip%
                ~\protect\goToSummaryText%
            }{}{}

更正,这根本不起作用。当我尝试设置时:

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

我完全被忽略了,距离仍然在32pt

答案1

您缺少一个群组:

\newcommand{\goToSummaryText}{{% group here
    \small\mdseries
    \hyperlink{summary}{\textcolor{ultramarine}{$\leftleftarrows$}}
    {$|$}
    \Acrobatmenu{GoBack}{\textcolor{ultramarine}{$\leftarrow$}}%
}}

原始定义\small影响了基线跳过,因此您得到了\lineskip间距。

相关内容