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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{lmodern,url}
\newcommand{\ttsl}[1]{\texttt{\textsl{#1}}}
\usepackage{pst-soroban}
\def\PS{PostScript}
\title{SOROBAN abacus\\[1cm]
package \texttt{pst-soroban}}
\author{Alain Delmotte \url{esperanto@swing.be}}
\begin{document}
\maketitle
\tableofcontents
\clearpage
\section{Original size \normalsize{(ps unit = 1mm)}}
\psset{unit=1mm}
\begin{center}
\begin{pspicture}(-2,-2)(122,76)
\tige{1}{1}{1}
\tige{2}{0}{0}
\tige{3}{6}{0}
\tige{4}{7}{1}
\tige{5}{4}{0}
\tige{6}{3}{0}
\cadre{6}
\end{pspicture}
\end{center}
\vspace{10mm}
\section{Using the package}
%There are two versions of the package \verb+soroban-pst.sty+ and \verb+soroban-pgf.sty+
%for use with PStricks or tikz/pgf. Just rename the selected system as \verb+soroban.sty+
%and put it in a folder which can be found by \LaTeX.
In the preamble, insert the instruction \verb+\usepackage{pst-soroban}+. There is no need
to load the corresponding graphics package as the packages are required by the pst-soroban package.
The package also sets the base unit as 1 mm; this draws a soroban of the normal size
as used in schools, shops,\dots If one wants to change the size, one sets the base
unit by \verb+\psset{unit=0.25mm}+.% (for PStricks) or \verb+\ladj{0.25}+ (for tikz/pgf).
These instructions can be used any time in the document to change the size for some
part if required.
To draw a soroban, one draws rod(s) with the required bids in the right position and
add either a frame or just top and bottom parts of the frame. One can then add some
bids in other colours and also cross some bids.
Let's draw a soroban representing the number 321.45 in small size: 0.25.
\renewcommand{\colbil}{yellow}
\renewcommand{\coltig}{brun}
\psset{unit=0.25mm}
\begin{center}
\begin{pspicture}(-2,-2)(122,76)
\tige{1}{0}{1}
\tige{2}{3}{0}
\tige{3}{2}{0}
\tige{4}{1}{1}
\tige{5}{4}{0}
\tige{6}{5}{0}
\cadre{6}
\end{pspicture}
\end{center}
\begin{tabular}{|l|l|l|}
\hline
\textbf{line}& \textbf{PStricks} & \textbf{tikz/pgf}\\
\hline
\verb§ 1§ & \verb§\psset{unit=0.25mm}§ & \verb§\ladj{0.25}§\\
\verb§ 2§ & \verb§\begin{pspicture}(-2,-2)(122,76)§ & \verb§\begin{pspicture}§\\
\verb§ 3§ & \verb§\tige{1}{0}{1} § & \verb§\tige{1}{0}{1} §\\
\verb§ 4§ & \verb§\tige{2}{3}{0} § & \verb§\tige{2}{3}{0} §\\
\verb§ 5§ & \verb§\tige{3}{2}{0} § & \verb§\tige{3}{2}{0} §\\
\verb§ 6§ & \verb§\tige{4}{1}{1} § & \verb§\tige{4}{1}{1} §\\
\verb§ 7§ & \verb§\tige{5}{4}{0} § & \verb§\tige{5}{4}{0} §\\
\verb§ 8§ & \verb§\tige{6}{5}{0} § & \verb§\tige{6}{5}{0} §\\
\verb§ 9§ & \verb§\cadre{6} § & \verb§\cadre{6} §\\
\verb§10§ & \verb§\end{pspicture} § & \verb§\end{pspicture} §\\
\hline
\end{tabular}
\vspace{6pt}
Line 1 defines the size, lines 2 and 10 create the picture environment, lines 3--8 draw
the rods and line 9 creates the frame.
For PStricks, one has to give the dimensions of the picture, otherwise the drawing
would have no size and would overlap the surrounding text. One gives some space before
and below (\verb+(-2,-2)+) and after above. The picture is 74.6 units hight and 20* number
of rods wide (here \verb+(122,76)+). Of course, if one adds something before, under,
after or above the soroban, one has to adjust the corresponding part of the frame dimension.
%This is not necessary for tikz.
To draw a rod, one uses the command \verb+\tige+. The syntax is:
\begin{center}
\verb§\tige[§\ttsl{<st>}\verb§]{§\ttsl{<nu>}\verb§}{§\ttsl{<val>}\verb§}{§\ttsl{<un>}\verb§}§
\end{center}
The \ttsl{<nu>} argument numbers the rods from left to right. \ttsl{<val>} is the
number to be represented on the rod from 0 to 9. The \ttsl{<un>} argument tells
that there is a dot on the central bar (1) or not (0); there is normally a dot for the
unit, thousand, million,\dots ranks.
The \ttsl{<st>} argument is optional and tells at which position the drawing is started;
the default value is 1. This is interesting when one wants to put more then one drawing
on a line:
\begin{center}
\begin{minipage}[][][c]{5cm}
\begin{verbatim}
\begin{pspicture}(-2,-2)(182,76)
\tige{1}{1}{1}
\barres{1}
\tige[5]{1}{6}{1}
\barres[5]{1}
\tige[9]{1}{5}{1}
\barres[9]{1}
\end{pspicture}
\end{verbatim}
\end{minipage}
\hspace{10mm}
\begin{minipage}[][][c]{5cm}
\begin{pspicture}(-2,-2)(182,76)
\tige{1}{1}{1}
\barres{1}
\tige[5]{1}{6}{1}
\barres[5]{1}
\tige[9]{1}{5}{1}
\barres[9]{1}
\end{pspicture}
\end{minipage}
\end{center}
In this example, there is no frame but only parts of it above and below; this is
created with the \verb+\barres+ command. The syntaxes for the frame and top/bottom lines are:
\begin{center}
\verb§\cadre[§\ttsl{<st>}\verb§]{§\ttsl{<nb>}\verb§}§ and \verb§\barres[§\ttsl{<st>}\verb§]{§\ttsl{<nb>}\verb§}§.
\end{center}
The optional \ttsl{<st>} arguments are the same as the one of \verb+\tige+, the \ttsl{<nb>}
argument tell how many rods have to be covered.
If one wants to colour a specific bid , one can achieve this with \verb+\binoire+:
\begin{center}
\verb§\binoire[§\ttsl{<st>}\verb§]{§\ttsl{<nu>}\verb§}{§\ttsl{<pos>}\verb§}{§\ttsl{<col>}\verb§}§
\end{center}
\ttsl{<st>} and \ttsl{<nu>} arguments are the same as for \verb+\tige+; the \ttsl{<col>}
argument defines the colour and the \ttsl{<pos>} argument tells which bid has to be
coloured as shown in the following example.
\begin{center}
\begin{minipage}[c]{5cm}
\begin{verbatim}
\begin{pspicture}(-2,-2)(202,76)
\tige{1}{0}{1}
\tige{2}{0}{1}
\tige{3}{0}{1}
\tige{4}{0}{1}
\tige{5}{4}{1}
\tige{6}{4}{1}
\tige{7}{4}{1}
\tige{8}{4}{1}
\tige{9}{0}{1}
\tige{10}{5}{1}
\cadre{10}
\binoire{1}{1}{black}
\binoire{2}{2}{black}
\binoire{3}{3}{black}
\binoire{4}{4}{black}
\binoire{5}{5}{black}
\binoire{6}{6}{black}
\binoire{7}{7}{black}
\binoire{8}{8}{black}
\binoire{9}{9}{black}
\binoire{10}{10}{black}
\end{pspicture}
\end{verbatim}
\end{minipage}
\hspace{10mm}
\begin{minipage}[][][c]{5cm}
\begin{pspicture}(-2,-2)(202,76)
\tige{1}{0}{1}
\tige{2}{0}{1}
\tige{3}{0}{1}
\tige{4}{0}{1}
\tige{5}{4}{1}
\tige{6}{4}{1}
\tige{7}{4}{1}
\tige{8}{4}{1}
\tige{9}{0}{1}
\tige{10}{5}{1}
\cadre{10}
\binoire{1}{1}{black}
\binoire{2}{2}{black}
\binoire{3}{3}{black}
\binoire{4}{4}{black}
\binoire{5}{5}{black}
\binoire{6}{6}{black}
\binoire{7}{7}{black}
\binoire{8}{8}{black}
\binoire{9}{9}{black}
\binoire{10}{10}{black}
\end{pspicture}
\end{minipage}
\end{center}
The \verb+\barbil+ command allows to cross a bid (see example below); the syntax is:
\begin{center}
\verb§\barbil[§\ttsl{<st>}\verb§]{§\ttsl{<nu>}\verb§}{§\ttsl{<pos>}\verb§}§
\end{center}
The arguments \ttsl{<st>}, \ttsl{<nu>} and \ttsl{<pos>} have the same meaning
as those of \verb+\binoire+.
Finally, one can change the overall colours of the rods and the bids, for example
to print in black and white.
This is done by changing the values of the \verb+\colbil+ (for the bids) and
\verb+\coltig+ (for the rods) commands; by default these are yellow and
``brun´´ (new brown colour).
\begin{center}
\begin{minipage}[][][c]{5cm}
\begin{verbatim}
\renewcommand{\colbil}{white}
\renewcommand{\coltig}{black}
\begin{pspicture}(-2,-2)(182,76)
\tige{1}{1}{1}
\barres{1}
\tige[5]{1}{6}{1}
\barbil[5]{1}{5}
\barres[5]{1}
\tige[9]{1}{5}{1}
\barres[9]{1}
\end{pspicture}
\end{verbatim}
\end{minipage}
\hspace{10mm}
\renewcommand{\colbil}{white}
\renewcommand{\coltig}{black}
\begin{minipage}[][][c]{5cm}
\begin{pspicture}(-2,-2)(182,76)
\tige{1}{1}{1}
\barres{1}
\tige[5]{1}{6}{1}
\barbil[5]{1}{5}
\barres[5]{1}
\tige[9]{1}{5}{1}
\barres[9]{1}
\end{pspicture}
\end{minipage}
\end{center}
\section{examples}
\psset{unit=0.25mm}
\textbf{2 + 1} (in colours)\\
1) Put 2 with thumb
\hspace*{5mm}
\begin{pspicture}(-2,-2)(22,76)
\tige{1}{2}{1}
\binoire{1}{5}{black}
\binoire{1}{6}{black}
\barres{1}
\end{pspicture}
\quad 2) Add 1
\hspace*{5mm}
\begin{pspicture}(-2,-2)(22,76)
\tige{1}{3}{1}
\binoire{1}{5}{gray}
\binoire{1}{6}{gray}
\binoire{1}{7}{black}
\barres{1}
\end{pspicture}
\quad
\hspace{5mm}$\Rightarrow$ \textbf{= 3}\hspace{5mm}
\begin{pspicture}(-2,-2)(22,76)
\tige{1}{3}{1}
\barres{1}
\end{pspicture}
\vspace{15mm}
\renewcommand{\colbil}{white}
\renewcommand{\coltig}{darkgray}
\noindent\textbf{7 - 1} (in black and white for printing)\\
1) Set 7 at once (pinch)\hspace*{5mm}
\begin{pspicture}(-2,-2)(22,76)
\tige{1}{7}{1}
\binoire{1}{5}{black}
\binoire{1}{6}{black}
\binoire{1}{10}{black}
\barres{1}
\end{pspicture}
\quad 2) Substract 1
\hspace*{5mm}
\begin{pspicture}(-2,-2)(22,76)
\tige{1}{7}{1}
\binoire{1}{5}{gray}
\binoire{1}{6}{gray}
\binoire{1}{10}{gray}
\barbil{1}{6}
\barres{1}
\end{pspicture}
\quad
\hspace{5mm}$\Rightarrow$ \textbf{= 6}\hspace{5mm}
\begin{pspicture}(-2,-2)(22,76)
\tige{1}{6}{1}
\binoire{1}{3}{black}
\barres{1}
\end{pspicture}
\nocite{*}
\bgroup
\raggedright
\bibliographystyle{plain}
\bibliography{\jobname}
\egroup
\end{document}
|