Multicol 和页面顶部的浮动框,文本环绕在其周围
我正在为一本杂志写一篇文章。我试图在 3 列文档的右上角插入一个(浮动)2 列框,文本很好地环绕在它周围,并且各列对齐。我正在使用 tikz 包制作盒子,这样我就可以拥有一个带有圆形边缘和背景颜色的盒子。 我试图使用wrapfig 进行包装(并且我也尝试了一些小型页面的东西),但我无法让它工作。
这是一些代码,解释了我想要做什么,以及我如何尝试做到这一点:
\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}
I'm writing an article for a magazine. I'm trying to insert a (floating) 2-column box at the upper right corner of a 3-column document, with the text wrapping around it nicely andn the columns being aligned. I'm making the box using the tikz package so I can have a box with rounded edges and a background color.
I was trying to do the wrapping using wrapfig (and I've tried some minipage stuff as well), but I can't get it to work.
This is some code that explains what I'm trying to do, and how I've been trying to do it:
\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}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我的经验,使用乳胶很难获得这种布局(图形跨越多个列,但不是页面上的所有列)。
我知道的最好的解决方案是 flowfram 包。该包允许您在编写文档内容之前定义页面布局(某些框应放置在何处)。
下面给出了一个小代码示例。它是 flowfram 包附带的海报示例的重组。
It is my experience that such layout (figure spanning more than one, but not all of the columns on the page) is difficult to obtain with latex.
The best solution that I'm aware of is the flowfram package. The package lets you define the page layout (where should certain boxes be placed) before writing the contents of the document.
A small code example is given below. It is a restructuring of the poster example that comes with the flowfram package.
多列环境中跨越两列的非浮动图形
我也遇到了类似的问题。迷你页是我听过的最好的主意。
也可以用wrapfig来完成,但是需要大量调整,但这是可能的:
那来自wrapfig文档。
祝你好运。
Nonfloating figure spanning two columns in multicol environment
I had a similar problem. The minipage was about the best idea I have heard.
It can also be done with wrapfig, but it takes a lot of adjusting, but it is possible:
That is from the wrapfig documentation.
Good luck.