2

I desire a layout that has, say, an "info-box" (for the lack of better wording). The main layout of my document uses a three column layout. I intend to place a colorbox (two columns in width) in such a way that the three columns wrap around the colorbox automatically. The text and figures inside the colorbox should not adhere to the three column layout. I'll consider one example but I suspect that the solution will be applicable to whatever placement of the colorbox one can think of. The example I'm considering here is aligning the colorbox to the top right.

In my attempt to produce this result, I split up my problem in two.

The first issue is reproducing the intended vertical alignment of the second and third column. I got this far (Keep in mind that this example only explains visually what I had in mind - excluding the colorbox):

http://i.imgur.com/gqPX4Ct.png?1

\documentclass[demo]{article}
\usepackage[a4paper,margin=20mm]{geometry}
\usepackage[demo]{graphicx}

\usepackage{xcolor}
\usepackage{multicol}
\usepackage{wrapfig}
\usepackage{kantlipsum}

\begin{document}
\begin{multicols*}{3}
\kant[5]
More text, to show that the entire column is filled from top to bottom. More text, to show that the entire column is filled from top to bottom. More text, to show that the entire column is filled from top to bottom. More text, to show that the entire column is filled from top to bottom. More text, to show that the entire column is filled from top to bottom. More text, to show that the entire column is filled from top to bottom. More text, to show that the entire column is filled from top to bottom. More text, to show that the entire column is filled from top to bottom. 

\columnbreak
{
\hangindent=\columnwidth
\begin{wrapfigure}{r}{2\columnwidth}
\colorbox{gray}{%
\begin{minipage}{\dimexpr2\columnwidth}
\kant[1]
\end{minipage}%
}
\end{wrapfigure}
}
\phantom{.}
\vskip .8\textheight
As any dedicated reader can clearly see, the Ideal of practical reason is a representation of, as far as I know, the things in themselves; as I have shown elsewhere, the phenomena should only be used as a canon for our understanding. The paralogisms of practical reason are what first give rise to the architectonic of practical reason. As will
\columnbreak
aasfsafaaaaaaaaaaaaaa aaaaaaaaaaaaa afwafawfaw
\vskip .8\textheight
\noindent easily be shown in the next section, reason would thereby be made to contradict, in view of these considerations, the Ideal of practical reason, yet the manifold depends on the phenomena. Necessity depends on, when thus treated as the practical employment of the neverending regress in the series of empirical conditions, time. Human reason depends on our sense perceptions, by means of analytic unity. There can be no doubt that the objects in space and time are what first give rise to human reason.
\end{multicols*}
\end{document}

On the second step, placing the colorbox inside the now produced white space, I ran into issues. Those issues aside, manual adjustment of a box in this case isn't very desirable if one wants to keep the layout consistent. Naturally an elegant solution exists to produce something like this:

http://i.imgur.com/bkWT5A0.png

This colorbox is produced with the following code:

\documentclass[demo]{article}
\usepackage[a4paper,margin=20mm]{geometry}
\usepackage[demo]{graphicx}

\usepackage{xcolor}
\usepackage{multicol}
\usepackage{wrapfig}
\usepackage{kantlipsum}

\begin{document}
\begin{multicols*}{3}

\columnbreak
{
\hangindent=\columnwidth
\begin{wrapfigure}{r}{2\columnwidth}
\colorbox{gray}{%
\begin{minipage}{\dimexpr2\columnwidth}
\kant[2-4]

This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. 
\end{minipage}%
}
\end{wrapfigure}
}
\end{multicols*}
\end{document}

EDIT: Thanks to @Bernard I've come pretty close to the intended effect

http://i.imgur.com/LvVfZ5s.png

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{xcolor}
\usepackage{flowfram}
\usepackage{kantlipsum}
\usepackage{microtype}

\newflowframe[1]{0.30\textwidth}{\textheight}
{0pt}{0pt}[leftcolumn]

\newflowframe[1]{0.30\textwidth}{.2\textheight}
{0.35\textwidth}{0pt}[shortcentercolumn]

\newflowframe[1]{0.30\textwidth}{.2\textheight}
{0.7\textwidth}{0pt}[shortrightcolum]

\newstaticframe[1]{0.65\textwidth}{.8\textheight}
{0.35\textwidth}{.2\textheight}[minipage]

\begin{document}

\noindent \kant[1]

\begin{staticcontents*}{minipage}
\colorbox{gray}{%
\begin{minipage}{\linewidth}
\kant[2-4]

This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer.  This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer.  This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer.  This paragraph has the sole intention of making the entire colorbox longer. This paragraph has the sole intention of making the entire colorbox longer. 
\end{minipage}}
\end{staticcontents*}

\kant[2-5]

\end{document}

This is still non-automated and it has a bug on the second page, where the three column layout is not properly restored: the second and third column have a large amount of whitespace on the new page.

Furthermore:

  • Footnotes don't work inside the static frame.
  • Footnotes in the second and third column of the flowframed paragraphs appear on the page after.

So the question that remains is: How can I use flowfram without breaking the consequent pages, ideally with multicol compatibility?

  • I am not suggesting tcolorbox this time ;-) Wrapping is one of the tricky stuff in LaTeX. I think I have seen some solution by Nicola Talbot, with an own package. – user31729 Sep 20 '14 at 15:50
  • @ChristianHupfer I meant colorbox, not tcolorbox. ;-) And this version of a colorbox is only a suggestion. – 1010011010 Sep 20 '14 at 15:53
  • Yes, I was serious this time -- I don't suggest tcolorbox The wrapping issue is something I am interested too! – user31729 Sep 20 '14 at 15:56
  • 1
    You should take a look at the flowfram package, by Nicola Talbot. – Bernard Sep 20 '14 at 16:00
  • 1
    You've only defined frames for page 1. (You should have a warning in the transcript Run out of flows frames on page 1, adding new one on input line 48.) So it's not a bug on the second page, you haven't given flowfram any instructions as to what to do with the text after the first page. – Nicola Talbot Sep 21 '14 at 10:46
2

Here is a preliminary answer using flowfram. Thanks @Bernard for the suggestion and @NicolaTalbot for commenting on some inconsistencies in my code.

When I get around to it, I can balance the columns better using LaTeX page dimensions.

http://i.imgur.com/YesUrOR.png?1

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[margin=2cm]{geometry}
\usepackage{xcolor}
\usepackage{flowfram}
\usepackage{lipsum}
\usepackage{kantlipsum}
\usepackage{microtype}
\usepackage{multicol}

\definecolor{infocolor}{RGB}{216,237,237}

\newflowframe{\dimexpr\textwidth/3-2\columnsep/3}{\textheight}{0pt}{0pt}[leftcolumn]
\newflowframe[>1]{\dimexpr\textwidth/3-2\columnsep/3}{\textheight}{\dimexpr\textwidth/3+\columnsep/2}{0pt}[centercolumn]
\newflowframe[1]{\dimexpr\textwidth/3-2\columnsep/3}{.2\textheight}{\dimexpr\textwidth/3+\columnsep/2}{0pt}[shortcentercolumn]
\newflowframe[>1]{\dimexpr\textwidth/3-2\columnsep/3}{\textheight}{\dimexpr2\textwidth/3+\columnsep}{0pt}[rightcolumn]
\newflowframe[1]{\dimexpr\textwidth/3-2\columnsep/3}{.2\textheight}{\dimexpr2\textwidth/3+\columnsep}{0pt}[shortrightcolumn]
\newstaticframe[1]{\dimexpr2\textwidth/3-2\columnsep/3}{\dimexpr2\textheight/3-9\columnsep}{\dimexpr\textwidth/3+\columnsep/2}{\dimexpr\textheight/3}[minipage]

\begin{document}
\tolerance=10000
\lipsum[1]

\begin{staticcontents*}{minipage}
\colorbox{infocolor}{%
\parbox[b][\dimexpr.8\textheight-4.8\fboxsep][t]{\textwidth}{%
\vfil
\hfil
\begin{minipage}{\dimexpr\linewidth-6\fboxsep}
\setlength\parindent{16pt}
\kant[2] More text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text, more text.

\begin{center}
\includegraphics{figure.png}
\end{center}
\kant[4] 
\end{minipage}}}
\hfil
\vfil
\end{staticcontents*}

\lipsum[2-15]

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.