I'm using the Tufte class and I want to create a margin figure that is larger than the margin, making the text wrap around it. Any tips of how I might do that? I tried adapting the @tufte@margin@floatbox
to get a third argument for the minipage width, but I'm failing miserably. Here's what I got so far:
\newsavebox{\myfloatboxwider}
\newenvironment{myfloatwider}[3][-1.2ex]%
{\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
\begin{lrbox}{\myfloatboxwider}%
\hspace*{-\marginparwidth}%
\begin{minipage}{#3}%
\@tufte@caption@font%
\def\@captype{#2}%
\hbox{}\vspace*{#1}%
\@tufte@caption@justification%
\@tufte@margin@par%
\noindent%
}
{\end{minipage}%
\end{lrbox}%
\marginpar{\usebox{\myfloatboxwider}}%
}
\newenvironment{marginfigurewider}[2][-1.2ex]%
{\begin{myfloatwider}[#1]{figure}{#2}}
{\end{myfloatwider}}
To use like this
\begin{marginfigurewider}[1.2ex]{2.0\marginparwidth}%
\includegraphics[width=\linewidth]{myimage.jpg}
\caption{Some caption.}
\label{fig:somefig}
\end{marginfigurewider}
However there are two problems left that I cannot solve:
- The hspace should actually be
#3-\marginparwidth
, but I can't find a way to make this calculation. - The main text does not wrap around it. Do I need something like
wrapfig
for this?
Update
This achieves more or less what I want:
\setlength\columnsep{\marginparsep}
\begin{wrapfigure}{O}[\dimexpr \marginparwidth+\marginparsep]{2.0\marginparwidth}
\FloatBarrier%
\vspace{-0.7\baselineskip}
\begin{minipage}[b]{2.0\marginparwidth}
\includegraphics[width=\linewidth]{myimage.jpg}
\caption{Some caption.}
\label{fig:somefig}
\end{minipage}
\end{wrapfigure}
There are still two problems:
- Side notes, like
cite
, are overlaid over the image, not floated down below it. - I can't make it work as a \newenvironment. Nothing shows, and
width=\linewidth
is flagged as not a number. I can live by using the code manually, but it'd be nicer if it was an environment. Attempt is below:
\newenvironment{marginfigurewide}[1]%
{\FloatBarrier%
\setlength\columnsep{\marginparsep}%
\begin{wrapfigure}{O}[\dimexpr \marginparwidth+\marginparsep]{2.0\marginparwidth}%
\vspace{-0.7\baselineskip}%
\begin{minipage}[b]{2.0\marginparwidth}
}
{\end{minipage}%
\end{wrapfigure}
}
[\dimexpr \marginparsep+\marginparwidth]