]> AND Private Git Repository - these_charles_emile.git/blob - upmethodology-p-common.sty
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
RCE : Update du 9/1/2016
[these_charles_emile.git] / upmethodology-p-common.sty
1 % Copyright (c) 2009-13 Stephane GALLAND <galland@arakhne.org>
2
3 % This program is free library; you can redistribute it and/or modify
4 % it under the terms of the GNU Lesser General Public License as
5 % published by the Free Software Foundation; either version 3 of the
6 % License, or any later version.
7 %
8 % This library is distributed in the hope that it will be useful, but
9 % WITHOUT ANY WARRANTY; without even the implied warranty of
10 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 % Lesser General Public License for more details.
12 %
13 % You should have received a copy of the GNU Lesser General Public
14 % License along with this library; see the file COPYING.  If not,
15 % write to the Free Software Foundation, Inc., 59 Temple Place - Suite
16 % 330, Boston, MA 02111-1307, USA.
17 %
18
19 \global\edef\upm@package@private@doctype@ver{2015/04/24}
20
21 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
22 \ProvidesPackage{upmethodology-p-common}[\upm@package@private@doctype@ver]
23
24 \RequirePackage{ifthen}
25 \RequirePackage{xspace}
26 \RequirePackage{xcolor}
27 \RequirePackage{ifpdf}
28
29 %----------------------------------------
30 % UPMVERSION MACRO
31 %----------------------------------------
32 \input UPMVERSION.def
33 \def\upm@common@parseversion@to@tex#1#2#3#4#5#6#7#8#9\@nil{#1#2#3#4/#5#6/#7#8}
34 \def\upm@common@parseversion@major#1#2#3#4#5#6#7#8#9\@nil{#1#2#3#4#5#6#7#8}
35 \edef\ver@UPMVERSION@major{\expandafter\upm@common@parseversion@major\UPMVERSION-\relax\@nil}
36 \edef\ver@UPMVERSION{\expandafter\upm@common@parseversion@to@tex\UPMVERSION\@nil}
37 \expandafter\let\csname ver@UPMVERSION.sty\endcsname\ver@UPMVERSION
38 \expandafter\let\csname ver@UPMVERSION.cls\endcsname\ver@UPMVERSION
39
40 \gdef\UPMVERSIONTEST{\ver@UPMVERSION\\\ver@UPMVERSION@major}
41
42 %----------------------------------------
43 % ARAKHNE.ORG MACRO
44 %----------------------------------------
45 \providecommand{\arakhneorg}{{\begingroup%
46         {\usefont{T1}{pzc}{m}{it}\selectfont Arakhn\^e}%
47         {\usefont{T1}{phv}{bc}{sc}\selectfont\tiny.org}\endgroup}\xspace}
48
49 %----------------------------------------
50 % CURRENT LANGUAGE
51 %----------------------------------------
52 \def\upmcurrentlang{english}
53 \def\ifupmlang#1{\ifthenelse{\equal{#1}{\upmcurrentlang}}}
54
55 %----------------------------------------
56 % TEST MACROS
57 %----------------------------------------
58 \long\def\Ifnotempty#1{\ifthenelse{\equal{#1}{\@empty}}{}}
59 \long\def\Ifempty#1#2{\ifthenelse{\equal{#1}{\@empty}}{#2}{}}
60 \long\def\Ifelseempty#1#2#3{\ifthenelse{\equal{#1}{\@empty}}{#2}{#3}}
61
62 %----------------------------------------
63 % TOC MACROS
64 %----------------------------------------
65 \newcommand{\newpageintoc}{\addtocontents{toc}{\protect\newpage}}
66
67 %----------------------------------------
68 % DOCUMENT TYPE
69 %----------------------------------------
70 \newif\ifupmbookformat
71 \newif\ifupmreportformat
72 \newif\ifupmarticleformat
73
74 \upmbookformatfalse
75 \upmreportformattrue
76 \upmarticleformatfalse
77
78 %----------------------------------------
79 % PDF COLORS
80 %----------------------------------------
81 \newcommand{\setpdfcolor}[1]{}
82
83 %----------------------------------------
84 % CREATE COMMAND WITH ID AS NAME
85 %----------------------------------------
86 \def\upm@protect#1{\upm@p@protect #1\relax}
87 \def\upm@p@protect#1#2\relax{%
88         \ifx\relax #1%
89                 \relax
90         \else%
91                 \string #1%
92                 \ifx\relax #2%
93                         \relax
94                 \else
95                         \upm@p@protect #2\relax%
96                 \fi
97         \fi}
98
99 \def\upm@namedef#1#2{%
100         \@namedef{\upm@protect{#1}}{#2}%
101 }
102
103 \def\upm@nameuse#1{%
104         \@nameuse{\upm@protect{#1}}%
105 }
106
107 \def\upm@nameundef#1{%
108         \expandafter\let\csname\upm@protect{#1}\endcsname\relax%
109 }
110
111 \def\upm@namelet@ext#1#2{%
112         \expandafter\expandafter\let\expandafter\upm@tmp\csname#2\endcsname%
113         \global\expandafter\let\csname#1\endcsname\upm@tmp%
114 }
115
116 \def\upm@ifdefinedname#1#2#3{%
117         \expandafter\ifx\csname\upm@protect{#1}\endcsname\relax%
118                 #3%
119         \else%
120                 #2%
121         \fi%
122 }
123
124 \newcommand{\upm@column@char}{\ifupmlang{french}{ :}{:}}
125
126 %----------------------------------------
127 % GET THE REFERENCE ID WITHOUT \REF
128 %----------------------------------------
129 \gdef\upm@getref#1{%
130   \expandafter\ifx\csname r@#1\endcsname\relax
131     \nfss@text{\reset@font\bfseries ??}%
132   \else
133     \expandafter\expandafter\expandafter\@car\csname r@#1\endcsname\@nil
134   \fi
135 }
136
137 \gdef\upm@getpageref@filter#1#2#3#4#5{#2}
138
139 \gdef\upm@getpageref#1{%
140   \expandafter\ifx\csname r@#1\endcsname\relax
141     \nfss@text{\reset@font\bfseries ??}%
142   \else%
143     \protected@xdef\upm@p@tmp@tmp{\protect\upm@getpageref@filter\csname r@#1\endcsname}%
144     \upm@p@tmp@tmp%
145     \global\let\upm@p@tmp@tmp\relax%
146   \fi
147 }
148
149 %----------------------------------------
150 % INTERNAL COMMAND FOR TEXT SUPPER/SUB SCRIPT
151 %----------------------------------------
152
153 \let\upm@textsuperscript\textsuperscript
154
155 \def\upm@textsubscript#1{%
156   {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
157
158
159 %----------------------------------------
160 % MACRO THAT PERMITS TO LOOP ON A SEPARATOR
161 %----------------------------------------
162
163 \newif\ifupm@foreach@hasseparator
164 \newif\ifupm@foreach@oneseparator
165
166 \let\upm@foreach@end\relax
167
168 \def\upm@foreach@rec#1{%
169         {\upm@foreach@searchseparator#1\upm@foreach@end\@nil}%
170         \ifupm@foreach@hasseparator%
171                 \protected@xdef\upm@foreach@continue{\protect\upm@foreach@rec{\upm@foreach@rest}}%
172                 \upm@foreach@body%
173                 \upm@foreach@continue%
174         \else%
175                 \ifupm@foreach@oneseparator\else%
176                         \upm@foreach@lastbody%
177                 \fi%
178         \fi%
179 }
180
181 % Loop on parts of a text given a specific separator.
182 % In the bodies, the macros \upm@foreach@term is the current data.
183 % #1: is the separator to consider
184 % #2: is the data set
185 % #3: is the body to run for each loop, except the last.
186 % #4: is the body to run for the last loop.
187 \def\upm@foreach#1\in#2\do#3#4{%
188         \global\upm@foreach@oneseparatorfalse%
189         \gdef\upm@foreach@searchseparator##1#1##2\@nil{%
190                 \gdef\upm@foreach@term{##1}%
191                 \ifx\upm@foreach@end##2%
192                         \global\upm@foreach@hasseparatorfalse%
193                 \else%
194                         \gdef\upm@foreach@rest{##2}%
195                         \global\upm@foreach@hasseparatortrue%
196                         \global\upm@foreach@oneseparatortrue%
197                 \fi%
198         }%
199         \gdef\upm@foreach@body{#3}%
200         \gdef\upm@foreach@lastbody{#4}%
201         \upm@foreach@rec{#2#1}%
202 }
203
204 %----------------------------------------
205 % MACRO THAT PERMITS TO FIND A STRING
206 %----------------------------------------
207 \def\upm@ifin#1#2{\begingroup\edef\upm@tmp{\endgroup\noexpand\in@{#1}{#2}}\upm@tmp\ifin@}
208
209 %-----------------------------------------
210 % Option parameters
211 \newif\ifupm@common@optlist@needdefault
212 \gdef\upm@common@optlist@parseparams#1=#2\@nil{%
213         \ifthenelse{\equal{#2}{===}}{%
214                 \global\upm@common@optlist@needdefaulttrue%
215         }{%
216                 \global\upm@common@optlist@needdefaultfalse%
217         }%
218 }
219 \DeclareRobustCommand{\upm@common@optlist}[1]{%
220         {\upm@common@optlist@parseparams #1====\@nil}%
221 }
222 \newcommand{\upm@setkeys}[3]{%
223         \upm@common@optlist{#3}%
224         \ifupm@common@optlist@needdefault%
225                 \expandafter\setkeys{#1}{#2=#3}%
226         \else%
227                 \expandafter\setkeys{#1}{#3}%
228         \fi%
229 }
230
231 \endinput