[Tex/LaTex] How to make minipage spanning multiple pages

minipagepage-breaking

I'm using this resume template: https://github.com/deedydas/Deedy-Resume
Example Resume

This template uses minipage to build a layout like :

+-----------------+
|      Header     |
+------+----------+
|      |          |
|      |          |
| side |   Body   |
| bar  |          |
|      |          |
|      |          |
|      |          |
+------+----------+

Using:

\documentclass{article}  
\begin{document}
\begin{minipage}[t]{0.33\textwidth} 
Sidebar
\end{minipage}
\begin{minipage}[t]{0.66\textwidth} 
Body
\end{minipage}
\end{document}

However, if the body gets too long I end up with something like this:

+-----------------+
|      Header     |
+-----------------+
~pagebreak~        
+------+----------+
|      |          |
| side |   Body   |
| bar  |          |
|      |          |
|      |          |
|      |          |
+-----------------+
       | Overflow |
       |          |
       |          |
       +----------+

Instead of this:

+-----------------+
|      Header     |
+------+----------+
|      |          |
|      |          |
| side |   Body   |
| bar  |          |
|      |          |
|      |          |
|      |          |
+------+----------+
       ~pagebreak~ 
       +----------+
       |          |
       |          |
       |          |
       |          |
       +----------+

I understand that minipages aren't designed to span multiple page but is there a way to make this template work using another environment ?

Thanks !

Best Answer

The following attempt uses tcolorbox to create a breakable box to contain the body minipage. The side bar is added as an overlay for the first box part.

This gives the following code:

\documentclass{article}
\usepackage[skins,breakable]{tcolorbox}
\usepackage{lipsum}% example texts
\begin{document}

\textcolor{red}{Header} %  <------------------------
\lipsum[1]

\begin{tcolorbox}[
  blanker,
  width=0.64\textwidth,enlarge left by=0.36\textwidth,
  before skip=6pt,
  breakable,
  overlay unbroken and first={%
    \node[inner sep=0pt,outer sep=0pt,text width=0.33\textwidth,
      align=none,
      below right]
      at ([xshift=-0.36\textwidth]frame.north west)
  {%
    \textcolor{red}{Sidebar} %  <------------------------
    \lipsum[2]
  };}]
\textcolor{red}{Body}: %  <------------------------
\lipsum[3-7]
\textcolor{red}{End of body}
\end{tcolorbox}

\end{document}

I marked the spots for header, side bar and body. The output is:

enter image description here

If needed, everything could be put into a macro or environment for a nicer interface.

Related Question