summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ltxmisc/ziffer.sty
blob: 714ad04de76b001923d68af76b5d32d22042f936 (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

% ziffer.sty v2.1
%
% Author:
%
% M. V\"ath      vaeth@mathematik.uni-wuerzburg.de
%
%
% This package provides the macros
% \ZifferAn        (equivalent with \ZifferPunktAn \ZifferStrichAn )
% \ZifferAus       (equivalent with \ZifferPunktAus\ZifferStrichAus)
% \ZifferPunktAn
% \ZifferPunktAus
% \ZifferStrichAn
% \ZifferStrichAus
%
% If \ZifferAn was used, then in numbers in math-mode the following happens:
%   `.' is used as a `one-thousand separator' as common in Germany
%   `,' is used as a decimal separator as common in Germany
%  `--' generates a -- with better spacing (e.g. in 1.000,-- )
%
% You may still use the symbols `.' `,' and `-' in other context in math mode.
%
% The first two conversions are switched on by default, the last conversion has
% to be switched on explicitly (this has been changed in v2.1):
% You may switch on/off the conversions with
% \ZifferPunktAn/\ZifferPunktAus   (for the first two conversions) respectively
% \ZifferStrichAn/\ZifferStrichAus (for the last conversion).
%
% The reason why the last conversion is not on by default (and why it might be
% necessary to [temporarily] switch off a conversion) is that certain packages
% (in particular, newer versions of amsmath) cause problems with it.
%
% There were some discussions which should be the correct output of the
% above conversions (in particular, of `--').
% If you do not like my choice: You may customize (i.e. redefine) the macros
% \ZifferLeer and \ZifferStrich
% after loading the package to produce the `one-thousand separator'
% respectively the `--'.
%
% All above command-names are in German, because I had expected that this
% package is only needed for German texts. Meanwhile, I learned that also
% other countries use this strange convention for numbers. However, for
% downward compatibility, I decided to keep the name conventions anyway
% (after all, the name of the package is in German anyway).

\ifx\newcommand\undefined\else
  \newcommand{\ZifferAn}{}
  \newcommand{\ZifferAus}{}
  \newcommand{\ZifferPunktAn}{}
  \newcommand{\ZifferPunktAus}{}
  \newcommand{\ZifferStrichAn}{}
  \newcommand{\ZifferStrichAus}{}
  \newcommand{\ZifferLeer}{}
  \newcommand{\ZifferStrich}{}
\fi

\def\ZifferAn{\ZifferPunktAn\ZifferStrichAn}
\def\ZifferAus{\ZifferPunktAus\ZifferStrichAus}
\def\ZifferPunktAn{\mathcode`,="8000\mathcode`.="8000\relax}
\def\ZifferPunktAus{\mathcode`,="613B\mathcode`.="013A\relax}
\def\ZifferStrichAn{\mathcode`-="8000\relax}
\def\ZifferStrichAus{\mathcode`-="2200\relax}
\def\ZifferLeer{\phantom{.}}
\ifx\textrm\undefined
  \def\ZifferStrich{\hbox{-\kern0.1em-}}
\else
  \def\ZifferStrich{\textrm{-\kern0.1em-}}
\fi

\mathchardef\ziffer@CommaMy="013B
\mathchardef\ziffer@CommaOri="613B
\mathchardef\ziffer@DotOri="013A
\mathchardef\ziffer@MinusOri="2200
{\ZifferAn
 \catcode`\,=\active\gdef,{\begingroup\obeyspaces\futurelet\n\ziffer@ccheck}
 \catcode`\.=\active\gdef.{\begingroup\obeyspaces\futurelet\n\ziffer@dcheck}
 \catcode`\-=\active\gdef-{\begingroup\obeyspaces\futurelet\n\ziffer@mcheck}}
\def\ziffer@ccheck{\ziffer@check\ziffer@CommaMy\ziffer@CommaOri}
\def\ziffer@dcheck{\ziffer@check\ZifferLeer\ziffer@DotOri}
\def\ziffer@mcheck{\ifx\n-\def\n-{\endgroup\ZifferStrich}%
   \else\def\n{\endgroup\ziffer@MinusOri}\fi\n}
\def\ziffer@check#1#2{%
  \ifx\n1\endgroup#1\else
    \ifx\n2\endgroup#1\else
      \ifx\n3\endgroup#1\else
        \ifx\n4\endgroup#1\else
          \ifx\n5\endgroup#1\else
            \ifx\n6\endgroup#1\else
              \ifx\n7\endgroup#1\else
                \ifx\n8\endgroup#1\else
                  \ifx\n9\endgroup#1\else
                    \ifx\n0\endgroup#1\else
                      \endgroup#2%
                    \fi
                  \fi
                \fi
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi}
\ZifferPunktAn