2

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

5
  • 2
    Is that right hand box really just a one line label? (If so you don't need boxes at all, just a list, which will allow page breaking naturally) May 20, 2015 at 8:41
  • Maybe this question could help you tex.stackexchange.com/questions/32704/…
    – Rico
    May 20, 2015 at 8:42
  • Yes, the right hand box is just one line. But I don't see how to do it with a list. Sorry.
    – chris
    May 20, 2015 at 8:58
  • The posted example produces: ! Undefined control sequence. l.12 \NewEnviron and ! LaTeX Error: No counter 'punkte' defined. May 20, 2015 at 9:40
  • I had some commands in an external file. It should work now...
    – chris
    May 20, 2015 at 9:52

1 Answer 1

1

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}

You must log in to answer this question.

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