% This file is copyrighted (c) 1998 1999 by Javier Bezos.
% All Rights Reserved.
%
% This file is part of the titlesec distribution release 2.1.
% -----------------------------------------------------------
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.

\ProvidesFile{page.tsk}[1998/08/30]

\makeatletter

\define@key{ttlformat}{page}{\edef\ttl@a{/#1\ttl@a}}
\let\KV@ttlspacing@page\KV@ttlformat@page

%___
\if@twoside

\newcounter{ttlp@side}
\newcount\ttlp@side

\def\ttlp@theside{\ifodd\c@page o\else e\fi}

\def\ttlp@append#1#2{%
 {\let\@elt\relax
  \expandafter\xdef\csname ttlp@#1\endcsname{%
     \csname ttlp@#1\endcsname\@elt #2}}}

\def\ttlp@write#1{%
  {\let\ttlp@theside\relax
   \protected@write\@auxout{}%
     {\string\ttlp@append{#1}{\ttlp@theside}}}}

\def\ttlp@fetch#1{%
   \stepcounter{ttlp@side}%
   \global\advance\ttlp@side\@ne
   \@whilenum\ttlp@side<\c@ttlp@side\do{%
      \expandafter\@next\expandafter\@tempa\csname ttlp@#1\endcsname{}{}%
      \global\advance\ttlp@side\@ne}%
   \expandafter\@next\expandafter\ttl@b\csname ttlp@#1\endcsname{%
      \xdef\ttl@a{/\if\ttl@b oodd\else even\fi}%
   }{%
      \xdef\ttl@a{/\ifodd\c@page odd\else even\fi}%
	  \@@warning{Unsynchronized `#1' title on page \thepage}}}

%___
\else

\let\ttlp@write\@gobble
\def\ttlp@fetch#1{\gdef\ttl@a{/odd}}

%___
\fi

\makeatother