让文本主体浮动在 marginpar 周围

让文本主体浮动在 marginpar 周围

如何创建 marginpar 以便它缩进文本主体并且文本主体浮动在 marginpar 周围?

我知道如何创建 marginpar:

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

这创建了 A,但我想要 B。

在此处输入图片描述

答案1

wrapfig 环境采用可选参数,表示要向边距中伸出多少。用法如示例所示。使用相当新的 LaTeX,您可以使用 来\dimexpr计算总和,或者您可以使用calc包并省略\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}

相关内容