I'm (still) going to develop a class that will use wide margins and put some contents into it. In contrast to tufte-book, which sets the positioning parameters for floats as htbp by default, I would like to allow true floats. Furthermore, I'd like to offer an environemtn which a) floats and b) puts its caption (in the margin) either above or below the figure, depending on the positioning selected by the float mechanism. While I can handle this if a position is provided (the optional argument of figure or table), I'd like to do the same if no optional argument was specified. Since the content and hence the height of the figure is the same for both cases, it would not change the positioning of the figure.
I'm quite sure that I have read about this some years ago, but I don't find a hint via google. For the MWE, I omit the positioning in the margin but simply want to output the caption below or above the figure's content.
\documentclass{article}
\usepackage[marginparwidth=7cm,left=1.5cm,right=1cm,includemp]{geometry}
\usepackage{lipsum}
\makeatletter
\def\myt{t}\def\myp{p}\def\myb{b}
\newcommand*\widefigure[3][]{%
% #1: Position
% #2: Figure
% #3: Caption
\def\@tempa{#1}%
\begin{figure}[#1]%
\rlap{%
\begin{minipage}{\dimexpr\textwidth+\columnsep+\marginparwidth}%
\ifx\@tempa\myb
\caption{#3}#2%
\else\ifx\@tempa\myt
#2\caption{#3}
\else\ifx\@tempa\myp
\caption{#3}#2%
\else
% What if no position is specified?
\fi\fi\fi
\end{minipage}}
\end{figure}%
}
\begin{document}
\widefigure[b]{\rule{\textwidth}{5cm}}{foo}
\lipsum[1-4]
\widefigure[t]{\rule{\textwidth}{5cm}}{foo}
\lipsum[2]
\widefigure{\rule{\textwidth}{5cm}}{foo}
\lipsum[7]
\end{document}
[t]it may not be set in top position if flushed with\clearpage(which basically forces all floats to be[p]) – David Carlisle Feb 16 '15 at 23:14bon an entire page, the order of caption and figure should adapt to it. I know that the MWE given above is far from perfect since I don't know how to find out what type of positioning LaTeX's float mechanism is testing. – Patrick Happel Feb 16 '15 at 23:21