[Tex/LaTex] How to make “draft margin notes” for floats

floatsmarginparmemoir

Page 394 of the memoir manual provides a snippet by Bastian Veelo for making margin comments out over the part of the stock paper that would be cut away. This very handy for making comments only appearing in the draft.

However if I want to comment a float like for example a figure it complains about not being in outer par mode. How can I adopt the code:

\documentclass[draft]{memoir}

\makeatletter
\ifdraftdoc
\newlength{\draftnotewidth} 
\newlength{\draftnotesignwidth} 
\newcommand{\draftnote}[1]{\@bsphack%
{%% do not interfere with settings for other marginal notes 
\strictpagecheck% 
\checkoddpage%
\setlength{\draftnotewidth}{\foremargin}% 
\addtolength{\draftnotewidth}{\trimedge}% 
\addtolength{\draftnotewidth}{-3\marginparsep}% 
\ifoddpage
\setlength{\marginparwidth}{\draftnotewidth}%
\marginpar{\flushleft\textbf{\textit{\HUGE !\ }}\small #1}% 
\else
\settowidth{\draftnotesignwidth}{\textbf{\textit{\HUGE\ !}}}% 
\addtolength{\draftnotewidth}{-\draftnotesignwidth}% 
\marginpar{\raggedleft\makebox[0pt][r]{%% hack around
}% \fi
\parbox[t]{\draftnotewidth}{%%%%%%%%% funny behaviour 
\raggedleft\small\hspace{0pt}#1%
}}\textbf{\textit{\HUGE\ !}}%
}\@esphack} \else
\newcommand{\draftnote}[1]{\@bsphack\@esphack} \fi
\makeatother

\begin{document}
\begin{figure}
\draftnote{Lorem ipsum}
\end{figure}
\end{document} 

to work also with floats?

Best Answer

You can take the \marginnote macro from the marginnote package. It produces something similar to \marginpar, but it is not a float. I made a small example. In principle you should be able to replace the two \marginpars with \marginnotes, but the upper code does not work for me, even if the \draftnote command is outside of the figure environment, so I could not try that.

enter image description here

\documentclass[draft]{memoir}
\usepackage{lipsum}
\usepackage{marginnote}

\begin{document}
\lipsum[1]
\begin{figure}[h]
\marginnote{This is a comment}
\caption{I am a caption}
\end{figure}
\lipsum[2]
\end{document}