4

I am using the exam class to write up a document with questions, but with long passages of text between the questions. In order to get the indentation correct, I have been using \fullwidth{} for those long passages of text.

However this messes up pagebreaks. After a question ends and a \fullwidth{} begins, it seems that LaTeX tries to keep the entire \fullwidth{} text on one page. So you get a pagebreak immediately after the question, even if that leaves most of a page of whitespace, and the fullwidth text begins on the next page.

My best guess is that \fullwidth{} was only designed for one or two sentences of text at most, so I'm looking for some way around this.

Minimally working example below:

\documentclass{exam}            

\title{A minimally working example} 
\author{Confused Classicist}

\begin{document}
\maketitle
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor    incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\begin{questions}
%%%%
\question  Translate the above passage.
%%%%%
\fullwidth{  All of this text is within one fullwidth command, up until the next question.  You only see the effect when you put in enough text to fill up the first page.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Here ends the fullwidth command.
}
\question Do you value ancient languages?

\fullwidth{This fullwidth command does not have enough text here to fill up this page, so there's no problem. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}

\end{questions}
\end{document}
1
  • 1
    Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – jub0bs
    Commented Apr 13, 2013 at 13:39

1 Answer 1

7

Looking at the exam.cls \fullwidth is a very simple macro that consists almost entirely of wrapping the text in a vbox that will prevent page breaking:

\long\def\fullwidth#1{%
  \par\bigskip
  \vbox{%
    % We entered internal vertical mode, and so we get \parshape=0.
    \leftskip=0pt \rightskip=0pt
    \advance\linewidth\@totalleftmargin
    \@totalleftmargin=0pt
    #1%
  }% vbox
  \nobreak
}

So presumably this does the same but allowing breaking

\long\def\xfullwidth#1{%
  \par\bigskip
 % \vbox{%
     \begingroup
     \parshape=0
    % We entered internal vertical mode, and so we get \parshape=0.
    \leftskip=0pt \rightskip=0pt
    \advance\linewidth\@totalleftmargin
    \@totalleftmargin=0pt
    #1%
 %  }% vbox
 % \nobreak
   \par\endgroup
}

this is not tested as no example is included in your question. Also it is not at all the latex way of doing things (which should always use a list environment to change margins) but I don't know why the original definition used that form so I have kept it here.

5
  • Ah, this seems to mostly work with the minimal working example I just added (thanks for the reminder). There's a typo, perhaps with the \@totalleftmargin parts that causes this text to get printed at the beginning of each environment: . totalleftmargin totalleftmargin=0pt Sorry, I'm not fluent enough to find the error quickly. Commented Apr 13, 2013 at 14:41
  • 2
    oh you need to put it in a .sty file or surround with \makeatletter .. \makeatother in ordert o use commands with @ in their name Commented Apr 13, 2013 at 14:54
  • Thanks! Did the trick. It does look like there is one typo in your file, the period after \parshape=0. should be removed. Otherwise you get a period printed at the beginning of each environment. Commented Apr 13, 2013 at 15:03
  • @WilliamKennerly sorry about the . cut and paste from the comment on the original but that was a sentence not code:-) Commented Apr 13, 2013 at 15:29
  • This also helps to use \stretch inside solutions in fullwidth.
    – fabikw
    Commented Nov 2, 2016 at 18:41

You must log in to answer this question.

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