Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
2  
This won't work. Due to the asynchronic paragraph/page builder TeX can't change the page geometry in the middle of a paragraph. Use the commands only after explicit or implicit \newpage. –  Ulrike Fischer Feb 6 '13 at 18:11
    
Is there any way I can automate this in a document class? I'd like to not have to worry about explicitly setting the geometry in my actual document. –  agent154 Feb 6 '13 at 18:24
1  
I am not sure what you are after. Making document text differently positioned on a particular page (concerning margins, textwidth etc.) is a very bad idea, and I'm somehow glad that it's not easily possible. And if you want to modify the chapter title design, you can use the well-documented titlesec package –  tohecz Feb 6 '13 at 18:32
    
I already have the title designed with titlesec - I'm looking to change the margins of that page if possible. –  agent154 Feb 6 '13 at 18:34
    
It seems I answered a similar question before. –  A.Ellett Feb 6 '13 at 19:15

1 Answer 1

\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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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