[Tex/LaTex] Add an image in the right margin

graphicsmargins

I can add text in the right margin:

\marginpar{test}

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

Best Answer

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:

marginfigure image

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.