Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to create a problem booklet consisting of some questions and images on the marginpar. How to make sure the images properly float on the marginpar?

If you carefully see the left image below, you will notice that the most bottom image gets cropped as it is not properly floated.

enter image description hereenter image description here

\documentclass[twoside,12pt]{book}
\usepackage[
    a4paper,
    vmargin=2cm,
    outermargin=9cm,
    innermargin=2cm,
    marginparwidth=7cm,
    marginparsep=20pt
]{geometry}

\usepackage{graphicx}
\usepackage{marginnote}
\usepackage{caption}
\usepackage{lipsum}

\newcommand\MarginFig[1]{%
\marginpar{\includegraphics[width=\marginparwidth]{example-image-a}
\captionof{figure}{#1}
\label{#1}}}



\begin{document}
\chapter{Higgs Boson}
\lipsum[1-3]

\begin{enumerate}
\item
\MarginFig{1}
\MarginFig{2}
\MarginFig{3}
\lipsum[1-2]

\item
\MarginFig{4}
\MarginFig{5}
\MarginFig{6}
\lipsum[1-2]

\item 
\MarginFig{7}
\MarginFig{8}
\MarginFig{9}
\lipsum[1-2]

\end{enumerate}
\end{document}

This question is a continuation of my previous question.

Edit 3

Bonus questions (without prizes): Among the permutation of \MarginFig{n}, \MarginFig{n+1}, \MarginFig{n+2}, and \lipsum[1-2], which one will produce the best floating?

share|improve this question
    
Is it getting better if you use the marginfix package? –  Stephan Lehmke Jul 13 '12 at 13:50
    
@StephanLehmke: Yes. It is getting better. Thanks. You can submit it as your answer. –  I am who I say I am Jul 13 '12 at 13:50
add comment

1 Answer

up vote 4 down vote accepted

The package marginfix will help avoid overflows. It doesn't implement any "intelligent" floating though, so be prepared for margin images to "pile up" if you are using too many of them.

share|improve this answer
    
Sometimes I get "too many unprocessed floats". –  I am who I say I am Jul 13 '12 at 14:08
    
That's more or less what I meant. marginfix will turn marginpars which could not be placed on the current page into floats waiting to be placed on the next page(s). LaTeX allows only a rather limited number of those to float around unplaced. –  Stephan Lehmke Jul 13 '12 at 14:11
    
Does the permutation of \MarginFig{xxx} and \lipsum[1-2] matter? –  I am who I say I am Jul 13 '12 at 14:20
    
Not really. Every marginpar gets 'attached' to the line it appears on. So it really only matters how many you use on a page of text and less on the finer order in which they appear. –  Stephan Lehmke Jul 13 '12 at 14:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.