Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing margins on first page of letter

152 views
Skip to first unread message

Shami C

unread,
Sep 4, 2009, 4:57:02 PM9/4/09
to
Hi all,
I'm stuck on what seems to be a rather simple problem. What I'm trying
to do: Set a letter margin to be 1 inch, except on the first page,
where I need the left margin to be 2 inches. That's all. The right
margin always needs to stay the same.

I'm defining \renewcommand{\ps@firstpage}{ } and changing
oddsidemargin and textwidth inside it, as shown in the minimal style
file and example letter.tex below. I find that the margin and
textwidth change just fine for the document body; on the first page
the oddsidemargin changes as expected but the textwidth does not
change. Why not???

Things I've already tried:
* The geometry package makes no difference.
* The changepage / chngpage packages fail exactly as my style file
does.
* \setlength vs \addtolength makes no difference.
* The sign of the length change (+ive or -ive) does not matter.

I'd appreciate
(a) any insight as to what I'm doing wrong; or
(b) a simple way to just change the left margin and textwidth on the
first page only.
(Again, I've already tried changepage and geometry.)

Thanks very much for any help! (style file and example follows below.)
Shami

Here's my minimal style file illustrating the problem:
-----------------------------------
%%% dummy.sty: test margin.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dummy}
%% This can be commented out
\RequirePackage[margin=1.5in,nohead,showframe]{geometry}
%% Does addtolength work?
\addtolength{\oddsidemargin}{-0.5in} %% Yes,
\addtolength{\textwidth}{0.5in} %% it does.
\typeout{* Oddsidemargin = \the\oddsidemargin ; Textwidth = \the
\textwidth}

%%% First page style definition:
\renewcommand{\ps@firstpage}{%
% Reduce textwidth and increase left margin
\addtolength{\oddsidemargin}{1in} % This works
\addtolength{\textwidth}{-1in} % This fails !!
\typeout{*** First page Oddsidemargin = \the\oddsidemargin ;
Textwidth = \the\textwidth}
}

