6

I have a multicolumn text. And I want to print something on page two inside two fittable boxes spanning the whole width of the page exclusively.

So I thougth to use \begin{multicols}{2} for the two columns and \AtBeginShipout{\ifnum\value{page}=1 \tcboxfit{}}

Working example, with wrong output.

\documentclass[12pt]{article}
\usepackage[breakable,fitting,raster]{tcolorbox}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{atbegshi}
\AtBeginShipout{
\ifnum\value{page}=1
\tcbset{colframe=black,colback=white,
  sharp corners,
  boxsep=5mm,top=1mm,bottom=1mm,left=1mm,right=1mm,
  fit algorithm=hybrid*,raster equal skip=-0.5mm}
\tcboxfit{
  Information
}
\tcboxfit{
  more Infomation
}
\newpage
\fi
}
\begin{document}
\begin{multicols*}{2}
\subsection{-1-}
\lipsum[1]
\subsection{-2-}
\lipsum[2]
\subsection{-3-}
\lipsum[3]
\subsection{-4-}
\lipsum[4-5]
\subsection{-5-}
\lipsum[5]
\end{multicols*}
\end{document}

There are two things wrong with this:

  • Part of the paragraph will be output to page two
  • The tcboxfit only spans the column.

Any Ideas?

EDITH: twocolumn option is not so helpful, because it starts a new page, and I want to begin twocolumn right after a longtable (which itself may span over to the next page depending on the generated data).

So my real question ist: Why is part of the paragraph put on page two. I adjusted the example. As you can see, "sit amet, consecuteur..." is on the wrong page, namely the page two

  • Quick question: do you require to use \tcboxfit or another kind of tcolorbox is good? – Phelype Oleinik Jul 13 '18 at 13:27
  • @PhelypeOleinik the content of the first box is generated from outside of the LaTeX-Document, so it may be a bit overfull(vbox), so I thought to force the box to have only so much place to use (I stripped it in this MWE) – Peter Miehle Jul 13 '18 at 13:33
  • Part of which paragraph will be on page 2? What should be on page 2 exactly? – cfr Jul 17 '18 at 23:03
  • @cfr https://www.overleaf.com/read/bnvpzxtjwbbj you will see, that the rest of the first paragraph of section 0.4 is on the "special page" two and not at the beginning of page (now) 3 – Peter Miehle Jul 18 '18 at 11:44

3 Answers3

3

I think that wrapping the whole text in multicols is not the best way to tackle the problem (I might be wrong :)

Here's one way using the twocolumn option for article and switching to one column mode using \onecolumn.

The real problem was to make the \tcboxfit work :P

I wrapped them in minipages to avoid them being inserted side-by-side:

\documentclass[12pt,twocolumn]{article}
\usepackage[breakable,fitting,raster]{tcolorbox}
\usepackage{lipsum}
\usepackage{atbegshi}
\AtBeginShipoutNext{% We can use \AtBeginShipoutNext to eliminate the page number check
\onecolumn% switch to one column
\tcbset{colframe=black,colback=white,
  sharp corners,
  boxsep=5mm,top=1mm,bottom=1mm,left=1mm,right=1mm,
  fit algorithm=hybrid*,raster equal skip=-0.5mm}%
\begin{minipage}[t][0.5\textheight][t]{\textwidth}
  \tcboxfit[height=0.5\textheight,width=\textwidth]{
    Information
  }
\end{minipage}\par\nointerlineskip
\begin{minipage}[t][0.5\textheight][t]{\textwidth}
  \tcboxfit[height=0.5\textheight,width=\textwidth]{
    more Infomation
  }
\end{minipage}
\newpage
\twocolumn% and go back to two column mode
}
\begin{document}
\lipsum
\end{document}

And the second page:

enter image description here

  • the problem with twocolumn-option is, that it starts a new page, so when I have (not shown in my stripped example!) a table and then under the table the two column-text, that starts at a new page. – Peter Miehle Jul 16 '18 at 06:49
2

Another solution based in Phelype's one, but replacing minipages by a tcbraster which is declared with one column and two rows.

\documentclass[12pt,twocolumn]{article}
\usepackage[breakable,fitting,raster]{tcolorbox}
\usepackage{lipsum}
\usepackage{atbegshi}
\AtBeginShipoutNext{% We can use \AtBeginShipoutNext to eliminate the page number check
\onecolumn% switch to one column
\tcbset{colframe=black,colback=white,
  sharp corners,
  fit algorithm=hybrid*,raster equal skip=-0.5mm}%
\begin{tcbraster}[raster columns=1, raster row skip=-.5mm, raster height=\textheight, raster rows=2, raster equal height=all]
  \tcboxfit{
    Information
  }
  \tcboxfit{
    more Infomation
  }
\end{tcbraster}
\newpage
\twocolumn% and go back to two column mode
}
\begin{document}
\lipsum
\end{document}

enter image description here

Ignasi
  • 136,588
0

This is not an answer as such. It is more a question of clarification: why can't you just do such-and-so? However, I can't fit it in a comment. Not, at any rate with an image inline.

As I understand it, you want two tcolorboxes at the top of page 2, such that together they span the width of the page. You want the text for everything else to be typeset in two columns. So essentially, you end up with a box at the head of each column on page 2. And these must be at the head of page 2, with no dribbles of regular text above them.

I wondered if you also wanted nothing else at all on page 2. However, I tried that and it looked awful, so I figured probably not.

In that case, though, I don't see why you can't use

  • \twocolumn (or the twocolumn class option);
  • a figure* containing two tcolorboxes.

You do need the nobeforeafter option. Otherwise the tcolorbox is set in a paragraph of its own, so, of course, the second box is beneath rather than beside it.

Otherwise, it seems quite straightforward, which is why I assume this is not actually what you want.

\documentclass[12pt]{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\tcbset{aardvark/.style={colframe=black, colback=white, equal height group=aardvarks, sharp corners, width=\linewidth/2, nobeforeafter}}%
\begin{document}
\twocolumn
\begin{figure*}
  \begin{tcolorbox}[aardvark]
    Information
  \end{tcolorbox}%
  \begin{tcolorbox}[aardvark]
    more Infomation
  \end{tcolorbox}
\end{figure*}
\subsection{-1-}
\lipsum[1]
\subsection{-2-}
\lipsum[2]
\subsection{-3-}
\lipsum[3]
\subsection{-4-}
\lipsum[4-5]
\subsection{-5-}
\lipsum[5]
\end{document}

two boxes heading page 2

cfr
  • 198,882