[Tex/LaTex] minipage with page break

columnsminipagepage-breaking

I'm using LaTeX for writing math tests. Every task I wrap into an environment, which I defined like this:

  \NewEnviron{beispiel}[1]{\begin{minipage}[t]{0.76\textwidth}
    \BODY
    \end{minipage} \hfill
    \begin{minipage}[t]{0.1\textwidth} \begin{flushright} \small{\_\_\_/#1}\end{flushright}\addtocounter{punkte}{#1}\end{minipage}} 

So I actually want two columns (with different width) and the left one includes the example and the right one includes the points for that example.
My environment works perfectly well, but I need automatic page breaks for long examples. Is there a way to do this?

I also tried out the longtable-package (no page breaks within a row) parcolumns-package (enumeration, vspace don't work) – but I didn't manage to get what I want.

Example:

    \documentclass[a4paper,12pt]{report}

    \usepackage{geometry}
    \geometry{a4paper,left=18mm,right=18mm, top=3cm, bottom=2cm}
    \usepackage{lmodern}
    \usepackage[T1]{fontenc}


  \usepackage{setspace}
\usepackage{environ}
    \usepackage{blindtext}


    \onehalfspacing
    \newcounter{punkte}
    \NewEnviron{beispiel}[1]{\begin{minipage}[t]{0.76\textwidth}
    \BODY
    \end{minipage} \hfill
    \begin{minipage}[t]{0.15\textwidth} \begin{flushright} \small{\_\_\_/#1 Pkt.}\end{flushright}\addtocounter{punkte}{#1}\end{minipage}}


    \begin{document}
    \begin{enumerate}

    \item \begin{beispiel}{3} %points of the example

    \blindtext \\
    \blindtext \\
    \blindtext \\
    \blindtext \\

    \end{beispiel}

    \end{enumerate}
    \end{document}

I hope someone can help… Cheers

Best Answer

Almost always in such cases you need a list rather than minipages or tables.

here I use a list that borrows from enumerate and description to handle the enumeration counter but use the optional argument of \item to set the points.

enter image description here

\documentclass[a4paper,12pt]{report}

\usepackage{geometry}
\geometry{a4paper,left=18mm,right=18mm, top=3cm, bottom=2cm}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{setspace}
\usepackage{blindtext}
\
\newcounter{punkte}

\onehalfspacing

\makeatletter
\newenvironment{bbb}{%
      \list
        {}
        {%
    \rightmargin.25\textwidth
    \usecounter{enumi}%
    \def\makelabel##1{\refstepcounter{enumi}%
    \hss\llap{\labelenumi}%
    \addtocounter{punkte}{##1}%
    \rlap{\kern\dimexpr\textwidth-\leftmargin
    \llap{\small\_\_\_/##1/ Pkt.}}}}%
}
{\endlist}
\makeatother

\begin{document}

\noindent X\dotfill X

\begin{bbb}
\item[3] %points of the example

\blindtext 

\blindtext 

\blindtext 

\blindtext 

\item[2] %points of the example

zzz zzz zzz zzz zzz

\end{bbb}
\end{document}