# tcolorbox: wrong column width and space between columns

I don't know why but I can't manage to get equal width columns, with a correct column skip using tcolorbox if the columns does not fill the whole page. Here is a picture:

If the columns fill the whole page, I don't have any trouble, the columns have the same size and have the same spacing:

However, if I reduce the size, the boxes does not have the same width, and the spacing is clearly not equal to 3mm:

Do you know why?

Thank you!

MWE:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcbitemize}[nobeforeafter,
raster columns=2,
raster rows=2,
% Works when full width
% raster width=\textwidth,
% raster height=\textheight,
% Does not work when smaller width
raster width=.5\textwidth,
raster height=.5\textheight,
% ----
raster row skip=3mm,
raster column skip=3mm]%
\tcbitem[raster multirow=2,blankest]%
\begin{tcbitemize}[raster columns=1,raster rows=2]%
\tcbitem[colback=red]{A}
\tcbitem[colback=red]{B}
\end{tcbitemize}%
\tcbitem[raster multirow=2,raster multicolumn=1,colback=red]{C}%
\end{tcbitemize}%

\end{document}

• The title Tcolor is misleading. You mean tcolorbox – user31729 Nov 8 '17 at 6:27

## 2 Answers

The inner tcbitemize environment needs an additional parameter, viz.,

raster width=\textwidth


Why? The outer tcbitemize environment specifies both raster columns=2 and raster width=0.5\linewidth. The total width of both columns taken together is 0.5\textwidth, and each column's width is thus 0.25\textwidth (abstracting from the fact that there's 3mm of whitespace between the blocks).

Unless these parameters are overridden explicitly, they apply to the inner tcbitemize environment as well. The length variable \textwidth, by design, adjusts dynamically. To make the single column in the inner tcbitemize environment take up the full available width (which is \textwidth, as \textwidth has been adjusted), we need the additional option raster width=\textwidth.

The full MWE:

\documentclass{article}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcbitemize}[nobeforeafter,
raster columns=2,
raster rows=2,
raster width=.5\textwidth,
raster height=.5\textheight,
raster row skip=3mm,
raster column skip=3mm]
\tcbitem[raster multirow=2,blankest]
\begin{tcbitemize}[raster columns=1,raster rows=2,
raster width=\textwidth]% <-- new
\tcbitem[colback=red]{A}
\tcbitem[colback=red]{B}
\end{tcbitemize}
\tcbitem[raster multirow=2,raster multicolumn=1,colback=red]{C}
\end{tcbitemize}

\end{document}


An alternative for this construction could be tcbposter library introduced in tcolorbox v4.10.

A tcolorbox poster is an unbreakable array of boxes which provides easy/flexible options to place boxes with different widths and heights.

Two examples with tcbposters are shown in Creating this poster layout using minipages or Dynamic box size

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\begin{document}
\begin{tcbposter}[
poster = {
%       showframe,
columns = 2,
rows = 2,
height = .5\textheight,
width = .5\textwidth,
spacing=3mm},
boxes = {colback=red}
]
\posterbox{column=1, row=1}{A}
\posterbox{column=1, row=2}{B}
\posterbox{column=2, row=1, rowspan=2}{C}
\end{tcbposter}%

\end{document}


• Interesting, I may use it for some stuff, thank you! – tobiasBora Nov 8 '17 at 12:23