# How can I place a marginnote inside a description (or other list environment)

I have a macro (defined with the xparse package) that creates a marginnote. It works as I would like when prepended to normal paragraph text:

\NewDocumentCommand\dates{m g}{%
\IfNoValueTF{#2}
{\marginnote{\scriptsize{#1}}}
{\marginnote{\scriptsize{#2\\#1}}}}


I'd like to use it in a similar way against an item in a description environment, something like:

\begin{description}
\item[Coding and data representation] \dates{June 2009}{September 2009} Some description
\end{description}


However the above snippet places the margin note under the label text, I would like it to appear on the far left of the page lined up with with item. I am happy to create a NewDocumentEnvironment with xparse if that would help me achieve this easier and I am open to better ways of achieving this sort of layout.

Here is a minimal example replicating the issues:

\documentclass{article}
\usepackage{xparse}
\usepackage{marginnote}
\begin{document}
\NewDocumentCommand\dates{m g}{%
\IfNoValueTF{#2}
{\marginnote{\scriptsize{#1}}}
{\marginnote{\scriptsize{#2\\#1}}}}
\renewcommand*{\raggedleftmarginnote}{}
\setlength{\marginparsep}{7pt}
\reversemarginpar

\begin{description}
\item[Coding and data representation] \dates{June 2009}{September 2009} Some description
\end{description}

\end{document}

-
I obtain the expected output when compiling your code snippet. Please add a minimal working example (MWE) that illustrates your problem. This should probably only include marginnote and xparse. Also include the versions of these packages by adding \listfiles before \documentclass, and include that in an edit to your question. –  Werner Jan 21 '12 at 20:25

% The offending line:

Was to blame. I'm not sure of the purpose of the asterix, but I believe this is redefining the raggedleftmarginnote command to do nothing? Perhaps someone could comment to explain why it might have been there. Without it I get the output I desired.
Without *, you are allowed paragraphs within the <replacement text> of the command (re)definition. Otherwise (in the starred version), you're not. –  Werner Jan 24 '12 at 21:15
the purpose of the asterisk is to say this command is not "long", that is, its argument cannot contain a paragraph break. in fact, this definition does cause the command to do nothing, but that is because the expansion is just an open/close brace pair, i.e., nothing. it also specifies no argument; if the original definition (i haven't checked) had an argument, as \newcommand{\raggedleftmarginnote}[1]{...} then if an argument for the command is in the input file with the modified definition, it will be set as ordinary text -- which is undoubtedly not what you want. –  barbara beeton Jan 24 '12 at 21:16