# tcolorbox: height fill as option to tcbraster

I already asked some questions and I wonder if I am to stupid.

There is a nice option called height fill for the last tcolorbox on the page.

Isn't it possible to have height fill as option to the last tcbraster instead to the last box? In my case just two boxes next to each other. Is the only solution to try it like [tcolorbox: height fill in the middle of the page ?

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{tikzscale}

\begin{filecontents}{tikzimage.tikz}
\begin{tikzpicture}
\begin{axis}[xlabel=time,ylabel=value]
\end{axis}
\end{tikzpicture}
\end{filecontents}

\makeatletter
\tcbset{%
remember height/.style={before upper={%
\iftcb@fixedheight%
\tcbdimto#1{\kvtcb@top@rule@stand+\kvtcb@bottom@rule@stand+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom}%
\iftcb@hasTitle%
\tcbdimto#1{#1+\ht\tcb@titlebox+\dp\tcb@titlebox+\kvtcb@title@rule+\kvtcb@boxsep*2+\kvtcb@toptitle+\kvtcb@bottomtitle}%
\fi%
\tcbdimto#1{\kvtcb@height@fixed-#1}%
\else%
\tcbdimto#1{4cm}% fallback
\fi%
}},
}
\makeatother

\begin{document}
\begin{tcolorbox}
a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a
\end{tcolorbox}
\begin{tcolorbox}
b\\b\\b\\b\\b
\end{tcolorbox}
\begin{tcbraster}[%
raster columns=2,
raster rows=1,
%   height fill,% this does not work :-(
height=4cm, % want to have height=\vfill
]
\begin{tcolorbox}[%
equal height group=mybox,
title={box 1\\line two},remember height=\myheight]
\includegraphics[width=\linewidth,height=\myheight]{tikzimage.tikz}
\end{tcolorbox}
\begin{tcolorbox}[equal height group=mybox]
This box and the box on the left is extendet to fill the page.
\end{tcolorbox}
\end{tcbraster}
\end{document}


@Thomas F. Sturm
I hope this is my last question sorry and thanks so much for your time!

• I think that would be a nice option. Currently, I have no time to investigate, if an implementation can be done, but I put it on my todo list. – Thomas F. Sturm Jan 26 '16 at 6:49

A new answer is possible with tcolorbox version 3.90 (2016/02/29). Now, height fill also works for rasters and the text height of a fixed height box is available through \tcbtextheight:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{tikzscale}

\begin{filecontents}{tikzimage.tikz}
\begin{tikzpicture}
\begin{axis}[xlabel=time,ylabel=value]
\end{axis}
\end{tikzpicture}
\end{filecontents}

\begin{document}
\begin{tcolorbox}
a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a
\end{tcolorbox}
\begin{tcolorbox}
b\\b\\b\\b\\b
\end{tcolorbox}
\begin{tcbraster}
\begin{tcolorbox}[height fill,title={box 1\\line two}]
\includegraphics[width=\linewidth,height=\tcbtextheight]{tikzimage.tikz}
\end{tcolorbox}
\begin{tcolorbox}[height fill]
This box and the box on the left is extendet to fill the page.
\end{tcolorbox}
\end{tcbraster}
\end{document}


Here is something that could help: How to define a figure size so that it consumes the rest of a page?

Just put to preamble:

\newcommand\measurepage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}


Use \measurepage as length for the rest of the page. With that you can fill the rest of the page with content, for example:

\includegraphics[height=\measurepage,width=\textwidth]{cow}


In my case:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{tikzscale}

\newcommand\measurepage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}

\begin{filecontents}{tikzimage.tikz}
\begin{tikzpicture}
\begin{axis}[xlabel=time,ylabel=value]
\end{axis}
\end{tikzpicture}
\end{filecontents}

\makeatletter
\tcbset{%
remember height/.style={before upper={%
\iftcb@fixedheight%
\tcbdimto#1{\kvtcb@top@rule@stand+\kvtcb@bottom@rule@stand+\kvtcb@boxsep*2+\kvtcb@top+\kvtcb@bottom}%
\iftcb@hasTitle%
\tcbdimto#1{#1+\ht\tcb@titlebox+\dp\tcb@titlebox+\kvtcb@title@rule+\kvtcb@boxsep*2+\kvtcb@toptitle+\kvtcb@bottomtitle}%
\fi%
\tcbdimto#1{\kvtcb@height@fixed-#1}%
\else%
\tcbdimto#1{4cm}% fallback
\fi%
}},
}
\makeatother

\begin{document}
\begin{tcolorbox}
a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a
\end{tcolorbox}
\begin{tcolorbox}
b\\b\\b\\b\\b
\end{tcolorbox}
\begin{tcbraster}[%
raster columns=2,
raster rows=1,
%   height fill,% this does not work :-(
height=\measurepage, % want to have height=\vfill
]
\begin{tcolorbox}[%
equal height group=mybox,
title={box 1\\line two},remember height=\myheight]
\includegraphics[width=\linewidth,height=\myheight]{tikzimage.tikz}
\end{tcolorbox}
\begin{tcolorbox}[equal height group=mybox]
This box and the box on the left is extendet to fill the page.
\end{tcolorbox}
\end{tcbraster}
\end{document}


Use it at your own risk. This might not be really reliable. But at least here it works.

edit: Does not work with \usetikzlibrary{external}! :-(

• +1 for simple and elegant solution! I wasn't aware of the \pagegoal and \pagetotal lengths and wondered, which package one needs for that or if they are pdflatex specials. Apparent to the comments of this answer, however, they are TeX primitives, hence, available with any engine. Nice! – Daniel Jan 27 '16 at 8:34