1 % Copyright (c) 2009-13 Stephane GALLAND <galland@arakhne.org>
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.
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.
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.
19 \global\edef\upm@package@private@doctype@ver{2015/04/24}
21 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
22 \ProvidesPackage{upmethodology-p-common}[\upm@package@private@doctype@ver]
24 \RequirePackage{ifthen}
25 \RequirePackage{xspace}
26 \RequirePackage{xcolor}
27 \RequirePackage{ifpdf}
29 %----------------------------------------
31 %----------------------------------------
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
40 \gdef\UPMVERSIONTEST{\ver@UPMVERSION\\\ver@UPMVERSION@major}
42 %----------------------------------------
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}
49 %----------------------------------------
51 %----------------------------------------
52 \def\upmcurrentlang{english}
53 \def\ifupmlang#1{\ifthenelse{\equal{#1}{\upmcurrentlang}}}
55 %----------------------------------------
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}}
62 %----------------------------------------
64 %----------------------------------------
65 \newcommand{\newpageintoc}{\addtocontents{toc}{\protect\newpage}}
67 %----------------------------------------
69 %----------------------------------------
70 \newif\ifupmbookformat
71 \newif\ifupmreportformat
72 \newif\ifupmarticleformat
76 \upmarticleformatfalse
78 %----------------------------------------
80 %----------------------------------------
81 \newcommand{\setpdfcolor}[1]{}
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{%
95 \upm@p@protect #2\relax%
99 \def\upm@namedef#1#2{%
100 \@namedef{\upm@protect{#1}}{#2}%
104 \@nameuse{\upm@protect{#1}}%
107 \def\upm@nameundef#1{%
108 \expandafter\let\csname\upm@protect{#1}\endcsname\relax%
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%
116 \def\upm@ifdefinedname#1#2#3{%
117 \expandafter\ifx\csname\upm@protect{#1}\endcsname\relax%
124 \newcommand{\upm@column@char}{\ifupmlang{french}{ :}{:}}
126 %----------------------------------------
127 % GET THE REFERENCE ID WITHOUT \REF
128 %----------------------------------------
130 \expandafter\ifx\csname r@#1\endcsname\relax
131 \nfss@text{\reset@font\bfseries ??}%
133 \expandafter\expandafter\expandafter\@car\csname r@#1\endcsname\@nil
137 \gdef\upm@getpageref@filter#1#2#3#4#5{#2}
139 \gdef\upm@getpageref#1{%
140 \expandafter\ifx\csname r@#1\endcsname\relax
141 \nfss@text{\reset@font\bfseries ??}%
143 \protected@xdef\upm@p@tmp@tmp{\protect\upm@getpageref@filter\csname r@#1\endcsname}%
145 \global\let\upm@p@tmp@tmp\relax%
149 %----------------------------------------
150 % INTERNAL COMMAND FOR TEXT SUPPER/SUB SCRIPT
151 %----------------------------------------
153 \let\upm@textsuperscript\textsuperscript
155 \def\upm@textsubscript#1{%
156 {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
159 %----------------------------------------
160 % MACRO THAT PERMITS TO LOOP ON A SEPARATOR
161 %----------------------------------------
163 \newif\ifupm@foreach@hasseparator
164 \newif\ifupm@foreach@oneseparator
166 \let\upm@foreach@end\relax
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}}%
173 \upm@foreach@continue%
175 \ifupm@foreach@oneseparator\else%
176 \upm@foreach@lastbody%
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%
194 \gdef\upm@foreach@rest{##2}%
195 \global\upm@foreach@hasseparatortrue%
196 \global\upm@foreach@oneseparatortrue%
199 \gdef\upm@foreach@body{#3}%
200 \gdef\upm@foreach@lastbody{#4}%
201 \upm@foreach@rec{#2#1}%
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@}
209 %-----------------------------------------
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%
216 \global\upm@common@optlist@needdefaultfalse%
219 \DeclareRobustCommand{\upm@common@optlist}[1]{%
220 {\upm@common@optlist@parseparams #1====\@nil}%
222 \newcommand{\upm@setkeys}[3]{%
223 \upm@common@optlist{#3}%
224 \ifupm@common@optlist@needdefault%
225 \expandafter\setkeys{#1}{#2=#3}%
227 \expandafter\setkeys{#1}{#3}%