[Tex/LaTex] How to change looks of margin notes using memoir

marginparmemoir

I have spent some time now trying to figure out how to change the looks of the margin notes produced by the memoir class. I would like to try ragged right and ragged left in italics (so they align with the magin on each page) but I can't even begin to effect the looks of them even a little.

Page 250 of the memoir documentation has made me believe the following example code should change the look of them but no such luck:

\documentclass{memoir}

\newcommand*{\sideparform}{\raggedleft}
\newcommand*{\sideparfont}{\itshape}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris hendrerit
justo vel lorem eleifend id porttitor nunc dictum. Aenean ut iaculis sem.
Fusce urna augue, sagittis a dignissim at, lobortis eget purus. Duis
pellentesque commodo enim. Maecenas nec mi sed sapien iaculis congue. Proin
ut justo erat. Etiam tincidunt ornare sagittis. Suspendisse potenti.
Vivamus metus nisl, malesuada eu dignissim ac, congue eu arcu. Praesent ac
mollis nisl. Integer pulvinar dui vel sem viverra hendrerit. Donec non quam
leo. Cras metus leo, malesuada nec fermentum ut, aliquam id mi. Integer sit
amet semper nibh. Integer dictum volutpat nisi, nec luctus arcu vulputate
blandit. Sed tristique scelerisque mi id auctor. Vestibulum ac sem elit.
Pellentesque venenatis imperdiet turpis eu suscipit.

\marginpar{Lorem ipsum dolor sit amet, consectetur adipiscing elit.}
Aliquam lectus nisl, mattis at adipiscing nec, semper sit amet risus. In
ultrices eros vel ligula bibendum pretium. Ut quis purus tempus turpis
facilisis varius sit amet vitae arcu. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus mus. Donec nibh libero,
interdum sit amet ultricies pretium, vulputate sit amet odio. Nunc quam
nisi, lacinia ac pulvinar et, fermentum quis enim. Suspendisse eu blandit
lectus. Nulla neque urna, molestie ut faucibus et, suscipit porta metus. In
hac habitasse platea dictumst. Maecenas orci ligula, mattis eu malesuada
ut, hendrerit a sem. Maecenas venenatis dapibus massa quis tempor.
Vestibulum lobortis mattis mi, at molestie sem accumsan vitae.

\end{document}

Clearly I am doing something wrong, and it's probably going to be emberassing to find out, but please, what is it? 🙂

EDIT

Based on the answer by Seamus I came
up with this:

\newcommand\mymarginpar[1]{
\marginpar{\flushright \checkoddpage 
              \ifoddpage \flushleft \fi 
           \textit{#1}}}

I am not happy with this though. It
feels complicated… Do I really have
to create my own \mymarginpar?

Best Answer

\sideparform is not used by \marginpar, as the name suggest it is used within the \sidepar. Memoir has several margin writing macros, and in the case of \marginpar we actually use the \marginpar base from the LaTeX kernel, thus we currently offer no manner of customization for it. We may change this in the future. For now assuming you do not use the optional argument in \marginpar, this may be useful (requires the latest memoir):

\marginparmargin{outer}
\let\oldmarginpar\marginpar
\renewcommand\marginpar[2][]{%
  \oldmarginpar{\mpjustification #2}}

The \marginparmargin is required for \mpjustification to work, it follows the placement and typesets the text flush against the textblock.