summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/memexsupp/memexsupp.sty
blob: 69b871ac8131c46a5fd4ff4fddce040473e40569 (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
%%
%% This package can 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 Lars Madsen (daleif@imf.au.dk).
%%

%% HISTORY
% 2007/02/24 initial release
% 2008/03/20 updated with new code, and old code removed as to reflect
%            changes in memoir

\ProvidesPackage{memexsupp}[2008/03/20 v0.1 by daleif]

% only for the memoir class
\@ifclassloaded{memoir}{}{
  \PackageError{memsupp}{This package can only be used together with
    the memoir class.}{Either outcomment this package or switch to the
  memoir class}
}

\newcounter{tempcounter}
\newcommand\MXScreatesimplemark[2]{%
  \@namedef{#1mark}{\markboth{\memUChead{#2}}{\memUChead{#2}}}}
\newcommand\MXScreatemark[5]{%
  % #1 type: chapter, section, subsection, subsubsection
  % #2 mark type: both, right
  % #3 whether to show the counter part in mainmatter (true/false),
  % #4 prefix: text before number (including the spacing)
  % #5 number postfix: (. plus spacing)
  \@tempswafalse%
  \nametest{#3}{true}%
  \ifsamename\@tempswatrue\def\@tempa{00}\fi
  \nametest{#3}{false}%
  \ifsamename\@tempswatrue\def\@tempa{01}\fi
  \if@tempswa\else
  \@memerror{bad boolean value (#3)}%
  {I expect the use of 'true' or 'false'}%
  \fi
  \expandafter\if\@tempa
    \@namedef{#1marksn}##1{##1}
  \else
    \@namedef{#1marksn}{\@gobble}
  \fi
  \@namedef{#1mark}##1{%
    \@tempswafalse%
    \nametest{#2}{both}
    \ifsamename
    \@setclcnt{#1}{tempcounter}
    \addtocounter{tempcounter}{-1}
    \markboth{%
      \memUChead{%
        \ifnum \c@secnumdepth > \value{tempcounter}
            \if@mainmatter
              \@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
            \fi
          \fi
          ##1}}{%
        \memUChead{%
          \ifnum \c@secnumdepth > \value{tempcounter}
            \if@mainmatter
              \@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
            \fi
          \fi
          ##1}}%
    \@tempswatrue
    \fi
    \nametest{#2}{right}
    \ifsamename
    \@setclcnt{#1}{tempcounter}
    \addtocounter{tempcounter}{-1}
    \markright{%
      \memUChead{%
        \ifnum \c@secnumdepth > \value{tempcounter}%
            \if@mainmatter%
              \@nameuse{#1marksn}{#4\@nameuse{the#1}#5}%
              %#4\@nameuse{the#1}#5
            \fi%
          \fi%
          ##1}}%
    \@tempswatrue
    \fi
    \if@tempswa\else
    \@memerror{%
      Unknown mark setting type (#2)
    }{%
     I expect the use of 'both' or 'right'}%	
   \fi
  }
}

\newcommand\MXSaddtopsmarks[3]{
  % #1: name of pagestyle
  % #2: code for the beginning
  % code for the end
  \expandafter\addtodef\expandafter{\csname #1pshook\endcsname}{#2}{#3}%
}






\newenvironment{MXStitlingpage}%
  {\let\footnoterule\relax
   \let\footnotesize\small
   \if@twocolumn
     \@restonecoltrue\onecolumn
   \else
     \@restonecolfalse
   \fi
   \thispagestyle{titlingpage}%
   \setcounter{page}{\@ne}%
   \let\MXSoldnewpage\newpage
   \let\MXSoldclearpage\clearpage
   \def\newpage{\MXSoldnewpage\thispagestyle{titlingpage}}%
   \def\clearpage{\MXSoldclearpage\thispagestyle{titlingpage}}%
  }{%
   \thispagestyle{titlingpage}%
   \let\newpage\MXSoldnewpage
   \let\clearpage\MXSoldclearpage
   \if@restonecol \twocolumn \fi
   \if@twoside \cleardoublepage \else \clearpage \fi
   \setcounter{page}{\@ne}}