【问题标题】:Multicol and a floating box at the top of page, with text wrapping around itMulticol 和页面顶部的浮动框,周围有文字
【发布时间】:2009-11-07 14:55:27
【问题描述】:

我正在为杂志写一篇文章。我正在尝试在 3 列文档的右上角插入一个(浮动)2 列框,文本很好地环绕它并且列对齐。我正在使用 tikz 包制作盒子,这样我就可以拥有一个带有圆边和背景颜色的盒子。 我试图使用 wrapfig 进行包装(我也尝试了一些 minipage 的东西),但我无法让它工作。

这是一些代码,解释了我正在尝试做的事情,以及我一直在尝试做的事情:

\documentclass{article}
\usepackage{wrapfig}
\usepackage{tikz}
\usepackage{multicol}

\definecolor{col}{rgb}{0.6,0.6,0.9}
\setlength{\columnsep}{0.5cm}
\newcommand{\floatingBox}[3]
{
 \noindent
 \begin{wrapfigure}{#1}{#2}
 \begin{tikzpicture}
 \node[rounded corners=5pt, fill=col, text width=\linewidth]{#3};
 \end{tikzpicture}
 \end{wrapfigure}
}

\begin{document}
\begin{multicols}{3}
\large
Some random rambling to fill a page.

Aardvark AB aback abacus abaft abalone abandon abandoned abandonment abase
abasement abash abashed abate abatement abattoir abbess abbey abbot 
abbreviate abbreviation ABC abdicate abdication abdomen abdominal abduct 
abduction abeam abed aberrant aberration abet abeyance abhor abhorrence 
abhorrent abide abiding ability abject abjure ablaze able able-bodied ABM 
abnegation abnormal abnormality aboard abode abolish abolition abolitionist 
A-bomb abominable abominate abomination aboriginal aborigine abort abortion 
abortionist abortive abound about about-face above aboveboard abracadabra 
abrade Abraham abrasion abrasive abreast abridge abridgment abroad abrogate 
abrogation abrupt abscess abscond absence absent absentee absenteeism 
absent-minded absinthe absolute absolute zero absolution absolutism absolve 
absorb absorbency absorbent absorbing absorption abstain abstemious 
abstention abstinence abstinent abstract abstracted abstraction abstruse 
absurd absurdity abundance abundant abuse abusive abut abutment abysmal 
abyss AC acacia academia academic academician academy a cappella accede 
accelerate acceleration accelerator accent accentuate accentuation accept 
acceptability acceptable acceptance access accessibility accessible 
accession.


\floatingBox{tr}{2\columnwidth + 1\columnsep}{
\begin{multicols}{2}
A box that spans 2 columns and should be floating on top of the page with 
the text wrapping around it.  It's aligned to the right, so it would be 
exactly above 2 entire columns, with one column to its left.
\end{multicols}
}


Accessory accident accidental accident-prone acclaim acclamation acclimate 
acclimation acclimatization acclimatize accolade accommodate accommodating 
accommodation accompaniment accompanist accompany accomplice accomplish 
accomplished accomplishment accord accordance accordingly according to 
accordion accost account accountability accountable accountant accounting 
accouterments accredit accreditation accrue accumulate accumulation 
accumulative accuracy accurate accursed accusation accusative accusatory 
accuse accused accusingly accustom accustomed ace acerbic acerbity 
acetaminophen acetate acetic acid acetone acetylene ache achievable achieve 
achievement.

\end{multicols}
\end{document}

【问题讨论】:

    标签: latex tex pdflatex


    【解决方案1】:

    根据我的经验,这种布局(图形跨越多个列,但不是页面上的所有列)很难用乳胶获得。

    我知道的最佳解决方案是flowfram package。该包允许您在编写文档内容之前定义页面布局(某些框应放置在何处)。

    下面给出了一个小代码示例。它是对 flowfram 包附带的海报示例的重组。

    \documentclass[a4wide]{article}
    
    \usepackage{color}
    \usepackage{helvet}
    \usepackage{flowfram}
    
    \setlength{\columnsep}{0.3cm}
    
    % Base the page layout on 3 column with static header.
    \NcolumnStop{3}{1 cm}
    % give the static frame a label to make it easier to keep track of
    \setstaticframe{\value{maxstatic}}{label={title},backcolor=[cmyk]{0.64,0,0.95,0.40},textcolor=white}
    
    % On the first page, replace last two columns with
    % 2 columns and a static above
    \setflowframe{2,3}{pages={>1}}
    
    \computeflowframearea{2,3}
    \twocolumnStopinarea[1]{0.3\ffareaheight}{\ffareawidth}{\ffareaheight}{\ffareax}{\ffareay}
    \setstaticframe{\value{maxstatic}}{label={info},backcolor=[cmyk]{0.26,0,0.76,0},clear}
    
    \setallflowframes{backcolor=[cmyk]{0.15,0,0.69,0}}
    
    \raggedright
    \setlength{\parindent}{15pt}
    
    \begin{document}
    \begin{staticcontents*}{title}
    \begin{center}
    \bfseries\Large Creating stuff in \LaTeX\par
    \end{center}
    \end{staticcontents*}
    
    \pagestyle{empty}
    
    \begin{staticcontents*}{info}
    \begin{staticfigure}
    
    The {flowfram} package is designed to enable you to create
    frames in a document such that the 
    contents of the {document} environment flow from one 
    frame to the next in the order that they were defined.  
    This is useful for creating posters
    or magazines or any other form of document that does not 
    conform to the standard one or two column layout.
    
    \vfill
    
    \caption{The commands used to define the frames for this document g.}
    \protect\label{fig:thisdoc}
    \end{staticfigure}
    \end{staticcontents*}
    
    This is a modified version of the manual for the {flowfram} 
    package.  It is intended to illustrated what can be done. See the 
    full manual (ffuserguide.pdf) for
    a comprehensive description, as this may now be out of date. 
    The commands used to define the frames for
    this document are shown in Figure~\ref{fig:thisdoc}.
    If the columns are very narrow, it may be better to
    use {raggedright}, otherwise \TeX\ may have a
    problem working out the line breaks.
    
    \section{Introduction}
    
    The {flowfram} package is designed to enable you to create
    frames in a document such that the 
    contents of the {document} environment flow from one 
    frame to the next in the order that they were defined.  
    This is useful for creating posters
    or magazines or any other form of document that does not 
    conform to the standard one or two column layout.
    
    \section{Setting up Frames}
    
    The {flowfram} package provides three types of frame:
    {flow frames}, {static 
    frames} and {dynamic frames}.
    
    \subsection{Flow Frames}
    
    The flow frame is the principle type of frame.
    The text of the {document} environment will flow from 
    one frame to the next in order of definition. Each 
    flow frame has an associated width, height, 
    position on the page, and optionally a border.
    
    It is recommended that all the flow frames in a document
    have the same width, otherwise problems may occur
    when a paragraph spans to flow frames of unequal
    widths. This is because \TeX's output routine does not
    register the change in {hsize} until it reaches
    a paragraph break. If it is absolutely necessary for 
    flow frames to have unequal widths, judicious use of
    {framebreak} is required.
    
    
    \end{document}
    

    【讨论】:

      【解决方案2】:

      Nonfloating figure spanning two columns in multicol environment

      我遇到了类似的问题。迷你版是关于我听到的最好的主意。

      用wrapfig也可以,不过需要调整很多,不过还是可以的:

      Using wrapfig to span multiple columns
      
      Wrapfig can't automatically make matching cutouts in adjacent columns
      because it doesn't know which text will land in just the right place
      in the column next-door.  It certainly can't handle floating in such
      situations!  
      
      Here are some methods for doing such layout "by hand".  They are
      practical for one or a few such figures where you can tweak the
      layout for the final copy.  It is too painful to do this for long 
      or frequently-revised documents.  If you do have multiple fiddling, 
      fix the first one in each chapter (or after any forced page break), 
      rerun, then fix the second, etc.
      
      (These examples use calc.sty to evaluate overhangs in place.)
      
      Cutouts in Matching Columns
      
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~X  ~~~~~~~~~~~~~~~~~Y
      ~~~~~~~~~                    ~~~~~~~~~
      ~~~~~~~~~                    ~~~~~~~~~
      ~~~~~~~~~                    ~~~~~~~~~
      ~~~~~~~~~                    ~~~~~~~~~
      ~~~~~~~~~                    ~~~~~~~~~
      ~~~~~~~~~                    ~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      
      Initially, write the document without the wrapfigure, and locate the
      desired natural linebreak at "X".  (This first step is used for all
      methods described here.)  Then change to
      
      ~~~~~~~~X
      \begin{wrapfigure}[6]{r}[.5\width+.5\columnsep]{6cm}
      ...
      \end{wrapfigure}
      ~~~~....
      
      and run LaTeX again. This will print the figure overlapping the right
      column, but no matter. Use this run to locate position "Y" in the text.
      For the final run, switch to: 
      
      ~~~~~~~~X
      \begin{wrapfigure}[6]{r}[.5\width+.5\columnsep]{6cm}
      ...
      \end{wrapfigure}
      ~~~~....
      ...~~~~~~~Y
      \begin{wrapfigure}[6]{l}[.5\width+.5\columnsep]{6cm}
      \vfill
      \end{wrapfigure}
      ~~~~~~~~~~~
      
      
      Taking a whole column plus a cutout
      
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~X  ~~~~~~~~~~~~~~~~~Y
      ~~~~~~~~~  
      ~~~~~~~~~  
      ~~~~~~~~~  
      ~~~~~~~~~  
      ~~~~~~~~~  
      ~~~~~~~~~  
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      
      Locate "X" first, without any figure, as above, then write the 
      document like:
      
      ~~~~~~~~X
      \begin{wrapfigure}[6]{r}[\columnwidth+\columnsep]{9cm}
      ...
      \end{wrapfigure}
      ~~~~....
      
      and ignore the overprinting of the right column.  Then, after locating
      "Y" in the text, switch to:
      
      ~~~~~~~~X
      \begin{wrapfigure}[6]{r}[\columnwidth+\columnsep]{9cm}
      ...
      \end{wrapfigure}
      ~~~~....
      ...~~~~~~~Y\vspace{6\baselinskip}
      ~~~~~~~~~~~
      for the final layout 
      
      
      a whole column preceding a cutout
      
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~X  ~~~~~~~~~~~~~~~~~Y
                                   ~~~~~~~~~  
                                   ~~~~~~~~~  
                                   ~~~~~~~~~  
                                   ~~~~~~~~~  
                                   ~~~~~~~~~  
                                   ~~~~~~~~~  
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      
      After locating "X", write the draft document like:
      
      ~~~~~~~~X\vspace{6\baselinskip}
      ~~~~....
      ~~~~~~~~~~~~~
      ~~~~~~~~~
      
      run LaTeX to locate "Y", and then switch to:
      
      ~~~~~~~~X\vspace{6\baselinskip}
      ~~~~....
      ~~~~~~~~~~~~~Y
      \begin{wrapfigure}[6]{l}[\columnwidth+\columnsep]{9cm}
      ...
      \end{wrapfigure}
      ~~~~~~~~~
      
      Spanning (parts of) three columns
      
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~X  ~~~~~~~~~~~~~~~~~Y  ~~~~~~~~~~~~~~~~~Z
      ~~~~~~~~~                                        ~~~~~~~~~
      ~~~~~~~~~                                        ~~~~~~~~~
      ~~~~~~~~~                                        ~~~~~~~~~
      ~~~~~~~~~                                        ~~~~~~~~~
      ~~~~~~~~~                                        ~~~~~~~~~
      ~~~~~~~~~                                        ~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      
      This uses a combination of the above.  First locate X, then use
      
      ~~~~~~~~X
      \begin{wrapfigure}[6]{r}[.5\width+.5\columnwidth+\columnsep]{12cm}
      ...
      \end{wrapfigure}
      ~~~~....
      
      Locate Y from this, and change to
      
      ~~~~~~~~X
      \begin{wrapfigure}[6]{r}[.5\width+.5\columnwidth+\columnsep]{12cm}
      ...
      \end{wrapfigure}
      ~~~~....
      ~~~~~~~~~~~~Y\vspace{6\baselineskip}
      ~~~~~~~....
      
      which allows you to locate Z, to end up with 
      
      ~~~~~~~~X
      \begin{wrapfigure}[6]{r}[.5\width+.5\columnwidth+\columnsep]{12cm}
      ...
      \end{wrapfigure}
      ~~~~....
      ~~~~~~~~~~~~Y\vspace{6\baselineskip}
      ~~~~~~~....
      ~~~~~~~~~~~~Z
      \begin{wrapfigure}[6]{l}[.5\width+.5\columnwidth+\columnsep]{12cm}
      \vfill
      \end{wrapfigure}
      
      
      
      
      (Of course, to do matching cut-outs properly requires typesetting
      the text to a grid.)
      

      来自 wrapfig 文档。 祝你好运。

      【讨论】:

        猜你喜欢
        • 2013-07-05
        • 1970-01-01
        • 1970-01-01
        • 2013-02-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-28
        • 2014-08-03
        相关资源
        最近更新 更多