[Tex/LaTex] How to change the geometry of a page on the chapter header page only, and return to normal on the next page

geometrymargins

Edit: It would appear that I wasn't clear in my reasoning as to why I wanted to do this..

I would like to design a way that I can have a chapter intro page that is full width, so I can fill it up with information that is designed to only be on that page… Perhaps something like an image with a blurb under the image giving some context about the relation between the chapter topic and that image… like what many textbooks do. The actual content would only start on the next page, but those pages would have different margins, presumably for room to put margin notes.

I'm aware that I can use changepage to temporarily change the margin of a paragraph or block on the page, but I was hoping to change the whole page at once, and change back on the next page. There would be no changing of margins mid-paragraph of text.


\documentclass[twoside]{report}

\usepackage{etoolbox}
\usepackage{lipsum}
\usepackage{geometry}

\preto{\chapter}{\newgeometry{left=.75in,right=.75in}}
\appto{\chapter}{\restoregeometry} %% <--- This line doesn't work.

\begin{document}
  \lipsum
  \chapter{Test}
  \lipsum[1-15]
\end{document}

Using etoolbox, I can get \geometry to run before \chapter with the \preto command, but \appto{\chapter}{\restoregeometry} is not working… Is it because it doesn't work how I think it does?

Best Answer

\appto is not the way to go.

You might think you could do something like

\savegeometry{mysavedgeometry}
\usepackage{afterpage}
\newcommand{\mychapter}[1]{%
    \newgeometry{margin=0.5in}%
    \chapter{#1}% 
    \afterpage{\loadgeometry{mysavedgeometry}}}

But this won't work because the parameters are only getting set locally within \afterpage.

But that's not the end of the story. You can go in and manually change the parameters in a global manner. It's a bit of a pain, but you can do it.

\documentclass{report}
\usepackage[margin=1in]{geometry}
\usepackage{lipsum}
\usepackage{afterpage}
\newcommand{\mychapter}[1]{%
    \newgeometry{margin=2in}
    \chapter{#1}
    \afterpage{%
        \global\setlength{\oddsidemargin}{0in}%
        \global\setlength{\evensidemargin}{0in}%
        \global\setlength{\hsize}{\dimexpr\paperwidth-2in\relax}
    }}
\begin{document}

\lipsum[1-10]

\mychapter{test}

\lipsum[1-40]

\end{document}

The result isn't pretty. As noted in the comments above, you cannot change the effective width of a paragraph mid-paragraph. So when a paragraph spills over from the start of a chapter, on the following page it's not formatted correctly. As best I can tell there's no nice work-around for this.

What this means is that you'll have to go into the document and manually enter \pagebreak before any paragraph that will spill over onto the following page where you're new page geometry is to take effect. I'm not sure this solution then really saves you any hassle. But maybe you'll feel that having to add \pagebreak is far easier than manually resetting page dimensions.

But then you might have long paragraphs, half appearing on the first page of the chapter and half appearing on the next page. That's a bit more icky to deal with, and involves more manual mucking around in the document.

\documentclass{report}
\usepackage[margin=1in]{geometry}
\usepackage{lipsum}
\usepackage{afterpage}
\newcommand{\mychapter}[1]{%
    \newgeometry{margin=2in}
    \chapter{#1}
    \afterpage{%
        \global\setlength{\oddsidemargin}{0in}%
        \global\setlength{\evensidemargin}{0in}%
        \global\setlength{\hsize}{\dimexpr\paperwidth-2in\relax}
    }}
\begin{document}

\lipsum[1-10]

\mychapter{test}

\lipsum[1-2]

{Nulla malesuada porttitor diam. Donec felis erat, congue non, volut-
pat at, tincidunt tristique, libero. Vivamus viverra fermentum
felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper
elit. Proin fer- mentum massa ac quam. Sed diam turpis, molestie vitae,
placerat a, mo- lestie nec, leo. Maecenas lacinia. Nam ipsum ligula,
eleifend at, accumsan nec, suscipit a, ipsum. Morbi blandit ligula
feugiat magna. Nunc eleifend consequat lorem. Sed lacinia nulla vitae
enim. Pellentesque tincidunt\parfillskip0pt\par}\pagebreak

\noindent   puvel magna. Integer non enim. Praesent euismod nunc eu purus. Donec
bibendum quam in tellus. Nullam cursus pulvinar lectus. Donec et
mi. Nam vulputate metus eu enim. Vestibulum pellentesque felis eu
massa.

\lipsum[4-40]

\end{document}

That seems like potentially a lot of mucking. And to boot, I had to put in a manual page break as it was.

A couple of other notes:

I'm not so sure that using etoolbox to \preto and \appto are the way to go here. You're not really trying to change what a \chapter does. You're trying to change the lay-out of the page on the first page of the chapter. So, I think building a wrapper around \chapter by defining a wrapper function \mychapter is probably a better way to go.

Second point, LaTeX automatically adds 1in to the effective left-hand margin. If you try to set \oddsidemargin to 1in thinking you'll get a 1in left margin, you'll be rather disappointed.

Finally, you might want to check out my musings about how to answer your question to get an idea of why changing \textwidth or \linewidth will not effect the change to the page geometry you want.