\renewcommand{\opening}[1]{
\thispagestyle{firstpage}
#1\par}
%%%% End of style file. %%%%
-----------------------------------
My example letter:

\documentclass{letter}
\usepackage{dummy}
\begin{document}
\begin{letter}{Addressee's Name\\
City, State}

\opening{Dear Recipient,} %% This triggers first page style

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
nulla ...
(etc. for two pages; please add dummy text here for testing.)

\closing{Sincerely,}
\end{letter}
\end{document}

Again, any help is greatly appreciated!
S.

zugzwang

unread,
Sep 5, 2009, 11:09:14 PM9/5/09
to

As a Latex intermediate, I adjust my margins with the following
preamble hack:

% margins
\addtolength{\hoffset}{-2.0cm}
\addtolength{\textwidth}{4cm}
\addtolength{\voffset}{-0.5cm}
\addtolength{\textheight}{2cm}
\advance\footskip by -3.5cm

Faced with your situation, my first try would be:

...
\begin{document}
{% local margin hacks and text for first page in this group
... % margin hacks
... % text for first page
\newpage
}% above newpage triggered manually, to ensure that first
% page of text is wrapped in a group

The hope is that the margin hacks contained within the above group
will only apply locally; you'll have to experiment. If try fails,
one alteration might be using a \begin{group}...\end{group} wrapping,
rather than simply a {...} wrapping.

If above fails, the crude industrial strength solution is:

\begin{document}
% local margin hacks and text for first page in this group
... % margin hacks
... % text for first page
\newpage
% above newpage triggered manually, to ensure that first
% page of text is wrapped in a group
... % margin adjustment hacks

Unknown whether (2nd) margin (adjustment) hacks go just before or just
after the newpage command. As intermediate, this is simply my
conceptual idea; my Tex-Latex knowledge insufficient to tell whether
concept flawed or obsolete (in favor of much easier method).

Shami C

unread,
Sep 6, 2009, 1:58:03 PM9/6/09
to
On Sep 5, 11:09 pm, zugzwang <buyoninte...@bluebottle.com> wrote:

> \begin{document}
> {% local margin hacks and text for first page in this group
> ... % margin hacks
> ... % text for first page
> \newpage}% above newpage triggered manually, to ensure that first
> % page of text is wrapped in a group

> [...]


> this is simply my conceptual idea; my Tex-Latex knowledge insufficient to tell whether
> concept flawed or obsolete (in favor of much easier method).

Thanks for your thoughts; but as you say, your solution requires a
manual \newpage. At that point, I might as well have a document for
the first page and another document for the rest of the pages...

I was trying to define a style file that would take care of the page
handling on its own, and my attempt with ps@firstpage works just fine
for changing the oddsidemargin on the first page. I'm just baffled
that the textwidth does not change even though the margin does.
-S.

Lars Madsen

unread,
Sep 7, 2009, 4:28:50 AM9/7/09
to
Shami C wrote:
> On Sep 5, 11:09 pm, zugzwang <buyoninte...@bluebottle.com> wrote:
>
>> \begin{document}
>> {% local margin hacks and text for first page in this group
>> ... % margin hacks
>> ... % text for first page
>> \newpage}% above newpage triggered manually, to ensure that first
>> % page of text is wrapped in a group
>> [...]
>> this is simply my conceptual idea; my Tex-Latex knowledge insufficient to tell whether
>> concept flawed or obsolete (in favor of much easier method).
>
> Thanks for your thoughts; but as you say, your solution requires a
> manual \newpage. At that point, I might as well have a document for
> the first page and another document for the rest of the pages...
>

try inserting it using \afterpage at the start of the first page (untested)

> I was trying to define a style file that would take care of the page
> handling on its own, and my attempt with ps@firstpage works just fine
> for changing the oddsidemargin on the first page. I'm just baffled
> that the textwidth does not change even though the margin does.
> -S.


--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

Robin Fairbairns

unread,
Sep 7, 2009, 7:36:03 AM9/7/09
to
Shami C <sbc...@hotmail.com> writes:

>On Sep 5, 11:09=A0pm, zugzwang <buyoninte...@bluebottle.com> wrote:
>
>> \begin{document}
>> {% local margin hacks and text for first page in this group
>> ... % margin hacks
>> ... % text for first page
>> \newpage}% above newpage triggered manually, to ensure that first
>> % page of text is wrapped in a group
>> [...]
>> this is simply my conceptual idea; my Tex-Latex knowledge insufficient to=

> tell whether
>> concept flawed or obsolete (in favor of much easier method).
>
>Thanks for your thoughts; but as you say, your solution requires a
>manual \newpage. At that point, I might as well have a document for
>the first page and another document for the rest of the pages...

indeed.

>I was trying to define a style file that would take care of the page
>handling on its own, and my attempt with ps@firstpage works just fine
>for changing the oddsidemargin on the first page. I'm just baffled
>that the textwidth does not change even though the margin does.

unfortunately, tex collects paragraphs as it goes along. when it gets
to the end of the paragraph, it lays it out according to the present
margins, and adds it to the list of things to send to output.

if the paragraph has over-filled the page, the paragraph is split and
the bit after the page is full is carried on to the next page ... but
it's already been typeset according to the margins of the page it
started on.

which is why you find this immensely tedious need for manual
adjustment. i don't know any technique for avoiding it, in general :-(
--
Robin Fairbairns, Cambridge

GL

unread,
Sep 7, 2009, 9:12:00 AM9/7/09
to
Robin Fairbairns a �crit :

Not an output routine guru, yet ?

Robin Fairbairns

unread,
Sep 7, 2009, 10:09:13 AM9/7/09
to

hardly (i just about know my way around, no more). i have _tried_
unglopping the leavings after a page has been set, but have no uniform
procedure for dealing with every eventuality -- every attempt has
resulted in unfortunate oddities. how _does_ one undo hyphenation
splits, prior to reflowing lines, for example?

perhaps there are those who _can_ do it, but not me.
--
Robin Fairbairns, Cambridge

Shami C

unread,
Sep 7, 2009, 12:23:15 PM9/7/09
to
On Sep 7, 7:36 am, r...@cl.cam.ac.uk (Robin Fairbairns) wrote:

> >I was trying to define a style file that would take care of the page
> >handling on its own, and my attempt with ps@firstpage works just fine
> >for changing the oddsidemargin on the first page. I'm just baffled
> >that the textwidth does not change even though the margin does.
>

> unfortunately, tex collects paragraphs as it goes along. [...]


> if the paragraph has over-filled the page, the paragraph is split and
> the bit after the page is full is carried on to the next page ... but
> it's already been typeset according to the margins of the page it
> started on.

If I'm following what you're saying: TeX has a textwidth in mind, and
it continues to use that width for the para even after it spills on to
the next page. And then, to keep things consistent, it retains that
textwidth for the new page...? So it is practically impossible to
change textwidth at all in mid para? That's... unfortunate.

(But wait: Doesn't TeX handle widows and orphans by recasting the
inter-line spacing, and possibly the inter-word spacing, of preceding
paragraphs? Why can't it do that when the textwidth changes?)

Thanks again for thinking about this problem - I really thought there
would be a simple answer. Sigh.
S.

Robin Fairbairns

unread,
Sep 7, 2009, 2:43:25 PM9/7/09
to
Shami C <sbc...@hotmail.com> writes:

>On Sep 7, 7:36=A0am, r...@cl.cam.ac.uk (Robin Fairbairns) wrote:
>
>> >I was trying to define a style file that would take care of the page
>> >handling on its own, and my attempt with ps@firstpage works just fine
>> >for changing the oddsidemargin on the first page. I'm just baffled
>> >that the textwidth does not change even though the margin does.
>>
>> unfortunately, tex collects paragraphs as it goes along. [...]
>> if the paragraph has over-filled the page, the paragraph is split and
>> the bit after the page is full is carried on to the next page ... but
>> it's already been typeset according to the margins of the page it
>> started on.
>
>If I'm following what you're saying: TeX has a textwidth in mind, and
>it continues to use that width for the para even after it spills on to
>the next page.

no. it sets the whole paragraph into a box, then splits enough off to
make a complete page. it's then got the rest of the paragraph in its
hand, already typeset.

>And then, to keep things consistent, it retains that
>textwidth for the new page...?

no: you can change the textwidth between paragraphs. it'll make an
odd spectacle if you're not at the top of a page, but you can set
whatever widths you like on a page.

>So it is practically impossible to
>change textwidth at all in mid para?

right.

>That's... unfortunate.
>
>(But wait: Doesn't TeX handle widows and orphans by recasting the
>inter-line spacing, and possibly the inter-word spacing, of preceding
>paragraphs? Why can't it do that when the textwidth changes?)

it recasts inter-line spacing (if there's any stretch available there)
-- think -- but it does nothing with the horizontal spacing.

>Thanks again for thinking about this problem - I really thought there
>would be a simple answer. Sigh.

there are things that are surprisingly difficult in tex. david
kastrup's a good person for doing the impossible, but even he
recognises boundaries of the possible ;-)

your problem is the sort of thing i can imagine doing with luatex -- i
mentioned reconstructing hyphenated words in an earlier post. i can
imagine a route whereby luatex might be able to do that.

(luatex is usable now, but it's not "ready for the big time", aiui.)
--
Robin Fairbairns, Cambridge

David Kastrup

unread,
Sep 7, 2009, 3:06:48 PM9/7/09
to
rf...@cl.cam.ac.uk (Robin Fairbairns) writes:

> Shami C <sbc...@hotmail.com> writes:
>>On Sep 7, 7:36=A0am, r...@cl.cam.ac.uk (Robin Fairbairns) wrote:
>>
>>> >I was trying to define a style file that would take care of the
>>> >page handling on its own, and my attempt with ps@firstpage works
>>> >just fine for changing the oddsidemargin on the first page. I'm
>>> >just baffled that the textwidth does not change even though the
>>> >margin does.
>>>
>>> unfortunately, tex collects paragraphs as it goes along. [...] if
>>> the paragraph has over-filled the page, the paragraph is split and
>>> the bit after the page is full is carried on to the next page
>>> ... but it's already been typeset according to the margins of the
>>> page it started on.
>>
>>If I'm following what you're saying: TeX has a textwidth in mind, and
>>it continues to use that width for the para even after it spills on to
>>the next page.

>>So it is practically impossible to


>>change textwidth at all in mid para?
>
> right.

It is doable using \parshape. The problem is rather having a clue about
how many lines you want in a certain shape. If you use \pdfpagepos (or
what its called) and its companions at the beginning of each paragraph,
likely with some automatic paragraph number assigned via a marks
register, you can get a good guess in the output routine. If you saved
the paragraph in a token register before typesetting, you can then give
it another spin.

Certainly not trivial.

>>That's... unfortunate.
>>
>>(But wait: Doesn't TeX handle widows and orphans by recasting the
>>inter-line spacing, and possibly the inter-word spacing, of preceding
>>paragraphs? Why can't it do that when the textwidth changes?)
>
> it recasts inter-line spacing (if there's any stretch available there)
> -- think -- but it does nothing with the horizontal spacing.

Which is a pain.

>>Thanks again for thinking about this problem - I really thought there
>>would be a simple answer. Sigh.
>
> there are things that are surprisingly difficult in tex. david
> kastrup's a good person for doing the impossible, but even he
> recognises boundaries of the possible ;-)

In this area, Jonathan Fine has done some work. However, there is a
difference between doing a problem under laboratory conditions, and
wedging impossible code into the gears of LaTeX without all too many
things falling apart in the process.

> your problem is the sort of thing i can imagine doing with luatex -- i
> mentioned reconstructing hyphenated words in an earlier post. i can
> imagine a route whereby luatex might be able to do that.
>
> (luatex is usable now, but it's not "ready for the big time", aiui.)

Well, more or less, but it is still "trial and restart". The basic
separation of line break optimization and page breaking is still
omnipresent and complicates things. You may be able to hide some of
that complication behind good Lua programming, but you can't hide the
performance hit you get when you replace a Viterbi algorithm (which is
what the basic paragraph breaker is) with trial and error, basically of
combinatorial complexity.

--
David Kastrup
UKTUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>

Shami C

unread,
Sep 8, 2009, 2:54:32 PM9/8/09
to
On Sep 7, 3:06 pm, David Kastrup <d...@gnu.org> wrote:

> >>So it is practically impossible to change textwidth at all in mid para?
> > right.
>
> It is doable using \parshape.  The problem is rather having a clue about
> how many lines you want in a certain shape.  If you use \pdfpagepos (or
> what its called) and its companions at the beginning of each paragraph,
> likely with some automatic paragraph number assigned via a marks
> register, you can get a good guess in the output routine.  If you saved
> the paragraph in a token register before typesetting, you can then give
> it another spin.
>
> Certainly not trivial.

Huh. I stick my toe in and it comes back very, very muddy.

I think I'll implement an \endfirstpage macro in my style file, and
leave it to the letterhead user to decide how to deal with para
splitting across the page.

Thanks once again for all your thoughts - at least it's been a
learning experience.
-S.

Donald Arseneau

unread,
Sep 8, 2009, 10:46:17 PM9/8/09
to
On Sep 4, 1:57 pm, Shami C <sbc...@hotmail.com> wrote:
> I'm stuck on what seems to be a rather simple problem. What I'm trying
> to do: Set a letter margin to be 1 inch, except on the first page,
> where I need the left margin to be 2 inches. That's all. The right
> margin always needs to stay the same.

First off, you can't automatically have the width change in the
middle of a paragraph. So forget about that.

> I'm defining \renewcommand{\ps@firstpage}{ } and changing
> oddsidemargin and textwidth inside it,

Why would you make margin changes in a page-header format?
I see the name "page style" may have misled you, but \pagestyle
does not mean \pagesize -- the text-block dimensions are distinct
from the "style".

> file and example letter.tex below. I find that the margin and
> textwidth change just fine for the document body; on the first page
> the oddsidemargin changes as expected but the textwidth does not
> change. Why not???

You need to apply the changes, and the best way is to (re)declare
\onecolumn.

\clearpage
\addtolength{\oddsidemargin}{1in}
\addtolength{\textwidth}{-1in}
\onecolumn

The other alternative is to use a list environment with a list
\leftmargin of 1 inch.

Donald Arseneau

Shami C

unread,
Sep 9, 2009, 12:03:06 PM9/9/09
to
On Sep 8, 10:46 pm, Donald Arseneau <a...@triumf.ca> wrote:

> First off, you can't automatically have the width change in the
> middle of a paragraph.  So forget about that.

Yes, I came to that sad realization.

> > I'm defining \renewcommand{\ps@firstpage}{ } and changing
> > oddsidemargin and textwidth inside it,
>
> Why would you make margin changes in a page-header format?

This goes back a long way - I'm re-implementing our official
letterhead in LaTeX (of course they only provide official Word
templates) and I'm triggering the letterhead and first page layout by
redefining the \opening command.

> You need to apply the changes, and the best way is to (re)declare
> \onecolumn.

Thanks - I asked about this again with a simpler example on a related
thread, and Will and Ulrike led me to the same answer. \hsize seems to
be the magic parameter I needed.

The help is much appreciated,
Shami

0 new messages