summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/titlesec/titleps.sty
blob: b52e3d83d04d246ef7457e076c2ede157838daca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
% +--------------------------------------------------+
% | Typeset titlesec.tex to get the documentation.   |
% +--------------------------------------------------+
%
% Copyright (c) 1998-2011 by Javier Bezos.
% All Rights Reserved.
%
% This file is part of the titlesec distribution release 2.10.0
% -----------------------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
% 
% This work has the LPPL maintenance status "maintained".
% 
% The Current Maintainer of this work is Javier Bezos.
%
% Release
% ~~~~~~~

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{titleps}[2011/12/15 v1.1.0 Page styles]

% This package is mainly a wrapper for the pagestyle macros provided
% by titlesec, so that they can be used without it.  Functionality is
% almost similar. First, some definitions from titlesec.

\newif\ifttl@ps
\newif\ifttl@toclabel
\ttl@toclabeltrue

\def\ttl@calcneg#1#2{%
  {\setlength\@tempskipa{#2}%
   #1{-\@tempskipa}}}

\newif\ifttl@premark % to be used in ttlps.def
\ttl@premarkfalse

\def\ttl@premark#1#2{%
  \protected@xdef\ttl@prevmarks{\ttl@marks}%
  \csname#1mark\endcsname{#2}%
  \gdef\ttl@prevmarks{\ttl@marks}}

\let\ttl@savemark\@empty

% Patching sectioning commands

\newcommand\TitlepsPatchSection{%
  \@ifstar{\ttl@setsec\@gobbletwo}%
          {\ttl@setsec\pretitlemark}}

\def\ttl@setsec#1#2{%
  \@ifundefined{#2}{}{%
    \expandafter\let\csname ttl@s@#2\expandafter\endcsname
      \csname#2\endcsname
    \@namedef{#2}{%
      \@ifstar{\ttl@presec@s{#2}}%
              {\@dblarg{\ttl@presec@x#1{#2}}}}}}%

% premark/gobble, sect-name, opt, title
\def\ttl@presec@x#1#2[#3]#4{%
  #1{#2}{#3}%
  \@nameuse{ttl@s@#2}[#3]{#4}}

\def\ttl@presec@s#1#2{%
  \gdef\ttl@savemark{\@nameuse{#1mark}{#2}}%
  \@nameuse{ttl@s@#1}*{#2}}

\def\ttl@atbegin{%
  \TitlepsPatchSection*{chapter}%
  \TitlepsPatchSection{section}%
  \TitlepsPatchSection{subsection}%
  \TitlepsPatchSection{subsubsection}%
  \TitlepsPatchSection{paragraph}%
  \TitlepsPatchSection{subparagraph}}

\AtBeginDocument{\ttl@atbegin}

% Package options
  
\DeclareOption{psfloats}{\let\ttl@replace\@empty} % a flag

\DeclareOption{outermarks}{%
  \def\ttl@titlemarks{\outertitlemarks}}
\DeclareOption{topmarks}{
  \def\ttl@titlemarks{\toptitlemarks}}
\DeclareOption{botmarks}{%
  \def\ttl@titlemarks{\bottitlemarks}}
\DeclareOption{innermarks}{%
  \def\ttl@titlemarks{\innertitlemarks}}
\DeclareOption{extramarks}{\let\ttl@fetchmark\@empty}
\DeclareOption{nopatches}{\let\ttl@atbegin\relax}

\ExecuteOptions{innermarks}

\ProcessOptions

% Load the package body

\let\newpagestyle\@empty
\let\renewpagestyle\@empty
\let\widenhead\@empty

\input ttlps.def

% Raise error if the following are used

\DeclareRobustCommand\ttl@naerror[1]{%
  \PackageError{titleps}%
    {#1\space only available in titlesec.\MessageBreak
     Consider using it instead of titleps}%
    {titleps provides a subset of the macros\MessageBreak
     for pagestyles defined in titlesec.}}

\def\ttl@setifthe#1{%
  \expandafter\protected@edef\csname ifthe#1\endcsname{%
    \ttl@naerror{\string\ifthe#1}}}

\ttl@setifthe{part}
\ttl@setifthe{chapter}
\ttl@setifthe{section}
\ttl@setifthe{subsection}
\ttl@setifthe{subsubsection}
\ttl@setifthe{paragraph}
\ttl@setifthe{subparagraph}

\endinput