0

When having the following MWE:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{multicol}
\begin{document}
    \begin{multicols}{2}
        \begin{minipage}{0.9\linewidth}
            \blindtext
        \end{minipage}

        \begin{minipage}{0.9\linewidth}
            \blindtext
        \end{minipage}

        \begin{minipage}{0.9\linewidth}
            \blindtext
        \end{minipage}
    \end{multicols}
\end{document}

my last minipage will end up as a left column. Is there a possibility to detect if the right column is empty, and if yes, to center the last minipage?

arc_lupus
  • 1,781

1 Answers1

2

You can use a tcbraster environment with the last box centered.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{lipsum}
\usepackage{graphicx}
%\usepackage{multicol}
\usepackage[most]{tcolorbox}
\begin{document}
    \begin{tcbraster}[blankest, raster columns=2, raster equal height, raster halign=center, raster column skip=5mm, raster row skip=5mm]
        \begin{tcolorbox}
            \lipsum[2]
        \end{tcolorbox}
        \begin{tcolorbox}
            \lipsum[2]
        \end{tcolorbox}
        \begin{tcolorbox}
            \lipsum[2]
        \end{tcolorbox}
    \end{tcbraster}
\end{document}

enter image description here

Ignasi
  • 136,588
  • What is the difference between tcbraster and multicol? – arc_lupus Jul 04 '16 at 11:18
  • @arc_lupus Within a multicol environment, all its contents will be organized into as many columns you defined. As soon as contents fills the first column, second is started, later third, etc, contents flows from one column to the next as soon as the previous is completed. On the other side, tcbraster is an environment based on boxes not flows. In this case every minipage defines a box which is inserted into the raster. – Ignasi Jul 04 '16 at 11:38
  • @arc_lupus If you want organize boxes as left-right-left-right-center, you can use tcbraster. – Ignasi Jul 04 '16 at 11:51