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{2014/03/03}
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}
54 %----------------------------------------
56 %----------------------------------------
57 \long\def\Ifnotempty#1{\ifthenelse{\equal{#1}{\@empty}}{}}
58 \long\def\Ifempty#1#2{\ifthenelse{\equal{#1}{\@empty}}{#2}{}}
59 \long\def\Ifelseempty#1#2#3{\ifthenelse{\equal{#1}{\@empty}}{#2}{#3}}
61 %----------------------------------------
63 %----------------------------------------
64 \newcommand{\newpageintoc}{\addtocontents{toc}{\protect\newpage}}
66 %----------------------------------------
68 %----------------------------------------
69 \newif\ifupmbookformat
70 \newif\ifupmreportformat
71 \newif\ifupmarticleformat
75 \upmarticleformatfalse
77 %----------------------------------------
79 %----------------------------------------
80 \newcommand{\setpdfcolor}[1]{}
82 %----------------------------------------
83 % CREATE COMMAND WITH ID AS NAME
84 %----------------------------------------
85 \def\upm@protect#1{\upm@p@protect #1\relax}
86 \def\upm@p@protect#1#2\relax{%
94 \upm@p@protect #2\relax%
98 \def\upm@namedef#1#2{%
99 \@namedef{\upm@protect{#1}}{#2}%
103 \@nameuse{\upm@protect{#1}}%
106 \def\upm@nameundef#1{%
107 \expandafter\let\csname\upm@protect{#1}\endcsname\relax%
110 \def\upm@namelet@ext#1#2{%
111 \expandafter\expandafter\let\expandafter\upm@tmp\csname#2\endcsname%
112 \global\expandafter\let\csname#1\endcsname\upm@tmp%
115 \def\upm@ifdefinedname#1#2#3{%
116 \expandafter\ifx\csname\upm@protect{#1}\endcsname\relax%
123 \newcommand{\upm@column@char}{\iflanguage{french}{ :}{:}}
125 %----------------------------------------
126 % GET THE REFERENCE ID WITHOUT \REF
127 %----------------------------------------
129 \expandafter\ifx\csname r@#1\endcsname\relax
130 \nfss@text{\reset@font\bfseries ??}%
132 \expandafter\expandafter\expandafter\@car\csname r@#1\endcsname\@nil
136 \gdef\upm@getpageref@filter#1#2#3#4#5{#2}
138 \gdef\upm@getpageref#1{%
139 \expandafter\ifx\csname r@#1\endcsname\relax
140 \nfss@text{\reset@font\bfseries ??}%
142 \protected@xdef\upm@p@tmp@tmp{\protect\upm@getpageref@filter\csname r@#1\endcsname}%
144 \global\let\upm@p@tmp@tmp\relax%
148 %----------------------------------------
149 % INTERNAL COMMAND FOR TEXT SUPPER/SUB SCRIPT
150 %----------------------------------------
152 \let\upm@textsuperscript\textsuperscript
154 \def\upm@textsubscript#1{%
155 {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
158 %----------------------------------------
159 % MACRO THAT PERMITS TO LOOP ON A SEPARATOR
160 %----------------------------------------
162 \newif\ifupm@foreach@hasseparator
163 \newif\ifupm@foreach@oneseparator
165 \let\upm@foreach@end\relax
167 \def\upm@foreach@rec#1{%
168 {\upm@foreach@searchseparator#1\upm@foreach@end\@nil}%
169 \ifupm@foreach@hasseparator%
170 \protected@xdef\upm@foreach@continue{\protect\upm@foreach@rec{\upm@foreach@rest}}%
172 \upm@foreach@continue%
174 \ifupm@foreach@oneseparator\else%
175 \upm@foreach@lastbody%
180 % Loop on parts of a text given a specific separator.
181 % In the bodies, the macros \upm@foreach@term is the current data.
182 % #1: is the separator to consider
183 % #2: is the data set
184 % #3: is the body to run for each loop, except the last.
185 % #4: is the body to run for the last loop.
186 \def\upm@foreach#1\in#2\do#3#4{%
187 \global\upm@foreach@oneseparatorfalse%
188 \gdef\upm@foreach@searchseparator##1#1##2\@nil{%
189 \gdef\upm@foreach@term{##1}%
190 \ifx\upm@foreach@end##2%
191 \global\upm@foreach@hasseparatorfalse%
193 \gdef\upm@foreach@rest{##2}%
194 \global\upm@foreach@hasseparatortrue%
195 \global\upm@foreach@oneseparatortrue%
198 \gdef\upm@foreach@body{#3}%
199 \gdef\upm@foreach@lastbody{#4}%
200 \upm@foreach@rec{#2#1}%
203 %----------------------------------------
204 % MACRO THAT PERMITS TO FIND A STRING
205 %----------------------------------------
206 \def\upm@ifin#1#2{\begingroup\edef\upm@tmp{\endgroup\noexpand\in@{#1}{#2}}\upm@tmp\ifin@}
208 %-----------------------------------------
210 \newif\ifupm@common@optlist@needdefault
211 \gdef\upm@common@optlist@parseparams#1=#2\@nil{%
212 \ifthenelse{\equal{#2}{===}}{%
213 \global\upm@common@optlist@needdefaulttrue%
215 \global\upm@common@optlist@needdefaultfalse%
218 \DeclareRobustCommand{\upm@common@optlist}[1]{%
219 {\upm@common@optlist@parseparams #1====\@nil}%
221 \newcommand{\upm@setkeys}[3]{%
222 \upm@common@optlist{#3}%
223 \ifupm@common@optlist@needdefault%
224 \expandafter\setkeys{#1}{#2=#3}%
226 \expandafter\setkeys{#1}{#3}%