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.
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.
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}
Like this?
\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\noindent\begin{tcolorbox}[width=.475\textwidth, nobeforeafter, title=box 1]
\lipsum[2]
\end{tcolorbox}\hfill
\begin{tcolorbox}[width=.475\textwidth, nobeforeafter, title=box 2]
\lipsum[2]
\end{tcolorbox}
\lipsum[1]
\end{document}
tcolorbox
after the two tcolorboxes
that you mentioned that I want to place on a different line, it gets shifted to the left of the margin by a few inches, i.e., the first tcolorbox
is vertically slightly to the right of the third one. How will get the left sides of both of them to be vertically aligned?
Commented
Jan 16, 2018 at 18:01
tcbraster
like in Christian's answer.
tcbraster
. But please post a MWE to show what you've tried so far.tcbraster
?