[texhax] Conditional formatting of section headings

Luca Turchetti luca.turchetti at uniroma1.it
Wed Nov 19 18:41:58 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
aligned(raggedright).

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

\renewcommand\section{%
                                   \@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
Luca



More information about the texhax mailing list