边注和章节标题的垂直对齐

边注和章节标题的垂直对齐

先前的问题我问道,我现在很难将边注与章节标题垂直对齐。明确地说,问题只在我调用该问题中建议的解决方案时出现。

最小工作示例如下:

\documentclass[8pt,a6paper,twoside,parskip=half]{scrartcl}
\RequirePackage{geometry}

% Configure the section style
\RequirePackage{sectsty}
\allsectionsfont{\centering\normalfont\scshape}

\usepackage[fulladjust]{marginnote}

\newcommand{\instruction}[1]{\mbox{}\marginnote{\normalsize\emph{#1}}}

\makeatletter
\renewcommand\marginfont{\normalfont}
\renewcommand\raggedleftmarginnote{\@parboxrestore\@marginparreset\raggedleft}
\renewcommand\raggedrightmarginnote{\@parboxrestore\@marginparreset\raggedright}
\makeatother

\begin{document}
\centering
\section*{A Section Heading\instruction{Do something long here}}
Lorem ipsum dolor sit amet, intellegat definitionem ad eos. Case possim vis
cu, salutandi iudicabit evertitur te mei, aliquip albucius usu et. Mundi
graeco eum in. In elit posse his. Erant primis consulatu est ex, cu sit
ferri reque epicurei, eam an veniam lucilius intellegam.
\end{document}

输出结果如下:

垂直错位输出

其中边注在垂直方向上偏离了其应在的位置。如果我撤消上一个问题中的更改(注释掉\makeatletter和之间的位\makeatother),垂直对齐是正确的,但现在水平对齐是错误的(居中,而不是右侧参差不齐):

在此处输入图片描述

现在,我可以手动将 a 插入\vskip到更新的\raggedrightmarginnote和中\raggedleftmarginnote,但我不知道要为此使用什么值(例如,对于字体大小的变化,该值必须是可靠的)。有没有办法得到正确的位移?

还值得指出的是,\normalsize从定义的\instruction命令中删除会给出文本的正确垂直位置(正如预期的那样),但我希望所有边注都是相同的大小。

答案1

\documentclass[8pt,a6paper,twoside,parskip=half]{scrartcl}
\RequirePackage[showframe]{geometry}
% Configure the section style
\RequirePackage{sectsty}
\allsectionsfont{\centering\normalfont\scshape}

\usepackage{ragged2e}
\usepackage[fulladjust]{marginnote}
\def\instruction#1{\marginnote[\sloppy\RaggedLeft\hspace{0pt}#1]{\sloppy\RaggedRight\hspace{0pt}#1}}
\let\marginfont\itshape

\begin{document}
\centering
\section*{A Section Heading\instruction{Do something long here}}
Lorem ipsum dolor sit amet, intellegat definitionem ad eos. Case possim vis
cu, salutandi iudicabit evertitur te mei, aliquip albucius usu et. Mundi
graeco eum in. In elit posse his. Erant primis consulatu est ex, cu sit
ferri reque epicurei, eam an veniam lucilius intellegam.

\newpage
\section*{A Section Heading\instruction{Do something long here}}
Lorem ipsum dolor sit amet, intellegat definitionem ad eos. Case possim vis
cu, salutandi iudicabit evertitur te mei, aliquip albucius usu et. Mundi
graeco eum in. In elit posse his. Erant primis consulatu est ex, cu sit
ferri reque epicurei, eam an veniam lucilius intellegam.

\end{document}

在此处输入图片描述

相关内容