0

Each tcolorbox must be put on each page for presentation. Some page is overflowed when the tcoloxbox's contents are beyonded height. How can the page height expand in this situation. This is my MWE, the second page's height need to expanded. Thank you in advance! enter image description here

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{lipsum}
\usepackage[margin=2cm,papersize={15cm,10cm}]{geometry}
\usepackage{etoolbox}
\AtBeginEnvironment{tcolorbox}{\newpage}
\begin{document}
\begin{tcolorbox}
    \lipsum[15]
\end{tcolorbox}

\begin{tcolorbox} \lipsum[3-30] \end{tcolorbox}

\begin{tcolorbox} \lipsum[15] \end{tcolorbox} \end{document}

2 Answers2

2

Instead of expanding the page, I'd suggest to break the box is as many pages as needed. It's easy to do it with break library from tcolorbox

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage[margin=2cm,papersize={15cm,10cm}]{geometry}
\usepackage{etoolbox}
\AtBeginEnvironment{tcolorbox}{\newpage}
\begin{document}
\begin{tcolorbox}
    \lipsum[15]
\end{tcolorbox}

\begin{tcolorbox}[breakable, colback=red!30] \lipsum[3-5] \end{tcolorbox}

\begin{tcolorbox} \lipsum[15] \end{tcolorbox} \end{document}

enter image description here

Update: incgraph

incgraph package is used to compile an image collection but keeping the individual page size. This package can be used to declare several pages with size adapted to their length.

\documentclass{article}
\usepackage{incgraph}
\usepackage{tcolorbox}
\usepackage{lipsum}

\begin{document}

\begin{inctext} \begin{tcolorbox} \lipsum[1] \end{tcolorbox} \end{inctext}

\begin{inctext} \begin{tcolorbox}[colback=red!30] \lipsum[2-6] \end{tcolorbox} \end{inctext}

\begin{inctext} Just a line \end{inctext} \end{document}

enter image description here

Ignasi
  • 136,588
  • I have knowd this option. But the contents must be in one slide (page) – Nam Tran Le Aug 11 '21 at 09:42
  • Tcolorbox alse can fit text width box height. But it is difficulty to read because this size is small. – Nam Tran Le Aug 11 '21 at 09:46
  • @NamTranLe I don't understand you. You want to put a lot of text inside a large slide, but when you project it, the text will be so small that nobody will read it. Is this what you want? – Ignasi Aug 11 '21 at 11:57
  • If you want to mix different page sizes, you can try with incgraph (an example: https://tex.stackexchange.com/a/287054/1952). I'm not sure if you need to have independent images previously compiled to include at their real size. – Ignasi Aug 11 '21 at 12:02
  • You can exit presentation this slide, scoll it. – Nam Tran Le Aug 11 '21 at 12:23
  • The geometry can set up new page size and restore with \restoregeometry command. The difficulty is when we need enlarge the page automaticcally. – Nam Tran Le Aug 11 '21 at 12:25
  • @NamTranLe I've added an updated using incgraph to define individual pages. A similar solution can be applied to your other question: https://tex.stackexchange.com/a/620162/1952 – Ignasi Oct 26 '21 at 07:57
  • @lgnasi. Many Thanks – Nam Tran Le Oct 26 '21 at 15:40
2

I believe you want something as follows. It is mainly taken from this answer, except that I removed the manually added \begin{wrapper} and \end{wrapper} calls that are unneeded due to the \tcbset{before=\begin{wrapper}, after=\end{wrapper}} piece of code (automatically adding them is its very purpose!).

\documentclass[multi=wrapper,border=1mm]{standalone}
\usepackage{tcolorbox}
\usepackage{lipsum}

\newenvironment{wrapper}{}{} \tcbset{before=\begin{wrapper}, after=\end{wrapper}}

\begin{document}

\begin{tcolorbox} \lipsum[15] \end{tcolorbox}

\begin{tcolorbox} \lipsum[3-5] \end{tcolorbox}

\begin{tcolorbox} \lipsum[12] \end{tcolorbox}

\end{document}

enter image description here

frougon
  • 24,283
  • 1
  • 32
  • 55