3

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}

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

yielding the following output:

Vertically misaligned 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):

enter image description here

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.

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

enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.