3

Let's say I want to include an oversized margin figure that is allowed to stick into the normal text area using adjustbox, perhaps by something like this:

\documentclass{memoir}
\usepackage{adjustbox}
\usepackage{lipsum}

\begin{document}

\begin{marginfigure}
\adjustbox{lap=-\marginparwidth,caption=Caption,nofloat=figure}{\includegraphics[width=2\marginparwidth]{example-image-a}}
\end{marginfigure}

\lipsum[1-4]

\end{document}

This results in

enter image description here

which is mostly what I want, except for the placement of the caption.

Is it possible to have the caption move along with the actual content of the adjustbox? I'm not concerned with the content overlapping the normal text block (this will be taken care of in another way).

I know there are probably a lot better ways to do what I'm trying to do, but I'm editing a large document and prefer to do something similar to what the original authors have done, keeping their choice of syntax in some user defined macros.

mrf
  • 904
  • What does this mean: "Is it possible to have the caption move along with the actual content of the adjustbox? " – Steven B. Segletes Feb 08 '18 at 13:54
  • 1
    @StevenB.Segletes Adjustbox sets the caption, but it's located in the same place as it would be without the lap=-\marginparwidth. I had expected that the caption would be set inside the same box that is "moved" by the lap option. – mrf Feb 08 '18 at 14:01

1 Answers1

2

When I understand you correctly, then you want the caption centered below the image, right?

You need to first add the caption, then apply lap. This is best done by two nested \adjustbox calls as the (no-)float options are processed always after the normal ones:

\documentclass{memoir}
\usepackage{adjustbox}
\usepackage{lipsum}

\begin{document}

\begin{marginfigure}
\adjustbox{varwidth=\linewidth,lap=-\marginparwidth}{%
    \adjustbox{center,caption=Caption,nofloat=figure}{\includegraphics[width=2\marginparwidth]{example-image-a}}%
}
\end{marginfigure}

\lipsum[1-4]

\end{document}

enter image description here

If you want the caption on the left change center to left and the lap amount to -1.5\marginparwidth.

Martin Scharrer
  • 262,582