summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/akktex/akkstring.sty
blob: 28fcbdfa405ea1f2c836969a565d76be3964ebcc (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
%=====================================================================================================================================
% Package akkstring by Igor Akkerman (c) 2004, 2005
% Package providing string operation utilities.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License (latest version).
%
% The latest version of this license can be found at
%     http://www.latex-project.org/lppl.txt
%
% This file may only be distributed together with the full 'AkkTeX' bundle.
%=====================================================================================================================================
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{akkstring}[2005/04/30 1.2.2 by Igor Akkerman (c) 2004, 2005 Package providing string operation utilities.]
%=====================================================================================================================================

\RequirePackage{ifthen}

\makeatletter

\newcommand \ignore[1] {}
\newcommand \ign[1]    {}

\newcommand \centerln[1] {\hspace*{\fill}{#1}\hspace*{\fill}}

\newcommand \firstchar[1] {%
    \def\@firstof##1##2!!!{##1}%
    \expandafter\@firstof#1!!!%
}

\newcommand \removefirstchar[1] {%
    \def\@restof##1##2!!!{##2}%
    \expandafter\@restof#1!!!%
}

% \extractleadingnumber {<string>} {<countername>}
\newcommand \extractleadingnumber[2] {%
    \setbox0=\hbox{\global\csname c@#2\endcsname 0#1\relax}%
}

% \extractnumber {<string>} {<countername>}
\newcommand \extractnumber[2] {%
    \def\@restof##1##2!!!{##2}%
    \def\@remblank##1##2!!!{##1##2}%
    \edef\@string{#1}%
    \extractleadingnumber\@string{#2}%
    \whiledo{\(\not \equal{\@string}{}\) \and \value{#2} = 0} {%
        \edef\@string{\expandafter\@restof\@string!!!}%
        \edef\@string{\expandafter\@remblank\@string!!!}%
        \extractleadingnumber\@string{#2}%
    }%
}

\makeatother