6

I'm interested in putting marginal notes that seems like a post-it in the margin of a document.

No problem at all if they are simply made with \marginpar and playing with margin width and separation.

But my question is: how can I make the marginal note wider and make it invade the main body of the document? how will it wrap the body text? Let me clarify with a sample:

|   asdfasdfasdfasdfasfs        |
|   sadfasdfasdfasdfasas        |
|   asdfajhdfasfd               |
|   jhfasdjfasdfj +----------+  |
|   asdfasdfasdfa | asdasdfa |  |
|   jkasdfjasdfas | sdfadfas |  |
|   jhfasdjfasdfj +----------+  |
|   asdfajhdfasfd               |
|   asdfasdfasdfasdfasfs        |
|   sadfasdfasdfasdfasas        |

I'd be interested in some solution, also considering some aspect I don't know about the wrapfig package.

And... what about double sided documents (book class)?

7

One way is to use the wrapgifure environment:

\documentclass[twoside]{article}
\usepackage{lipsum}
\usepackage{wrapfig}
\setlength{\wrapoverhang}{\marginparwidth}
\addtolength{\wrapoverhang}{\marginparsep}
\usepackage[left=1in,right=2.5in,top=1in,bottom=1in]{geometry}
\begin{document}
\lipsum[1]
\begin{wrapfigure}[11]{O}{6.3cm}
\vspace{-10pt} %% If needed
This is a margin note getting wrapped with the text and going into margin as well.
In \verb!\begin{wrapfigure}[8]{O}[2cm]{6cm}!, \texttt{[8]} denotes the number of line space in the margin note, \texttt{{O}} is the alignment, \texttt{[2cm]} is amount by which the note goes in to the margin (called over hang) and \texttt{{6cm}} is the width.
\vspace{10pt} %% If needed
\end{wrapfigure}
\lipsum[2-3]
\clearpage
\lipsum[3]
\begin{wrapfigure}[11]{O}{6.3cm}
% \vspace{-10pt} %% If needed
This is a margin note getting wrapped with the text and going into margin as well.
In \verb!\begin{wrapfigure}[8]{O}[2cm]{6cm}!, \texttt{[8]} denotes the number of line space in the margin note, \texttt{{O}} is the alignment, \texttt{[2cm]} is amount by which the note goes in to the margin (called over hang) and \texttt{{6cm}} is the width.
% \vspace{10pt} %% If needed
\end{wrapfigure}
\lipsum[4-5]

\end{document}

enter image description here

  • 1
    It would be better to use \raggedright for the text inside wrapfigure to prevent ugly inter-word spacing. – Gonzalo Medina May 21 '12 at 0:56
  • @GonzaloMedina: That is true if one has unbreakable wordings like this one. Generally your suggestion is better. – user11232 May 21 '12 at 1:21
  • i'd line to thank you for your detailed explanation. Works like a charm! – Fèlix Galindo Allué May 21 '12 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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