diff --git a/ouexam.dtx b/ouexam.dtx index e952bb0..8f15d16 100644 --- a/ouexam.dtx +++ b/ouexam.dtx @@ -35,7 +35,7 @@ % % \fi % -%% \CheckSum{896} +%% \CheckSum{899} %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -1082,7 +1082,7 @@ % \changes{2.0}{2002/01/15}{NJS Fixed headers so that the page number is always centered.} % \changes{2.1.1}{2006/08/21}{NJS Updated \textsf{lastpage} style to display ``\textbf{END}''.} % \changes{2.3}{2012/09/03}{NJS Rearranged headers and footers to conform to the latest formatting requirements. Swapped \fbox{MARKING SCHEDULE} and \fbox{DRAFT} between header and footer so that the page number doesn't get overprinted.} -% \changes{2.4}{2013/06/06}{NJS Replaced the \texttt{lastpage} page style with direct manipulation of the footer contents, as \cs{pagestyle} and \cs{thispagestyle} don't get applied to automatically generated float pages on the last page of the document.} +% \changes{2.4}{2013/06/06}{NJS Replaced the \textsf{lastpage} page style with direct manipulation of the footer contents in the \textsf{plain} page style, as \cs{pagestyle} and \cs{thispagestyle} don't affect automatically generated float pages on the last page of the document.} % %\begin{macro}{\if@lastpagetext} %\begin{macro}{\if@lastpagefloat} @@ -1111,9 +1111,9 @@ \llap{\parbox[b]{\columnwidth}{\raggedleft\textbf{% % \end{macrocode} % -% An additional complication is that only the very last page of the document should have ``\textbf{END}'' displayed in the footer instead of ``\textbf{TURN OVER}''. This turns out to be a lot harder than you might think! Simply applying a page style \cs{AtEndDocument} works fine, \emph{except} when you have unprocessed floats at the end of the document. These are placed on an automatically-generated float page at the end, which \cs{pagestyle} and \cs{thispagestyle} don't affect. That is, a \textsf{lastpage} page style simply won't work in this situation. +% An additional complication is that only the very last page of the document should have ``\textbf{END}'' displayed in the footer instead of ``\textbf{TURN OVER}''. This turns out to be a lot harder than you might think! Simply applying a \textsf{lastpage} page style \cs{AtEndDocument} works fine, \emph{except} when you have unprocessed floats at the end of the document. These are placed on one or more automatically-generated float pages at the end, which \cs{pagestyle} and \cs{thispagestyle} don't affect. That is, a \textsf{lastpage} page style simply doesn't work in this situation. % -% The solution is therefore to not use a page style, but rather check in the \textsf{plain} page style whether or not this is the last page. Again, this isn't as simple as it sounds! The logic goes like this: +% The solution is therefore to not use a page style, but rather check in the \textsf{plain} page style whether or not this is the last page, because the page style macro will be expanded for every float page that is generated. Again, this isn't as simple as it sounds! The logic goes like this: % % \begin{itemize} % @@ -1123,7 +1123,15 @@ % % \begin{itemize} % -% \item If the float page is currently being generated (indicated by \cs{@fcolmadetrue} from \texttt{latex.ltx}), output ``\textbf{END}''. +% \item If a float page is currently being generated (indicated by \cs{@fcolmadetrue} from \texttt{latex.ltx}), then: +% +% \begin{itemize} +% +% \item If there are no more unprocessed floats (\cs{@deferlist} is empty), output ``\textbf{END}''. +% +% \item Otherwise, output ``\textbf{TURN OVER}''. +% +% \end{itemize} % % \item Otherwise, output ``\textbf{TURN OVER}''. % @@ -1132,11 +1140,10 @@ % \item Otherwise, output ``\textbf{TURN OVER}''. % % \end{itemize} -% -% Note that this currently fails if more than one float page needs to be generated at the end of the document. \emph{All} such pages will have ``\textbf{END}'' printed at the bottom. % \begin{macrocode} \if@lastpagetext END% - \else\if@lastpagefloat\if@fcolmade END% + \else\if@lastpagefloat\if@fcolmade\ifx\@deferlist\@empty END% + \else TURN OVER\fi% \else TURN OVER\fi% \else TURN OVER\fi% \fi}}}% @@ -1147,21 +1154,20 @@ % \end{macro} % % \textsf{plain} is the default page style: +% % \begin{macrocode} \pagestyle{plain} % \end{macrocode} % -% \cs{AtEndDocument}, we need to set the \texttt{lastpage} switches accordingly. The \cs{@deferlist} macro from \texttt{latex.ltx} holds a list of any unprocessed floats, so if this is empty, we know that there's nothing more to do and can just set \cs{@lastpagetexttrue}. If the list still contains unprocessed floats, set \cs{@lastpagefloattrue} then \cs{clearpage} to force the floats out. We also need to decrement the page counter by one, otherwise it ends up being one too many, presumably as a result of the \cs{clearpage}. -% -% I suspect that this will fail if the document uses \textsf{twocolumn} and has double floats that span both columns, because there is a separate \cs{@dbldeferlist}. Also, as noted above, this currently doesn't account for multiple float pages at the end of the document. +% \cs{AtEndDocument}, we need to set the \texttt{lastpage} switches accordingly. The \cs{@deferlist} macro from \texttt{latex.ltx} holds a list of any unprocessed floats, so if this is empty, we know that there's nothing more to do and can just set \cs{@lastpagetexttrue}. If the list still contains unprocessed floats, set \cs{@lastpagefloattrue} then \cs{clearpage} to force the floats out. We also need to decrement the page counter by one, otherwise it ends up being one too many, which is presumably a side effect of the explicit \cs{clearpage}. % \begin{macrocode} \AtEndDocument{% \ifx\@deferlist\@empty% \@lastpagetexttrue% \else% \@lastpagefloattrue% - \clearpage% - \addtocounter{page}{-1}% + \clearpage% + \addtocounter{page}{-1}% \fi% } % \end{macrocode}