summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/romanbar/romanbar.sty
blob: 95aeddaafd5c2980d38b8f27311e5c45fb55708a (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
%%
%% This is file `romanbar.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% romanbar.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: romanbar
%% Version: 2012/01/01 v1.0f
%% 
%% Copyright (C) 2011 by
%%     H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
%% 
%% The usual disclaimer applies:
%% If it doesn't work right that's your problem.
%% (Nevertheless, send an e-mail to the maintainer
%%  when you find an error in this package.)
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is H.-Martin Muench.
%% 
%% This work consists of the main source file romanbar.dtx,
%% the README, and the derived files
%%    romanbar.sty, romanbar.pdf,
%%    romanbar.ins, romanbar.drv,
%%    romanbar-example.tex, romanbar-example.pdf.
%% 
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{romanbar}[2012/01/01 v1.0f
              Roman numbers with bars (HMM)]

%% Allows to write Roman numbers (or any other text) with bars
%% and to convert Arabic numbers into Roman ones.
%% romanbar may work with earlier versions of LaTeX,
%% but this was not tested. Please consider updating
%% your LaTeX to the most recent version
%% (if it is not already the most recent version).

\def\gobbleminus#1{\ifx-#1\else#1\fi}
%% from http://www.tex.ac.uk/cgi-bin/texfaq2html?label=isitanum

\newcommand{\ifnumeric}[3]{%
%% similar to http://tex.stackexchange.com/a/17119
\sbox\z@{\@tempcnta=0\gobbleminus#1\relax}%
\ifdim\wd0>\z@\relax#3% is not numeric
\else#2% is numeric
\fi%
}

\def\r@iseL#1{\ifx @#1% then terminate
\else%
\if L#1\raisebox{0.05ex}{L}\else #1\fi%
\expandafter\r@iseL%
\fi%
}

\DeclareRobustCommand{\Romanbar}[1]{%
\ifnumeric{#1}{% is numeric
\@tempcnta=#1\relax%
%% similar to \XRoman from the http://ctan.org/pkg/pageslts package
\ifnum\@tempcnta<1%
  \ifnum #1>0%
    \relax \Roman@bar{\Roman{#1}}%
  \else%
    \ifnum #1<0%
     -\Roman@bar{\expandafter\@slowromancap\romannumeral\number-#1@%
     }%
    \else%
      \Roman@bar{0}%
    \fi%
  \fi%
\else\Roman@bar{\@Roman\@tempcnta}%
\fi%
}{% is not numeric
\Roman@bar{#1}%
}%
}

\DeclareRobustCommand{\Roman@bar}[1]{% #1 is in Roman, i.e. MMXII
%% (or any other text, "Caesar" would work, too).
%% similar to code of  by Prof. Enrico Gregorio (egreg) at
%% http://tex.stackexchange.com/questions/24065/roman-numerals-formatting/24084#24084
\@bsphack%
\edef\romanbartmp{#1}%
%% height:
\sbox0{\textsf{\romanbartmp}}%
%% top line:
%% + top of top line:
\@tempdima=\ht0%
\advance\@tempdima+0.05ex%0.03
\dimen1=\@tempdima%
%% + bottom of top line:
\@tempdima=-\ht0%
\advance\@tempdima+0.05ex%0.07
\dimen2=\@tempdima%
%% width:
\sbox0{\textsf{\expandafter\r@iseL\romanbartmp @}}%
\@tempdima=\wd0%
\advance\@tempdima+1pt%
\dimen0=\@tempdima%
\@esphack%
\makebox[\dimen0]{%
\rlap{\vrule width\dimen0 height\dimen1 depth\dimen2}% top    line
\rlap{\vrule width\dimen0 height 0.06ex depth 0.03ex}% bottom line
\kern0.5pt\textsf{\expandafter\r@iseL\romanbartmp @}\kern0.5pt}%
}

\DeclareRobustCommand{\romannum}[1]{%
\ifnumeric{#1}{% is numeric
\@tempcnta=#1\relax%
%% similar to \xroman from the http://ctan.org/pkg/pageslts package
\ifnum\@tempcnta<1%
  \ifnum #1>0%
    \relax \roman{#1}%
  \else%
    \ifnum #1<0%
     -\romannumeral\number-#1@%
    \else%
      0%
    \fi%
  \fi%
\else\@roman\@tempcnta%
\fi%
}{% is not numeric
\PackageError{romanbar}{%
Argument of \string\romannum\space is not a number}{%
The command \string\romannum\space converts an Arabic number into a%
 lower-case Roman one,\MessageBreak%
but the used argument of \string\romannum\space is not an Arabic number%
 but\MessageBreak%
`#1`,\MessageBreak%
which will now be printed unchanged.}%
#1%
}%
}

\DeclareRobustCommand{\Romannum}[1]{%
\ifnumeric{#1}{% is numeric
\@tempcnta=#1\relax%
%% similar to \XRoman from the http://ctan.org/pkg/pageslts package
\ifnum\@tempcnta<1%
  \ifnum #1>0%
    \relax \Roman{#1}%
  \else%
    \ifnum #1<0%
     -\expandafter\@slowromancap\romannumeral\number-#1@%
    \else%
      0%
    \fi%
  \fi%
\else\@Roman\@tempcnta%
\fi%
}{% is not numeric
\PackageError{romanbar}{%
Argument of \string\Romannum\space is not a number}{%
The command \string\Romannum\space converts an Arabic number into an%
 upper-case Roman one,\MessageBreak%
but the used argument of \string\Romannum\space is not an Arabic number%
 but\MessageBreak%
`#1`.}%
#1%
}%
}

\endinput
%%
%% End of file `romanbar.sty'.