0

I want to use a coloured box on a 2-column document but it keeps breaking the page and leaving a huge gap.

MWE:

%Document definitions
\documentclass[a4paper, twoside]{report}
\usepackage[left=1cm, right=1cm, top=1.25cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{xcolor}
%Maths Stuff
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{nccmath}
\usepackage{mathtools}
%Image handling
%Custom commands
\usepackage{tikz}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\pagestyle{empty}
% \pagestyle{fancy}
% \fancyhf{}
% \fancyhead[LE,RO]{Thermal \& Nuclear Physics}
% \chead{Henry T. Carr, Spring 2019}
% \fancyhead[RE,LO]{Exam Cheat Sheet}
%\fancyfoot[CE,CO]{\leftmark}
%\fancyfoot[LE,RO]{\thepage}
% \renewcommand{\headrulewidth}{2pt}
\renewcommand\thesection{\arabic{section}}
\numberwithin{equation}{section}
\usepackage{amsmath}
\usepackage{mathtools}
\newcommand{\dbar}{d\hspace*{-0.08em}\bar{}\hspace*{0.1em}}
\usepackage{mhchem,chemmacros}

\usepackage{sans} \usepackage{tikz,lipsum,lmodern} \usepackage[most]{tcolorbox}

\begin{document} \begin{multicols}{2} %[ %============================================================================================================================== %\chapter{Thermodynamics} \section{\color{blue}Introduction}

\begin{tcolorbox}[colback=blue!5!white,colframe=blue!75!black,title=My title] My box with my title. \end{tcolorbox} Throughout the 17th and 18th centuries , experimentation lead to the formulation of the following:

memes

%==============================================================================================================================

%============================================================================================================================== %]

\end{multicols}

\end{document}

  • Did you use breakable option in your tcolorbox? – Ignasi Apr 03 '22 at 20:51
  • 1
    you should clean up your code, you are loading various package twice. But beside an option clash it compliles fine for me in a current texlive. – Ulrike Fischer Apr 03 '22 at 20:57
  • Running your code looks fine to me. You do know that multicol is supposed to split the text evenly across the two columns at the end of the document? – John Kormylo Apr 04 '22 at 01:25

1 Answers1

5

I think the problem is a misunderstanding of what multicol does. This package tries to equilibrate columns, therefore in OPs example the box is on left column and following sentence in right column. The huge gap is due to how multicol works and not because a tcolorbox is not breakable. As soon as the text is larger than a page, all gaps will disappear.

If OP wants a complete text in two columns format, it's possible to add twocolumn option in report class declaration. There is no need for multicol package in this case.

An another solution would be to load multicol package but use the starred enviroment \begin{multicol*}{2} which won't try to balance content between columns.

Following codes show the original OPs code and examples with twocolumn report o multicol* environment.

In all of them should be considered that the tcolorbox won't break until it reaches the column end, so multicol work doesn't look so nice.

Initial code:

%Document definitions
\documentclass[a4paper, twoside]{report}
\usepackage[left=1cm, right=1cm, top=1.25cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{multicol} %<- Not needed with twocolumn option \setlength{\columnsep}{1cm} \pagestyle{empty}

\renewcommand\thesection{\arabic{section}}

\usepackage{lipsum,lmodern} \usepackage[most]{tcolorbox}

\begin{document} \begin{multicols}{2} \section{\color{blue}Introduction} \begin{tcolorbox}[enhanced, breakable, colback=blue!5!white,colframe=blue!75!black,title=My title] \lipsum[1] \end{tcolorbox} \lipsum[1] \end{multicols}

\end{document}

enter image description here

multicols* environment:

%Document definitions
\documentclass[a4paper, twoside]{report}
\usepackage[left=1cm, right=1cm, top=1.25cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{multicol} %<- Not needed with twocolumn option \setlength{\columnsep}{1cm} \pagestyle{empty}

\renewcommand\thesection{\arabic{section}}

\usepackage{lipsum,lmodern} \usepackage[most]{tcolorbox}

\begin{document} \begin{multicols}{2} \section{\color{blue}Introduction} \begin{tcolorbox}[enhanced, breakable, colback=blue!5!white,colframe=blue!75!black,title=My title] \lipsum[1] \end{tcolorbox} \lipsum[1] \end{multicols}

\end{document}

enter image description here

twocolumn option without multicol package

%Document definitions
\documentclass[a4paper, twoside, twocolumn]{report}
\usepackage[left=1cm, right=1cm, top=1.25cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

%\usepackage{multicol} %<- Not needed with twocolumn option \setlength{\columnsep}{1cm} \pagestyle{empty}

\renewcommand\thesection{\arabic{section}}

\usepackage{lipsum,lmodern} \usepackage[most]{tcolorbox}

\begin{document} %\begin{multicols}{2} \section{\color{blue}Introduction} \begin{tcolorbox}[enhanced, breakable, colback=blue!5!white,colframe=blue!75!black,title=My title] \lipsum[1] \end{tcolorbox} \lipsum[1] %\end{multicols}

\end{document}

enter image description here

Ignasi
  • 136,588
  • BTW, I believe that a breakable tcolorbox won't work in the first column of a multicol. Multicol formats the entire page as a single column then then breaks it when the page is complete. See https://tex.stackexchange.com/questions/530084/i-want-to-wrap-text-only-above-and-below-a-figure-inside-of-a-column/530129?r=SearchResults&s=1|16.3122#530129 – John Kormylo Apr 04 '22 at 13:56
  • @JohnKormylo A breakable tcolorbox will break in first column even inside multicol environment, but this happens only when the box is larger than all available vertical space not considering multicol, therefore multicol can not equilibrate columns. – Ignasi Apr 04 '22 at 14:08