[Tex/LaTex] How to make all figures float on the outer margins of two-side document

double-sidedfloatsmarginparmargins

I want to make a double-sided problem booklet that contains several questions. Each question has a distinct number and may have zero or more figures. Each figure has a caption and floats on the outer margin. The following figure illustrates what I want to have.

enter image description here

Is there a document class or package to do this out of the box? If the answer is NO, then how to create such a problem booklet?

Best Answer

As tohecz mentions in his comment, you can use \marginpar for your purpose; using \captionof (from the caption or capt-of packages) you can provide the captions.

\documentclass[twoside]{article}
\usepackage[outermargin=2cm,innermargin=5cm,marginparwidth=3cm,marginparsep=20pt]{geometry}
\usepackage[demo]{graphicx}
\usepackage{marginnote}
\usepackage{caption}
\usepackage{lipsum}

\newcommand\MarginFig[4][width=\marginparwidth]{%
\marginpar{\includegraphics[#1]{#2}
\captionof{figure}{#3}
\label{#4}}
}

\reversemarginpar

\begin{document}
%\layout
text\MarginFig{name1}{description for figure one}{fig:test1} \lipsum[1-2]\MarginFig{name2}{description for figure one}{fig:test2}
\lipsum[1]\MarginFig[height=7cm,width=\marginparwidth]{name3}{description for figure three}{fig:test3}\lipsum[1-3]
text\MarginFig[height=7cm,width=\marginparwidth]{name4}{description for figure four}{fig:test4} \lipsum[1]\MarginFig{name5}{description for figure five}{fig:test5}\lipsum[2]\MarginFig{name6}{description for figure six}{fig:test6}\lipsum[1-3]

\end{document}

enter image description here

In the code above I used the \reversemarginpar command and the geometry package to customize the page layout in order to obtain the result shown in the original question (images in the left margin for odd-numbered pages and images in the right margin for even-numbered pages). Those settings are, of course, optional.