6

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?

1
  • In asking this question I though I was asking something trivial but judging from the two answers I have received 3 hours after asking the question I am beginning to think this was not so... suprised
    – jonalv
    Mar 11, 2011 at 16:05

2 Answers 2

5

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

5
  • Ah. mpjustification is what I was looking for in my answer...
    – Seamus
    Mar 11, 2011 at 13:02
  • hm I am trying this but I get: "! Undefined control sequence. <argument> \mpjustification"
    – jonalv
    Mar 11, 2011 at 15:57
  • I am getting undefined control sequence \marginparmargin When I do this.
    – Seamus
    Mar 11, 2011 at 17:04
  • @seamus please update your LaTeX installation, your memoir is too old
    – daleif
    Mar 11, 2011 at 17:38
  • Wow, I reread you answer for the -- hm actually I don't know how many times I have read it but anyway -- and I realized that maybe I should try using the \sidepar command instead. Now things actually works much better and I can even set margin notations next to floats! I was on the completely wrong track... I am not able to get your code example to work but the first sentence of your answer made me think of the solution so I am going to mark this as accepted answer and be done with it :)
    – jonalv
    Mar 11, 2011 at 18:04
2

Memoir defines \sidepar which acts more or less like \marginpar and it also defines \sidebar (with a b) which set at the top of the page block for the page they are on. For \sidebar but not \sidepar memoir defines commands to set the text:

\documentclass{memoir}

\begin{document}

\renewcommand*{\sidebarform}{\raggedright}
\renewcommand*{\sidebarfont}{\itshape}


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.
\sidebar{ Lorem ipsum o dolor sit amet, consectetur adipiscing elit.}

\end{document}

Note I've put the sidebar note at the end so you can see that it floats to the top. Also note that I used \renewcommand rather than \newcommand because memoir defines a default... This works, but doesn't do quite what you want.

The easiest way to do what you want is perhaps define your own wrapper for marginpars like so:

\newcommand\mymarginpar[1]{\marginpar{\textit{\flushleft #1}}}

This should work as you want... Although it will always flush left, so that's not going to work with two-sided setups... Let me think about that one.

1
  • Yea I guess this works, but I was not expecting to have to wrap marginpar in a new command to be able to change the styling of it. I guess next problem is how to make it behave nicely on two-sided setups...
    – jonalv
    Mar 11, 2011 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .