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?

3
  • Very much the same as Detecting current column in multicol
    – Runar
    Commented Jul 4, 2016 at 10:34
  • The last minipage in your MWE ends up in the right column, not left. The 2nd minipage goes in the left column. With 1/2/3 before \blindtext : i.imgur.com/3k6RAnw.png
    – alwaysask
    Commented Jul 4, 2016 at 11:11
  • @alwaysask: Hmm, can I then make it rather like <left-right-left-right-center>?
    – arc_lupus
    Commented Jul 4, 2016 at 11:24

1 Answer 1

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

3
  • What is the difference between tcbraster and multicol?
    – arc_lupus
    Commented Jul 4, 2016 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
    Commented Jul 4, 2016 at 11:38
  • @arc_lupus If you want organize boxes as left-right-left-right-center, you can use tcbraster.
    – Ignasi
    Commented Jul 4, 2016 at 11:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .