summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/makebase/makebase.sty
blob: ab2552b7a142a5641aff916722c6edf8a7ad19b5 (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
%%
%% This is file `makebase.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% makebase.dtx  (with options: `package')
%% This file was generated from an XML master source.
%% Amendments and corrections should be notified to the
%% maintainer for inclusion in future versions.
\NeedsTeXFormat{LaTeX2e}[2014/09/29]
\ProvidesPackage{makebase}[2016/05/10 v0.2
 Typeset counters in a different base]
%%
%% Packages required
%%
%% Required for calculations involving lengths or counters, such as changes to widths for margin adjustment.
\RequirePackage{calc}
\newcounter{Sil@MB@prenum}
\newcounter{Sil@MB@postnum}
\newcounter{Sil@MB@quot}
\newcounter{Sil@MB@rem}
\newcounter{Sil@MB@div}
\newcommand{\Sil@MB@maxdiv}[2][16]{%
  \setcounter{Sil@MB@div}{#1}%
  \setcounter{Sil@MB@prenum}{#2}%
  \loop
    \divide\c@Sil@MB@prenum by\c@Sil@MB@div
    \multiply\c@Sil@MB@prenum by\c@Sil@MB@div
    \multiply\c@Sil@MB@div by#1
    \ifnum\c@Sil@MB@prenum>0
  \repeat
  \divide\c@Sil@MB@div by#1
  \divide\c@Sil@MB@div by#1
}
\newcommand{\makebase}[2][16]{%
  \Sil@MB@maxdiv[#1]{#2}%
  \ifnum#1=16 0x\else\ifnum#1=8 0\fi\fi
  \setcounter{Sil@MB@prenum}{#2}%
  \setcounter{Sil@MB@postnum}{#2}%
  \loop
    \ifnum\c@Sil@MB@div>\c@Sil@MB@prenum
      0\divide\c@Sil@MB@div by#1
    \fi
    \divide\c@Sil@MB@postnum by\c@Sil@MB@div
    \setcounter{Sil@MB@quot}{\value{Sil@MB@postnum}}%
    \multiply\c@Sil@MB@postnum by\c@Sil@MB@div
    \setcounter{Sil@MB@rem}{\value{Sil@MB@prenum}-\value{Sil@MB@postnum}}%
    \ifcase\c@Sil@MB@quot 0\or 1\or 2\or 3\or 4\or 5\or 6\or
           7\or 8\or 9\or A\or B\or C\or D\or E\or F\else !Z\fi
    \setcounter{Sil@MB@prenum}{\value{Sil@MB@rem}}%
    \setcounter{Sil@MB@postnum}{\value{Sil@MB@rem}}%
    \divide\c@Sil@MB@div by#1
    \ifnum\c@Sil@MB@rem>0
  \repeat
}

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