Tcolorbox Side-by-Side Boxes – How to Create 2 Boxes Side by Side

adjustboxtcolorboxtikz-styles

I want to create 2 boxes side by side (image below) in order to have the red box on the right of the blue one :

enter image description here

I wrote this code but I don't know how to do it (I am just specifying the width to fit in the general page):

\documentclass{article}

\usepackage{pgf, tikz, adjustbox}
\usepackage{tcolorbox}


\begin{document}
\tcbset{colback=blue!5!white,colframe=blue!75!black,fonttitle=\bfseries, width = 12cm}
\begin{tcolorbox}[before=\adjustbox{valign=t}\bgroup, after=\egroup]

\textbf{Démonstration}

\end{tcolorbox}

\tcbset{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries, width = 5cm}
\begin{tcolorbox}[before=\adjustbox{valign=t}\bgroup, after=\egroup]

\gap
A écrire 
\end{tcolorbox}
\end{document}

Any help would be appreciated ! Thank you very much.

Best Answer

I found the option box align in the package documentation on page 86 in the PDF. You can set this to top, bottom and center. Here is an example using center:

\documentclass{article}
\usepackage{pgf, tikz, adjustbox}
\usepackage{tcolorbox}
\usepackage{xcolor}
\begin{document}

\tcbset{colback=blue!5!white,colframe=blue!75!black,fonttitle=\bfseries,width=5cm,nobeforeafter}

\begin{tcolorbox}[box align=center]
\textbf{Démonstration}
\end{tcolorbox}
\tcbset{colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,width = 5cm}
\begin{tcolorbox}[box align=center]
\vspace{1cm}
A écrire 
\end{tcolorbox}

\end{document}

This produces the output: enter image description here

Related Question