Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
4  
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

1 Answer 1

Thanks to Werner's suggestion of providing a minimal working example I was able to establish that an inherited line of code:

% The offending line:
% \renewcommand*{\raggedleftmarginnote}{}

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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