2

I would like to define two minipage (or tcolorbox, I don't have much constraint there) environments, on two different pages, that I would like to fill with some text, and I would like LaTeX to spread the text between these two minipage environments automatically.

In other words, I would like to declare two minipage environments, separated by a \newpage command, and to declare the text that will fill the first minipage environment first, and then, once that first minipage environment is full, to send the remainder to the second minipage environment. It would be something like that (this is not a reduced example, because I have no idea where to start):

\begin{document}

\begin{minipage}[t][16cm][t]{18cm}
First part of my text.
\end{minipage}

~\newpage

\begin{minipage}[t][15cm][t]{18cm}
Second part of my text.
\end{minipage}

\end{document}

Of course, I can manually break my text into two parts, and write the first part in the first minipage environment and the second part of the text in the second minipage environment. However, I actually would like LaTeX to do that automatically (I am writing a template for a monthly report, and the text that has to fit in these two environments is loaded from a single .txt file, of variable size - so everytime a change in that file is implemeted, I would have to look for the proper position where I should break it).

I also need the ~\newpage command to control for the page break because I have to place stuff using texblock* environments on both the first and the second page - so if I let LaTeX make the second page by itself, all my texblock* commands will be put on the first page only.

It would look like that:

Page 1:
 _______________________________________
|    Stuff positioned with textblock    |
|_______________________________________|

     _______________________________
    |                               |
    |                               |
    |     First part of my text     |
    |                               |
    |                               |
    |_______________________________|

 _______________________________________
| Other Stuff positioned with textblock |
|_______________________________________|

Page 2:
 _______________________________________
| Other Stuff positioned with textblock |
|_______________________________________|

     _______________________________
    |                               |
    |                               |
    |    Second part of my text     |
    |                               |
    |                               |
    |_______________________________|

 _______________________________________
| Other Stuff positioned with textblock |
|_______________________________________|

Would you have any idea on how to do that?

1
  • The framed or shaded environments automatically break over pages if they do not fit on a single page.
    – Bernard
    Commented Feb 20, 2022 at 15:00

2 Answers 2

0

I found (after a lot of time) this link How to make minipage spanning multiple pages I discover the flowfram package, it should meet your needs.

If it's the same textblock on each page, no need for an option in \newstaticframe[1]{\textwidth}{.25\texttheight}{0pt}{.75\texttheight}[p1]%head

    \documentclass{article}
    \usepackage[margin=.5in]{geometry}
    \usepackage{flowfram,lipsum}

    \newstaticframe{\textwidth}{.25\textheight}{0pt}{.75\textheight}[p]
    \newstaticframe[1]{\textwidth}{.25\textheight}{0pt}{.75\textheight}[p1]%head
    %\newstaticframe[1]{\textwidth}{.7\textheight}{0pt}{-15cm}[bp1]% bottom
    % if the same text on every page the option is not necessary
    \newstaticframe{\textwidth}{.7\textheight}{0pt}{-15cm}[bp]% bottom
    %% for the other pages (if not the same text)
    \newstaticframe[2]{\textwidth}{.25\textheight}{0pt}{.75\textheight}[p2]%head
    \newstaticframe[3]{\textwidth}{.25\textheight}{0pt}{.75\textheight}[p3]%head
    \newstaticframe[4]{\textwidth}{.25\textheight}{0pt}{.75\textheight}[p4]%head
    \setallstaticframes{valign=t}

    \newflowframe{0.7\textwidth}{0.5\textheight}{.2\textwidth}{5cm}
    %
    \pagestyle{empty}

    \begin{document}


    \begin{staticcontents*}{p1}
        \large{TEXT of the first page}
    \end{staticcontents*}

    \begin{staticcontents*}{p2}
        \large{TEXT of the second page}
    \end{staticcontents*}

    \begin{staticcontents*}{p3}
        \large{TEXT of the third page}
    \end{staticcontents*}

    \begin{staticcontents*}{p4}
        \large{TEXT of the fourth page}
    \end{staticcontents*}

    \begin{staticcontents*}{bp}
        \large{TEXT of the bottom of all pages}% it can change
    \end{staticcontents*}

    \lipsum[1-4]
    \framebreak
    \lipsum[5-10]
    \end{document}
1

if you already know the available space on your page, you can use magazine library from tcolorbox and place every fragment on different pages, even in wrong order.

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

\begin{document}

\begin{tcolorbox}[enhanced, breakable, 
    reset box array, store to box array, 
    empty,
    break at=10cm,
    height fixed for = all,
    valign=center]
    \lipsum[1-3]
\end{tcolorbox}

\consumetcboxarray{1}{colback=blue!30}

\newpage

\consumetcboxarray{2}{colback=red!30}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .