两列,中间有一个文本框,两边环绕

两列,中间有一个文本框,两边环绕

我正在寻找一种允许两列的格式,并在页面中央有一个文本框;实际上是三个框。Wrapfig 无法完成这项工作,因为它只允许文本在一侧流动。

答案1

此解决方案使用 flowfram。flowfram 的优点是所有内容都相对于页面定位,而不是文本。

通常,当段落跨框架时,宽度不会改变。相反,您必须使用 手动拆分段落\nopar,并在需要时一次添加一个段落。

请注意,flowfram 与 twocolumn 不兼容,但可以使用更多流帧来伪造它。

\documentclass{article}
\usepackage[textwidth=6in]{geometry}
\usepackage{flowfram}
\usepackage{graphicx}
\usepackage{lipsum}% MWE only

\newcommand{\nopar}{\strut{\parfillskip=0pt\parskip=0pt\par}\framebreak\noindent}

\newflowframe[1,>2]{\dimexpr 0.5\textwidth-0.5\columnsep}{\textheight}%
  {0pt}{0pt}% normal left column
\newflowframe[1,>2]{\dimexpr 0.5\textwidth-0.5\columnsep}{\textheight}%
  {\dimexpr 0.5\textwidth+0.5\columnsep}{0pt}% normal right column

% the folowing wastes length registers, but is more easily read than using \dimen0 etc.
\newlength{\centerboxheight}
\newlength{\centerboxwidth}
\newlength{\boxsep}

\setlength{\centerboxheight}{2in}
\setlength{\centerboxwidth}{3in}
\setlength{\boxsep}{\intextsep}

\newflowframe[2]{\dimexpr 0.5\textwidth-0.5\columnsep}{\dimexpr 0.5\textheight-0.5\centerboxheight-\boxsep}%
  {0pt}{\dimexpr 0.5\textheight+\centerboxheight/2+\boxsep}% upper left
\newflowframe[2]{\dimexpr 0.5\textwidth-0.5\centerboxwidth-\columnsep}{\dimexpr \centerboxheight+2\boxsep}%
  {0pt}{\dimexpr 0.5\textheight-0.5\centerboxheight-\boxsep}% middle left
\newflowframe[2]{\dimexpr 0.5\textwidth-0.5\columnsep}{\dimexpr 0.5\textheight-0.5\centerboxheight-\boxsep}%
  {0pt}{0pt}% lower left
\newflowframe[2]{\dimexpr 0.5\textwidth-0.5\columnsep}{\dimexpr 0.5\textheight-0.5\centerboxheight-\boxsep}%
  {\dimexpr \dimexpr 0.5\textwidth+0.5\columnsep}{\dimexpr 0.5\textheight+0.5\centerboxheight+\boxsep}% upper right
\newflowframe[2]{\dimexpr 0.5\textwidth-0.5\centerboxwidth-\columnsep}{\dimexpr \centerboxheight+2\boxsep}%
  {\dimexpr 0.5\textwidth+0.5\centerboxwidth+\columnsep}{\dimexpr 0.5\textheight-0.5\centerboxheight-\boxsep}% middle right
\newflowframe[2]{\dimexpr 0.5\textwidth-0.5\columnsep}{\dimexpr 0.5\textheight-0.5\centerboxheight-\boxsep}%
  {\dimexpr \dimexpr 0.5\textwidth+0.5\columnsep}{0pt}% lower right

\newstaticframe[2]{\centerboxwidth}{\centerboxheight}%
  {\dimexpr 0.5\textwidth-0.5\centerboxwidth}{\dimexpr 0.5\textheight-0.5\centerboxheight}[page2]
\begin{staticcontents*}{page2}
  \includegraphics[width=\centerboxwidth,height=\centerboxheight]{example-image}
\end{staticcontents*}

\begin{document}
\sloppy
\lipsum[1-7]

Pellentesque habitant morbi tristique senectus
et netus et malesuada fames ac turpis egestas.
Donec odio elit, dictum in, hendrerit sit amet,
egestas sed, leo. Praesent feugiat sapien aliquet
odio. Integer vitae justo. Aliquam vestibulum
fringilla lorem. Sed neque lectus, consectetuer
at, consectetuer sed, eleifend ac, lectus. Nulla facilisi.
Pellentesque eget lectus. Proin eu metus.
Sed porttitor. In hac habitasse platea dictumst.\nopar
Suspendisse eu lectus. Ut mi mi, lacinia sit amet,
placerat et, mollis vitae, dui. Sed ante tellus, tristique
ut, iaculis eu, malesuada ac, dui. Mauris
nibh leo, facilisis non, adipiscing quis, ultrices a,
dui.

Morbi luctus, wisi viverra faucibus pretium,
nibh est placerat odio, nec\nopar
commodo wisi enim
eget quam. Quisque libero justo, consectetuer
a, feugiat vitae, porttitor eu, libero. Suspendisse
sed mauris vitae elit sollicitudin malesuada.
Maecenas ultricies eros sit amet ante. Ut
venenatis velit. Maecenas sed mi eget dui varius
euismod. Phasellus aliquet volutpat odio.
Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia Curae; Pellentesque
sit amet pede ac sem eleifend consectetuer.
Nullam elementum, urna vel imperdiet
sodales, elit ipsum pharetra ligula, ac pretium
ante justo a nulla. Curabitur tristique arcu eu
metus. Vestibulum lectus. Proin mauris. Proin
eu nunc eu urna hendrerit faucibus. Aliquam
auctor, pede consequat laoreet varius, eros tellus
scelerisque quam, pellentesque hendrerit ipsum
dolor sed augue. Nulla nec lacus.

Suspendisse vitae elit. Aliquam arcu neque,
ornare in, ullamcorper quis, commodo eu, libero.
Fusce sagittis erat at erat tristique mollis. Maecenas
sapien libero, molestie et, lobortis in, sodales
eget, dui. Morbi ultrices rutrum lorem. Nam elementum
ullamcorper leo. Morbi dui. Aliquam
sagittis. Nunc placerat. Pellentesque tristique
sodales est. Maecenas imperdiet lacinia velit.
Cras non urna. Morbi eros pede, suscipit ac, varius
vel, egestas non, eros. Praesent malesuada,
diam id pretium elementum, eros sem dictum tortor,
vel consectetuer odio sem sed wisi.

Sed feugiat. Cum sociis natoque penatibus et
magnis dis parturient montes, nascetur ridiculus
mus. Ut pellentesque augue sed urna.\nopar
Vestibulum
diam eros, fringilla et, consectetuer eu, nonummy
id, sapien. Nullam at lectus. In sagittis
ultrices mauris. Curabitur malesuada erat sit
amet massa. Fusce blandit. Aliquam erat volutpat.
Aliquam euismod. Aenean vel lectus. Nunc
imperdiet justo nec\nopar
dolor.

\lipsum[12-16]

\end{document}

相关内容