2

How do I create a marginpar so that it is indented into the text body and the text body floats around the marginpar?

I know how to create a marginpar:

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\marginpar{Here are some more information about this section.}
\lipsum
\end{document}

This creates A, but I want B.

enter image description here

white_gecko
  • 2,101

1 Answers1

1

The wrapfig environment takes an optional argument saying how much to overhang into the margin. Usage is in the example. With reasonably new LaTeX you can use \dimexpr for calculating the sum, or you can use the calc package and omit \dimexpr.

\documentclass{article}
\usepackage{lipsum}
\usepackage{wrapfig}
\usepackage{shortvrb}
\MakeShortVerb"
\begin{document}

\begin{wrapfigure}{r}[\dimexpr \marginparwidth+\marginparsep]{5cm} Here is some information about this section. And are some more facts about this section. \end{wrapfigure}

At the beginning of the document or after "\newpage" the top lines of text will align naturally. \lipsum[1]\marginpar{Here is how a marginpar is placed entirely in the marginpar region.}

\lipsum[1]

\section*{Section} \begin{wrapfigure}{r}[\dimexpr \marginparwidth+\marginparsep]{5cm} \vspace{-\intextsep} In general locations, the wrapfigure is separated by "\intextsep", so if you don't want the extra space, get rid of it with a negative "\vspace" or by setting "\intextsep" to zero. \end{wrapfigure}

\lipsum[1]

\end{document}