5

How to make \iflastpage{\newgeometry{bottom=40mm}}{} work to have a specific bottom offset for only the last page?

\documentclass{exam} \usepackage[14pt]{extsizes} \usepackage{lipsum} \usepackage[bottom=20mm]{geometry} \pagestyle{headandfoot} \newcommand{\myfooter}{\iflastpage{% {\centering\large End of the Exam}% \vspace{5pt}}{} \hrule\vspace{5pt} Instructors} \firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} \iflastpage{\newgeometry{bottom=40mm}}{} \begin{document} \lipsum[1-5] \end{document} 
4
  • You will run into problems if the page is nearly full: if you shorten it the text will wander to the next page and the number of the last page will oscillate. Commented Nov 5, 2019 at 8:45
  • @UlrikeFischer Do you mean that it is not stable to use \iflastpage to change the geometry of the last page? If yes, is there any other way to do so? Commented Nov 5, 2019 at 9:05
  • I would simply put the text "End of the Exam" at the end of the document. Commented Nov 5, 2019 at 9:07
  • @UlrikeFischer Unfortunately, this document resulted in this ugly output where End of the Exam is not placed just above the footer horizontal rule. Commented Nov 5, 2019 at 9:17

2 Answers 2

1
+50

You can add “End of Exam” so it takes no vertical space. You might also add \vspace*{20pt} at the very end of the text in order to ensure no overlap.

In any case, the text should be checked and possibly modified to fit in the required number of pages, so manual work is needed anyway.

\documentclass{exam} \usepackage[14pt]{extsizes} \usepackage{lipsum} \usepackage[bottom=20mm]{geometry} \pagestyle{headandfoot} \newcommand{\myfooter}{ \iflastpage{\raisebox{5pt}[0pt][0pt]{\large End of the Exam}}{}% \hrule\vspace{5pt}% Instructors% } \firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} \begin{document} \lipsum[1-5] \end{document} 

enter image description here

1

If you set the bottom margin to 25mm everything is OK. Now no need to use newgeometry command.

\documentclass{exam} \usepackage[14pt]{extsizes} \usepackage{lipsum} \usepackage[bottom=25mm]{geometry} % <-- changed to 25 mm. \pagestyle{headandfoot} \newcommand{\myfooter}{\iflastpage{% {\centering\large End of the Exam}% \vspace{5pt}}{} \hrule\vspace{5pt} Instructors} \firstpagefooter{}{\myfooter}{} \runningfooter{}{\myfooter}{} %\iflastpage{\newgeometry{bottom=40mm}}{} \begin{document} \lipsum[1-15] \end{document} 

enter image description here

2
  • If you use 1-20 for lipsum, 'Instructors' is cut off on the final page. Commented Nov 5, 2019 at 4:17
  • Thanks, but I need the word Instructors to be spaced from the page bottom edge equally in both last and second-to-last pages. Commented Dec 7, 2019 at 23:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.