最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

latex - How can I specify a vertical spacing within a breakable tcolorbox? - Stack Overflow

programmeradmin3浏览0评论

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}

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}
Share Improve this question edited Mar 20 at 14:39 Mathieu Coquerelle asked Mar 20 at 11:05 Mathieu CoquerelleMathieu Coquerelle 1015 bronze badges 1
  • Did you check this tex.stackexchange/questions/194427/… – Naveed Ahmed Commented Mar 20 at 11:17
Add a comment  | 

1 Answer 1

Reset to default 0

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}
发布评论

评论列表(0)

  1. 暂无评论