[texhax] Conditional formatting of section headings

Luca Turchetti luca.turchetti at uniroma1.it
Wed Nov 19 20:59:02 CET 2003

I'm trying to get  different  section heading alignments in even and odd
pages: on odd(right) pages I want section headings to be right
aligned(raggedleft) while on even(left) pages I want them to be left

I thought I found a good solution redefining the style part of the
\section command this way:

                                   \@startsection {section}{1}{0cm}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\sffamily\LARGE  \ifodd\value{page}
\raggedleft \else \raggedright \fi}}

This works fine, except for sections starting at the bottom of a page:
as you know, to avoid a page break between the title of these sections
and the following text, TeX pushes the title of the section to the
following page, but the heading alignment is determined by the page
where the section actually begins.

For instance, if a section beginning at the end of page 4 is pushed to
page 5, its heading will be left aligned because when the \section
command was issued, the vaule of the page counter was 4.

Does anybody know how to work this around?

Thank you

-------------- next part --------------
An embedded message was scrubbed...
From: Luca Turchetti <luca.turchetti at uniroma1.it>
Subject: Conditional formatting of section headings
Date: Wed, 19 Nov 2003 18:41:58 +0100
Size: 1662
Url: http://tug.org/pipermail/texhax/attachments/20031119/4e2a1061/attachment.eml

More information about the texhax mailing list