7

I am looking for a tcolorbox that has the hight like a \vfill.

I have a page with tcolorboxes.
If there is some space left on the page, I would like to extend the hight of a box in the middle of the page. The box should have the hight of a \vfill.

There is alreadey a very nice feature, the option height fill that does exactly what I want but just for the last box on the page.

Would be great, if the solution also works for a raster like the example.

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\begin{document}
other 
\clearpage
\begin{tcolorbox}a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\end{tcolorbox}
\begin{tcbraster}[%
    raster columns=2,
    raster rows=1,
    raster height=6cm, % manual adjustment :-( 
    %raster height=\vfill,% I would like to have the hight like \vfill
    %height fill,% Nice, but only working at the end of the page :-(
]
    \begin{tcolorbox}
        Here we will have a plot that is nice to extend if there is some space left on the page.
    \end{tcolorbox}
    \begin{tcolorbox}
        Here we will have a plot that is nice to extend if there is some space left on the page.
    \end{tcolorbox}
\end{tcbraster}
\begin{tcolorbox}a\\a\\a\\a\\a\\a\\a\\a\\a\\a
\end{tcolorbox}
\clearpage
other 
\end{document}

I want to extend the two boxes in the middle to fill the page.

@cfr

As you advised, I have put all boxes in the raster. The first and the last box should be natural height. Could you please show me how to extend the two boxes in the middle to fill the page?

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\begin{document}
other 
\clearpage
\begin{tcbraster}[%
    raster columns=1,
    raster rows=3,
    raster height=\textheight,
    ]
    \begin{tcolorbox}[reset,natural height]
        a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a
    \end{tcolorbox}
    \begin{tcbraster}[%
        raster columns=2,
        raster rows=1,
        raster height=6cm,% how to extend the height to fill the page?
    ]
        \begin{tcolorbox}
            Here we will have a plot that is nice to extend if there is some space left on the page.
        \end{tcolorbox}
        \begin{tcolorbox}
            Here we will have a plot that is nice to extend if there is some space left on the page.
        \end{tcolorbox}
    \end{tcbraster}
    \begin{tcolorbox}[reset,natural height]
        a\\a\\a\\a\\a\\a\\a\\a\\a\\a
    \end{tcolorbox}
\end{tcbraster}
\clearpage
other 
\end{document}
  • Why can't you put the final box inside the raster? – cfr Jan 24 '16 at 21:22
  • Thanks for your advide. I have edit to show an MWE with all boxes in a raster that has \textheight. First and last box is natural height. Could you please advise me how to extend the box in the middle to fill the page? – Tobias Jan 25 '16 at 10:45
5

This needs some manual effort. In my code, the height of the top and bottom boxes are saved by equal height groups of name topbox and bottombox. Now, the height of the middle boxes are set to \textheight-\topboxheight-\bottomboxheight-4mm where 2mm is the space between the boxes.

tcolorbox version 3.80 (2015/11/27) or newer is needed for this answer.

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\tcbuselibrary{breakable}
\begin{document}
other
\clearpage
%-------------------
\begin{tcolorbox}[equal height group=topbox,
  before skip=0mm,after skip=2mm]a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\end{tcolorbox}
\begin{tcbraster}[%
    raster columns=2,
    raster rows=1,
    code={%
      \tcbheightfromgroup\topboxheight{topbox}%
      \tcbheightfromgroup\bottomboxheight{bottombox}%
    },
    raster height=\textheight-\topboxheight-\bottomboxheight-4mm]
    \begin{tcolorbox}
        Here we will have a plot that is nice to extend if there is some space left on the page.
    \end{tcolorbox}
    \begin{tcolorbox}
        Here we will have a plot that is nice to extend if there is some space left on the page.
    \end{tcolorbox}
\end{tcbraster}
\begin{tcolorbox}[equal height group=bottombox,
  before skip=2mm,after skip=0mm]a\\a\\a\\a\\a\\a\\a\\a\\a\\a
\end{tcolorbox}
%-------------------
\clearpage
other
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.