latex

How can I specify a vertical spacing within a breakable tcolorbox?


I would like to define tcolorboxes including a user specified blank space (purpose: having a question/answer box for students to fill) that can be broken. For example, here is what I would like to have :

----------------- % Begin of tcolorbox
Some preliminary text \lipsum[1]
%%% exactly X cm blank vertical space below (may it be broken or not) %%%



----------------- % End of tcolorbox

The difficulty comes when the breakable tcolorbox gets broken: I've tried to use \vspace{} after \tcbbreak or tcblower, specify an explicit height to the tcolorbox's parameters (that fails because of the breakable option), use height fixed for... but no option seems valid for having exactly the desired height. Either specifying the blank space height of the total tcolorbox height would be fine.

Does anyone would have an idea on how to achieve this?

MRE:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\begin{document}

\newtcolorbox{box_test}{enhanced,breakable,title={Title}}

\lipsum[1-3]
\begin{box_test}
\lipsum[1]
\vspace{10cm}

Exactly 10cm empty space above wanted across page break.
\end{box_test}

\begin{box_test}
\lipsum[1]
\vspace{10cm}

Exactly 10cm empty space above obtained without page break.
\end{box_test}
\end{document}

Solution

  • You could add empty lines instead of just one fixed space (adjust the number of lines to whatever gives you the desired amount of space):

    \documentclass{article}
    \usepackage[most]{tcolorbox}
    \usepackage{lipsum}
    
    \begin{document}
    
    \newtcolorbox{box_test}{enhanced,breakable,title={Title}}
    
    \lipsum[1-3]
    \begin{box_test}
    \lipsum[1]
    \foreach \macro in {1,...,20}{\mbox{}\par}
    Exactly 10cm empty space above wanted across page break.
    \end{box_test}
    
    \begin{box_test}
    \lipsum[1]
    \foreach \macro in {1,...,20}{\mbox{}\par}
    Exactly 10cm empty space above obtained without page break.
    \end{box_test}
    \end{document}