summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/plain/pitex/sections.ptx
blob: aae16e4192ef40f568eed2624aca633648285701 (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
\newcount\ptx@section_skip % A count, since vertical skips are expressed in number of lines.
\newcount\ptx@section_link
\def\sectioncommand#1#2#3{%
  \par\penalty0
  \ifvalue #1 : clear = true 
           {\vfil\penalty-10000}% Clear the page...
           {% Or skip some lines. The "beforeskip" attribute is the number of blank lines one wants before a section
            % title and "minimum" is the minimum number of lines it must be possible to have after the section title.
            \ifdim\dimexpr(\pagegoal-\pagetotal) < \numexpr(\usevalueor #1 : beforeskip 0+\usevalueor #1 : minimum 0) \baselineskip
              \vfil\penalty-10000 % Not enough room.
            \else
              \vskip\usevalueor #1 : beforeskip 0 \baselineskip
            \fi}%
%
% Sections have an internal count, incremented here.
  \storevalueor\ptx@tempsectioncount #1 : internalcount {\def\ptx@tempsectioncount{0}}%
  \setparameter #1 : e:internalcount = {\the\numexpr(\ptx@tempsectioncount+1)}\par
  \resetbelow{#1}% Resets all internal counts of sections which depend on the current one (i.e. "section" depends on "chapter", etc.).
%
%
  \ifvalue #1 : link = true {%
    \global\advance\ptx@section_link 1
    \pdfdest num \ptx@section_link xyz
    \pdfoutline attr {/Border [0 0 2]} goto num \ptx@section_link {\detokenize{#2}}}{}%
  \noindent
  \hskip\usevalueor #1 : indent {0pt}%
  \bgroup
    \ifattribute #1 : color {\pdfcolorstack0 push {\usevalueand #1 : color { rg}{} \usevalueand #1 : color { RG}{}}}{}%
    \usevalue #1 : font
    \ifvalue #1 : number = none {}{%
      \usevalue #1 : beforenumber
      \ifcasevalue #1 : number
        \val roman  \makeroman
        \val arabic \unbrace
      \endval{\usevalue #1 : internalcount }%
      \usevalue #1 : afternumber
      }%
    #3%
    \ifattribute #1 : color {\pdfcolorstack0 pop}{}
  \egroup
  \ifvalue #1 : inline = true
           {}
           {\vskip\usevalueor #1:afterskip 0\baselineskip}%
  }
\newwhile\resetbelow1{}{%
  \ifattribute #1 : below
               {\storevalue\tempbelow #1 : below
                \setparameter\tempbelow : e:internalcount = 0\par
                \passvalue{\changewhile} #1 : below
                }{\breakwhile{}}%
  }
\def\makeroman#1{%
  \uppercase\expandafter{\romannumeral#1\relax}%
  }

\setparameter metasection :
  clear        = false
  minimum      = 3
  inline       = false
  number       = arabic
  link         = true
	afternumber  = "\kern.3em"

\setparameter chapter section subsection :
  meta = metasection

\setparameter chapter :
  clear        = true
  number       = arabic
  below        = section
  afterskip    = 3
  indent       = "0pt plus 1fill"
  beforenumber = "chapitre "
  afternumber  = {\par\hfill}
  
\setparameter section :
  beforeskip = 2
  below      = subsection

\setparameter subsection :
  font         = \it
  beforeskip   = 1
  beforenumber = "\usevalue section:internalcount ."
  minimum      = 3

\def\chaptertitle{}%
\def\chapter#1{%
  \def\chaptertitle{#1}%
  \sectioncommand{chapter}{#1}{#1}%	
  }
\def\section#1{\sectioncommand{section}{#1}{#1}}
\def\subsection#1{\sectioncommand{subsection}{#1}{#1}}