[Tex/LaTex] Placing two tcolorboxes side by side

boxestcolorbox

I am working on a latex document that uses tcolorboxes and I want to place two different tcolorboxes side by side. How can I achieve this?

EDIT: I found that using minipage we can achieve this. This is demonstrated here.

Best Answer

Here is the tcbraster way to place two (or more?) boxes side by side, by using the tcbraster environment and raster columns=2.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begin{tcbraster}[raster columns=2,raster equal height]
\begin{tcolorbox}[nobeforeafter, title=box 1]
\lipsum[2]
\end{tcolorbox}
\begin{tcolorbox}[nobeforeafter, title=box 2]
\lipsum[2]
\end{tcolorbox}
\end{tcbraster}
\lipsum[2]
\end{document}

Update with more options:

Any option, that is not specific to the raster library will be handed over to the rastered tcolorbox environments, as such, those options have not to be specified each time, but only once in the raster setup.

Use raster column skip to increase the horizontal gap between the boxes:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begin{tcbraster}[raster columns=2,raster equal height,nobeforeafter,raster column skip=2cm]
  \begin{tcolorbox}[title=box 1]
    \lipsum[2]
  \end{tcolorbox}
  \begin{tcolorbox}[title=box 2]
    \lipsum[2]
  \end{tcolorbox}
\end{tcbraster}
\lipsum[2]
\end{document}

enter image description here

Related Question