Add an image in the right margin

I can add text in the right margin:

\marginpar{test}


But how can I add an image.png in the right margin?

• \marginpar{\includegraphics{image}} Aug 18 '15 at 21:59
• You might want to use [width=\marginparwidth] with that. Aug 19 '15 at 0:02

I made the sidenotes package for this purpose. Here is an example.

\documentclass{article}

\usepackage{sidenotes}
\usepackage{lipsum} % provides the dummy text
\usepackage{mwe} % provides the example image

\begin{document}
\lipsum[1]
\begin{marginfigure}%
\includegraphics[width=\marginparwidth]{example-image-a}%
\caption{This is in the margin.}%
\end{marginfigure}%
\lipsum[2]

\end{document}


The output:

You can find more information using the package manual or you can use \documentclass{caesar_book} if you want to start with reasonable margin widths and such. There is a tufte-book class as well and I believe that memoirprovides this functionality as well.