# Vertical alignment of marginnote and section heading

Following on from a previous question I asked, I am now having difficulty in vertically aligning my margin note with a section heading. To be clear, the problem is only when I invoke the solution suggested in that question.

A minimal working example is as follows:

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

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

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


yielding the following output:

in which the margin note is vertically displaced upwards from where it should be. If I undo the changes from the previous question (comment out the bits between \makeatletter and \makeatother), the vertical alignment is correct, but now the horizontal alignment is wrong (centred, rather than ragged right):

Now, I can manually insert a \vskip into the renewed \raggedrightmarginnote and \raggedleftmarginnote, but I don't know what value to use for this (that would be robust to e.g. font size changes). Is there some way to get the correct displacement for this?

It's also worth pointing out that removing \normalsize from the defined \instruction command gives the correct vertical position of the text (as might be expected), but I'd like all the margin notes to be the same size.

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

\usepackage{ragged2e}
\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}


• Great, this does work. Just for completeness, I added /normalsize just before #1 in the instruction command. Can you tell me why this works? – Henry Gomersall Jun 14 '14 at 7:13
• I use only the official interface to the margin note. And that is only \marginnote and not the internal macros. – user2478 Jun 14 '14 at 7:17