In the following situation, when the outer left box is higher than the outer right box, i want to have the greatest possible height for the inner boxes (inside the raster of the outer right box).
\documentclass[11pt]{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbuselibrary{raster}
\begin{document}
\tcbset{%
outer left/.style={frame hidden, boxrule=0pt, boxsep=5pt, colback=yellow, halign=center, valign=center},
outer right/.style={frame hidden, boxrule=0pt, boxsep=2pt, colback=orange, halign=center, valign=center},
inner right/.style={boxsep=3pt, halign=center, valign=center}
}
\begin{tcbraster}[raster columns=2, raster equal height=rows, raster valign=center]
\begin{tcolorbox}[outer left]
w\\
x\\
y\\
z
\end{tcolorbox}
%
\begin{tcolorbox}[outer right]
\begin{tcbraster}[raster columns=3]
\begin{tcolorbox}[inner right]
d
\end{tcolorbox}
%
\begin{tcolorbox}[inner right]
e
\end{tcolorbox}
%
\begin{tcolorbox}[inner right]
f
\end{tcolorbox}
\end{tcbraster}
\end{tcolorbox}
\end{tcbraster}
\end{document}
I have come up with a hacky solution (far from being perfect) that seems to work after two successive compilations.
\documentclass[11pt]{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbuselibrary{raster}
\begin{document}
\tcbset{%
outer left/.style={frame hidden, boxrule=0pt, boxsep=5pt, colback=yellow, halign=center, valign=center},
outer right/.style={frame hidden, boxrule=0pt, boxsep=2pt, colback=orange, halign=center, valign=center},
inner right/.style={boxsep=3pt, halign=center, valign=center, ht}
}
\makeatletter
\begin{tcbraster}[raster columns=2, raster equal height=rows, raster valign=center]
\begin{tcolorbox}[outer left]
w\\
x\\
y\\
z
\end{tcolorbox}
%
\begin{tcolorbox}[outer right,
code={%
\edef\tcb@ehgid{\kvtcb@raster@ehgid @\number\c@tcbrasterrow}%
\ifcsundef{tcb@ehg@height@\tcb@ehgid}%
{\tcbset{ht/.style={}}}%
{%
\tcbheightfromgroup\myht{\tcb@ehgid}%
\tcbdimto\myresult{\kvtcb@top@rule@stand+\kvtcb@bottom@rule@stand+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom}%
\iftcb@hasTitle%
\tcbdimto\myresult{\tcbtextheight+\ht\tcb@titlebox+\dp\tcb@titlebox+\kvtcb@title@rule+\kvtcb@boxsep*2+\kvtcb@toptitle+\kvtcb@bottomtitle}%
\fi%
\tcbdimto\myresult{\myht-\myresult}%
\tcbset{ht/.style={height=\myresult}}%
}%
}
]
\begin{tcbraster}[raster columns=3]
\begin{tcolorbox}[inner right]
d
\end{tcolorbox}
%
\begin{tcolorbox}[inner right]
e
\end{tcolorbox}
%
\begin{tcolorbox}[inner right]
f
\end{tcolorbox}
\end{tcbraster}
\end{tcolorbox}
\end{tcbraster}
\makeatother
\end{document}
But this solution requires me to delete the auxillary file and to recompile twice if any changes are made to the code (boxes content or settings like boxsep
and so on).
Does anyone have a better solution? Thanks !