Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

For some time, version 2.01 of the exam document class has been used in my department. In the future we are going to use the latest version (currently 2.4), and this has to be customised so that existing papers typeset as before. In the example below, the new version of exam.cls puts in an extra page break.

\documentclass{exam}
\setlength{\textheight}{8.8in} %set \textheight as in the old version
\extraheadheight[.7in]{-.2in}
%
\begin{document}
\hrule
\newpage
\showthe\textheight
\hrule
\vskip408pt
\hrule
\begin{center}
\rule{0.5\textwidth}{212pt}
\end{center}
\end{document}

Our existing exam papers include the \extraheadheight command shown here. I expected setting \textheight to 8.8in (the value used by version 2.01 of exam.cls) and then including \extraheadheight to reproduce the behaviour of the old version, but in this case it does not.

Why does this happen?

share|improve this question
    
I get a \textheight of 8.8in by removing the \extraheadheight command. Otherwise the text height is 9in. –  egreg Feb 22 '12 at 15:43
    
@egreg --- the \extraheadheight is required for our purposes. I removed the headers from the example, to make it as minimal as possible. I can't reproduce the problem without \extraheadheight, though. –  Ian Thompson Feb 22 '12 at 15:54
    
The final \textheight is 9in, so try setting it to 8.6in in the second line. –  egreg Feb 22 '12 at 15:57
    
@egreg --- do you mean set it to 9in in the second line? Either way, I only get different behaviour from the two versions of exam.cls when I include \extraheadheight. –  Ian Thompson Feb 22 '12 at 16:03
    
@egreg --- I've added some extra detail to clarify the question. –  Ian Thompson Feb 22 '12 at 16:16

1 Answer 1

up vote 5 down vote accepted
+100

After a vast odyssey through source2e.pdf and both versions of exam.cls (most of which was unnecessary) I bring you the following fix:

\usepackage{etoolbox}
\makeatletter
 \patchcmd\@setheadheight{\endgroup}{\global\vsize=\textheight\endgroup}{}{}
\makeatother

Perhaps some explanation is in order. According to exam.cls, version 2.4, a bugfix was introduced in version 2.307beta (2009/03/28):

% We fixed a bug that arose only when the user used a figure or
% table environment that floated to the top of a page.  If that
% happened, then a full page's worth of text was placed below
% the figure or table, makeing the text run over the footline and off
% the bottom of the page.
%
% We fixed this by commenting out several lines at the end of
% \@setheadheight and @setfootheight.

The lines commented out included the one that sets \vsize. Should you want them all, they are:

\global\@colroom=\textheight
\global\vsize=\textheight
\global\pagegoal=\textheight

Aside from minor changes in the structure of the code, that's the only difference between \extraheadheight in v2.4 and v2.01, and as you can see, it accounts for your bug:

\documentclass{exam}
% Comment out the next four lines to get 3 pages instead of 2 in v2.4
\usepackage{etoolbox}
\makeatletter
 \apptocmd\@setheadheight{\global\vsize=\textheight}{}{}
\makeatother
\extraheadheight[.7in]{-.2in}
\begin{document}
 \hrule
 \newpage
 \hrule
 \vskip408pt
 \hrule
 \begin{center}
  \rule{0.5\textwidth}{212pt}
 \end{center}
\end{document}

Effectively, the old behavior you observe is considered incorrect and you can get it back by reinserting a bug that was removed three years ago!

share|improve this answer
    
If only I had checked the value of \vsize! I'll add a keepoldpagebreaks option to our customised class, but I won't restore the behaviour by default since it's a bug. –  Ian Thompson Mar 1 '12 at 12:09
    
I don't even know what \vsize does; I think it's one of the raw TeX page dimensions, not one of the more nuanced LaTeX ones. Presumably one should not be setting it at all. –  Ryan Reich Mar 1 '12 at 15:56
    
Oh, I should mention that the same change was made to \@setfootheight, so perhaps you should patch it as well, in case people used it too. –  Ryan Reich Mar 1 '12 at 18:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.