# How do I put a figure with a caption nicely in my margin?

I may be going in the right direction, but as you can see from compiling, my image is cropped. What to do?

\documentclass[]{memoir}

% Lipsum
\usepackage{kantlipsum}

% Sidenote attempt
\usepackage{caption}
\usepackage[textwidth=25mm]{todonotes}
\setlength{\marginparwidth}{25mm}

%% Pagesize
\setstocksize{226mm}{146mm}
\settrimmedsize{220mm}{140mm}{*}
\settrims{0.3cm}{0.3cm}
\renewcommand\trimmarkscolor{\color{red}}
\setlrmarginsandblock{2cm}{2cm}{*}
\setulmarginsandblock{2.5cm}{2.5cm}{*}
\checkandfixthelayout
\fixpdflayout

% Changemargin environment
\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}

\begin{document}

\chapter{Larger margins}

\begin{changemargin}{2cm}{2cm}

\marginpar{
\includegraphics[width=25mm]{example-image-a}
\captionof{figure}{This is a test case.}
\label{fig:test}
}
\kant[1-2]

\end{changemargin}

\chapter{Normal margins}

\kant[3-4]

\end{document}


A couple of things. You have increased the margins but have not changed the horizontal positioning of marginal notes. I think that you could have used thememoir adjustwith environment instead of your changemargin environment.

Based on your MWE try the following:

...
\chapter{Larger margins}
\begin{adjustwidth}{2cm}{2cm} % increase margins by 2cm
\setlength{\marginparsep}{-1cm}  % move marginal notes closer to the reduced textwidth
\marginpar{
\includegraphics[width=25mm]{example-image-a}
\captionof{figure}{This is a test case.}
\label{fig:test}
}
\kant[1-2]

Or if you want to keep your changemargin add \setlength{\marginparsep}{-1cm} to its definition.