1

Changing page size mid-document should be a basic, easy to use feature but it isn't.

I am developing upon the answer given at Change paper size in mid-document

\documentclass{article}
\usepackage[landscape]{geometry}
\usepackage{lipsum}
\usepackage{graphicx}
\begin{document}
Normal page
\eject \pdfpagewidth=3in \pdfpageheight=5in
Tall page
\begin{figure}
  \centering
  \includegraphics{example-image-a}
\end{figure}
\eject \pdfpagewidth=18in \pdfpageheight=3in
Wide page
\lipsum[1-2]
\begin{figure}
  \centering
  \includegraphics{example-image-b}
\end{figure}

\begin{table} \centering \begin{tabular}{lc} A & B\ c & D \end{tabular} \end{table} \end{document}

The output is: enter image description here

There are a lot of problems:

  1. modifying \pdfpagewidth does not modify \paperwidth which is commonly used to modify image size

  2. The page number is shown only on the first page. How to show it on other pages and place it in the centre of the bottom of the page.

  3. Why is "Tall page" shown at the bottom of the page?

  4. Where is example-image-a?

  5. Where is the table?

  6. Where is the text placed by \lipsum?

  7. example-image-b has been centred, but in the output it is in the left side of the page.

Viesturs
  • 7,895
  • Each time the paper size changes, all the page geometry dimensions need an update. You don't see page numbers and imageexample-image-a because they are typeset outside the page. Are there specific reasons you cannot use typearea package? – muzimuzhi Z Nov 12 '21 at 06:33
  • @muzimuzhiZ, I am not familiar with the typearea package. Does it provide an acceptable solution? – Viesturs Nov 12 '21 at 06:36
  • TeX can generally be considered some form of programming of a document, which inherently suggests that it imposes consistency of the structure. Changing page dimensions mid-document goes counter to that, even though WYSIWYG editors like Word make it possible. You'll have to manually inform TeX how to change the text width across the page break as well, since it naturally assumes the structure will remain consistent. What is the main intent behind the change? – Werner Nov 12 '21 at 06:37
  • Yes, there's a typearea example under the question you mentioned. – muzimuzhi Z Nov 12 '21 at 06:38
  • If you do need to change the page size (which is very rare and contrary to your first line one of the trikiest thing sto do in a typesetting system with an asynchronous page breaker) why not use the provided \newgeometry command since you are loading the geometry package that defines it. If you use tex primitive settings mid document without re-calculating all the latex structures built on them then things will break. – David Carlisle Nov 12 '21 at 07:44
  • @DavidCarlisle, I tried the \newgeometry command but I encountered a problem which I have described in another question https://tex.stackexchange.com/questions/622303/change-page-size-mid-document-with-newgeometry – Viesturs Nov 12 '21 at 07:49
  • @DavidCarlisle one need to trick newgeometry to accept a page size change, see e.g. the question and answer here https://tex.stackexchange.com/q/575295/2388 – Ulrike Fischer Nov 12 '21 at 08:01
  • @UlrikeFischer yes I was just looking at the package now, I wonder if we should change that... – David Carlisle Nov 12 '21 at 08:02
  • @DavidCarlisle I think changing also the page size should be possible too, that is a quite natural wish if documents are used only on screen, but as the landscape boolean shows one should be a bit careful and check if there are other side effect. – Ulrike Fischer Nov 12 '21 at 08:09
  • @UlrikeFischer yes a start at https://tex.stackexchange.com/a/622310/1090 – David Carlisle Nov 12 '21 at 08:18
  • @Viesturs do you want to close this in favour of the newgeometry question? Since you are using that package I think you should use a compatible version even if \newgeopmetry doesn't handle this as well as I'd expected – David Carlisle Nov 12 '21 at 08:39
  • @DavidCarlisle, I tried your \newgeometry solution in the real document. The first impression is rather agreeable. Maybe somebody will answer this question explaining the limitations of \eject and will point to better solutions. – Viesturs Nov 12 '21 at 08:58
  • @Werner, the main intention is to show large tables which do not fit into a page even when using \tiny font size. – Viesturs Nov 12 '21 at 09:06

0 Answers0