2

I produce exams in A3 format and, when the exam is too long, I want to produce a supplementary page, in A4 format. I use the \newgeometry command of the geometry package, and it's known that this package refuses to pass from A3 to A4 in the same document. So how I can do my purpose ?

I give a simple MWE where I use a boarded minipage to watch up the behaviour when I use \newgeometry.

\documentclass[12pt]{exam}

\usepackage[figuresleft]{rotating}
\usepackage{multicol}
\setlength{\columnsep}{40pt}
\setlength{\columnseprule}{3pt}

\usepackage[a3paper,landscape,margin=2cm,twocolumn]{geometry}
\begin{document}
\pagestyle{empty}
\begin{minipage}{1pt}
\rule{1pt}{4cm}
\end{minipage}
%
\begin{minipage}{15cm}
A first question
\end{minipage}
%
\begin{minipage}{1pt}
\rule{1pt}{4cm}
\end{minipage}

\newpage
\begin{minipage}{1pt}
\rule{1pt}{4cm}
\end{minipage}
%
\begin{minipage}{15cm}
A second question
\end{minipage}
%
\begin{minipage}{1pt}
\rule{1pt}{4cm}
\end{minipage}
\newpage
\newgeometry{a4paper,total={180mm,255mm},includefoot,includehead,centering,twoside,top=10pt}
\begin{minipage}{1pt}
\rule{1pt}{4cm}
\end{minipage}
%
\begin{minipage}{15cm}
A third question
\end{minipage}
%
\begin{minipage}{1pt}
\rule{1pt}{4cm}
\end{minipage}
\end{document}

and it's compilation

enter image description here enter image description here

One can see the effect on the second page, where the document is clearly in A4 document, but with A3 geometry.

One solution can be to rotate the last page, and playing on dimensions such width, height, top etc to obtain a good rotated centered page, and print it on A4 printer... (Note that that's what I do for A3 pages.. I print it on my A4 printer, and copy it outside "from A4 to A3"..

2

Some drivers (dvips) do not support changing the paper size in the middle of the document, but others can like pdfTeX or LuaTeX in PDF mode. This is maybe the reason, why package geometry does not allow changing the paper size in \newgeometry.

But the values can be set manually, taken from the options of \newgeometry (do you really want top=10pt, I have replaced it by 21mm for vertical centering)?

The subtraction of 1in is an oddity of TeX, the origin is not the upper left corner, but it is moved horizontally and vertically inside by 1 in.

\newpage
\onecolumn
\setlength{\paperwidth}{210mm}
\setlength{\paperheight}{297mm}
\setlength{\textwidth}{180mm}
\setlength{\textheight}{255mm}
\setlength{\topmargin}{21mm}
\addtolength{\topmargin}{-1in}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}
\setlength{\oddsidemargin}{\paperwidth}
\addtolength{\oddsidemargin}{-\textwidth}
\setlength{\oddsidemargin}{.5\oddsidemargin}
\addtolength{\oddsidemargin}{-1in}
\setlength{\evensidemargin}{\oddsidemargin}
\setlength{\hsize}{\textwidth}
\setlength{\columnwidth}{\textwidth}
\setlength{\linewidth}{\textwidth}
\setlength{\vsize}{\textheight}
\setlength{\csname @colht\endcsname}{\textheight}
% Driver part (XeLaTeX, pdfTeX or LuaTeX with package `luatex85`)
\setlength{\pdfpagewidth}{\paperwidth}
\setlength{\pdfpageheight}{\paperheight}

Some lines can be saved by using e-TeX's \dimexpr. This is left as exercise for the reader.

PS: Consider generating two documents. This is probably easier to print, less confusion for the PDF viewer/printer.

PPS: Option showframe is a nice feature of geometry to show the page layout, useful for debugging/reviewing the layout settings.

  • Excuse me I haven't said that I use xelatex for my compilation, so I can't use pdflatex.. I'm in RTL environment – Faouzi Bellalouna Mar 10 '18 at 14:12
  • @FaouziBellalouna It also works for XeLaTeX (PDF mode), because it also understands \pdfpagewidth and \pdfpageheight from pdfTeX. – Heiko Oberdiek Mar 10 '18 at 14:14
  • The two solutions are good for the question I asked, but are not useful in my "true conditions", in my arabic environment and using my packages.. I obtain a third page always in A3 format, in the second column, in the first column for the solution of @PhelypeOleinik, and in the place of the second column for your solution. I'll try debugging it for understanding what happen's and let you know ! – Faouzi Bellalouna Mar 10 '18 at 15:23
  • I understand what happen's. Let me say first that your answer is genious. It works fine except some dimensions, like margins and so, but what I can arrange empirically, "as an exercise". My first attempt was not good because I added a page into questions environment, and so the format hasn't change. When I add page after closing and re-opening the environment, something like \end{questions} \begin{questions}, it have the good behaviour, but the counter reinitialize to 0, and I will have big problems ti generate \gradetable, \totpoints, and so on... Any idea for that ? – Faouzi Bellalouna Mar 10 '18 at 16:58
  • @FaouziBellalouna Maybe, you can make a reference to the last question and use package refcount to reinitialize the counter again with the right value. – Heiko Oberdiek Mar 10 '18 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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