summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/rccol/rccol.dtx
blob: 9e469c81b2bc5d70afe4fb05681d3c3ca9eb2dbb (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
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
% \iffalse META-COMMENT
%
% The rccol package for use with TeX / LaTeX
% Copyright 2000-2005
% Eckhart Guthoehrlein
% e-mail <e_w_g@web.de>
%
% This program may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
%
% This program consists of the files 'rccol.dtx', 'rccol.ins'
% and 'README'.
%
% The package provides a special column type for tables.
% Numbers are centered to the title and flush right to each other,
% as well as rounded to a given accuracy. It needs the
% array package (sould be part of your LaTeX-distribution)
% and the fltpoint package (by the author, available from CTAN).
%
% Run TeX over rccol.ins to produce the docstripped version
% of the file. The documentation can be typeset by running
% LaTeX over rccol.dtx. You can use the docstrip utility
% with option 'driver' to generate a separate file for the
% generation of the user guide.
%
%	Please note that there is no further development of rccol.
% Do it yourself according to the license.
%
%                 E.W.G.
%
%
% \fi ^^A end meta-comment
% \CheckSum{408}
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% 
% ^^A The often-used and not very interesting example table...
% \newcommand{\tabexample}{%
%  \hline
%  \multicolumn{1}{c}{Value 1} & \multicolumn{1}{c}{Value 2} &
%  \multicolumn{1}{c}{Value 3}\tabularnewline
%  \hline
%  2345,765 & 1,6 & 21   \tabularnewline
%    45,130 & 0,2 &  1,65\tabularnewline 
%   543,99  & 2   &  9,9 \tabularnewline
%  \hline 
%  \end{tabular}}
%
%
% \DoNotIndex{\def,\edef,\xdef,\gdef,\let,\global,\if,\ifx,\else,\fi,
%  \loop,\repeat,\noexpand,\expandafter,\newtoks,\newif,\ignorespaces,
%  \unskip,\setbox,\dimen,\count,\advance,\multiply,\divide,\wd,
%  \relax,\hskip,\the,\hfil,\hfill,\hbox,\ifnum,
%  \@ifnextchar,\tabularnewline,\documentclass,\usepackage,
%  \OnlyDescription,\AlsoImplementation,\EnableCrossrefs,
%  \DisableCrossrefs,\CodelineIndex,\RecordChanges,\DocInput,
%  \begin,\end,\NeedsTeXFormat,\DeclareOption,\ProvidesPackage,
%  \AtBeginDocument,\ProcessOptions,\RequirePackage,
%  \ar@getul,\ar@getll,\llap,\newdimen,\number}
%
% \MakeShortVerb{\"}
% \catcode`\@=11
%
% \changes{v1.0a}{2000/08/23}{First public release.}
% \changes{v1.1a}{2000/09/05}{Minor corrections.
%     Better support for different decimal signs.}            
% \changes{v1.2b}{2004/11/12}{Some fixes, development freeze.}
% \changes{v1.2c}{2005/05/17}{Small fix for decimal sign input/output.}
%         
% \GetFileInfo{rccol.sty}
% \title{The \texttt{rccol} package\thanks{This
%  file has version number \fileversion{} dated \filedate.}}
% \author{Eckhart Guth\"ohrlein}
% \date{}
% \maketitle
%
% \begin{abstract}
% This package provides a new
% \lq right-centered\rq\ tabular column type \texttt{R}. Numbers
% are centered with respect to other entries, but flushed right
% to each other so that corresponding digits are vertically
% aligned. Furthermore, numbers can be rounded
% to the desired precision. 
%
%	Please note that there is no further development of rccol.
% Do it yourself according to the license.
% \end{abstract}
%
%
%
% \section{Introduction}
%
% It is often desirable to produce tables like the following.
% \begin{center}
%   \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}}
%   \tabexample
% \end{center}
% You can see what is ment by \lq right-centered\rq\ columns:
% The center of the largest number is centered with
% the title, while the numbers are aligned with their corresponding
% decimal places. This is, at least to the author's
% opinion, the most aesthetic way to typeset numbers in a table.
% 
% This package provides a general and easy-to-use solution for this 
% problem. In addition, the numbers given as alignment entries can be
% rounded to a given precision and formatted in several ways.
%
% The next section deals with the various possibilities
% to typeset numbers in tables with and without this package.
% After that, the additional facilities of \texttt{rccol} and
% their usage are described.
%
%
% \section{Numbers in tables}
%
% The typesetting of numbers in tables needs special care.
% Most importantly, the vertical alignment of corresponding 
% decimal places in a column should be ensured.
% Furthermore, it is desirable to achieve a proper placement
% (centering normally looks best)
% with respect to the column title and other entries 
% which are not numbers.
%
% First, let us discuss the possibilities
% available with and without this package, a small example
% for each one is given below.
% \begin{itemize}
%  \item Centered columns. This does not allow a vertical
%  alignment of corresponding digits, except if all numbers
%  have the exactly the same number of digits before and
%  after the decimal sign.
%  \item Flushed right columns. If the numbers have the same
%  number of digits after the decimal sign, the alignment
%  of corresponding digits will be correct. However, in any
%  case the placement with respect to the title will not
%  look good.
%  \item Flushed left columns. Similar restrictions as for
%  flushed right ones.
%  \item Use two columns with the decimal sign inserted between
%  them, e.\,g.\ "r@{,}l",
%  and typeset the title with "\multicolumn{2}{c}{Title}".
%  This provides correct alignment for corresponding digits, but
%  no proper placement with respect to the title if it is wider
%  than the numbers.
%  \item Use the \texttt{dcolumn} package~\cite{dcolumn}.
%  With version 1.03a,
%  the syntax has been extended so that both correct alignment
%  of digits and centering to other entries is possible.
%  \item Use the \texttt{rccol} package. Both correct alignment
%  and centering to other entries are possible. Furthermore,
%  other features like rounding of numbers are provided.
% \end{itemize}
%
% Let us have a look at an example of these possibilities.
% The following table shows the first four ones.
% \begin{center}
%  \begin{tabular}{|c|r|l|r@{,}l|}
%  Column type \texttt{c} & Column type \texttt{r} &
%  Column type \texttt{l} &
%  \multicolumn{2}{c|}{Spaltentyp \texttt{r@\{,\}l}}
%  \tabularnewline
%  100,5 & 100,5 & 100,5 & 100&5\tabularnewline
%  7,93 & 7,93 & 7,93 & 7&93\tabularnewline
%  17,123 & 17,123 & 17,123 & 17&123\tabularnewline
%  3141,592 & 3141,592 & 3141,592 & 3141&592\tabularnewline
%  13 & 13 & 13 & \multicolumn{1}{r@{}}{13} &\tabularnewline
%  0,00017 & 0,00017 & 0,00017 & 0&00017\tabularnewline
%  \end{tabular}
% \end{center}
%
% Obviously, none of the results is satisfying. The following
% table shows the result with
% the \texttt{dcolumn} and with the \texttt{rccol} package.
% \begin{center}
%  \rcRoundingfalse
%  \begin{tabular}{|D{,}{,}{4.5}|R{4}{5}|}
%  \multicolumn{1}{|c|}{Column type \texttt{D\{,\}\{,\}\{4.5\}}} &
%  \multicolumn{1}{c|}{Column type \texttt{R\{4\}\{5\}}}\tabularnewline
%  100,5 & 100,5\tabularnewline
%  7,93 & 7,93\tabularnewline
%  17,123 & 17,123\tabularnewline
%  3141,592 & 3141,592\tabularnewline
%  13 & 13\tabularnewline
%  0,00017 & 0,00017\tabularnewline
%  \end{tabular}
% \end{center}
%
% None of the special features of \texttt{rccol} have been used in
% this example. As you can see, the final results of the two packages
% are identical in this case. So, as long as you do not need the 
% features described in the next section, you can work equally well 
% with either of the two packages.
%
% \section{User interface}
% The new column type "R" is used as normally in the preamble of a
% \LaTeX\ table. It takes two mandatory arguments: the number of
% digits before and the number of digits after the decimal sign.
% The example table above has been produced by
% \begin{verbatim}
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}}
% \hline
% \multicolumn{1}{c}{Value 1} & \multicolumn{1}{c}{Value 2} &
% \multicolumn{1}{c}{Value 3}\tabularnewline
% \hline
% 2345,765 & 1,6 & 21   \tabularnewline
%   45,130 & 0,2 &  1,65\tabularnewline 
%  543,99  & 2   &  9,9 \tabularnewline
% \hline 
% \end{tabular}
% \end{verbatim}
%
% \DescribeMacro\rcRoundingtrue\DescribeMacro\rcRoundingfalse
% By default, numbers are rounded to the given number of digits
% after the decimal sign, and trailing zeros are appended if they are
% missing in the input file. This behaviour can be toggled
% with the switch "\rcRoundingtrue"/"\rcRoundingfalse", obeying
% the normal grouping rules, and with the package options
% \texttt{rounding} or \texttt{norounding} (see below.)
% With "\rcRoundingfalse", the above input results into the following
% result. Numbers are not rounded or altered in any way; trailing
% zeros are not appended.
% \begin{center}
%  \rcRoundingfalse
%   \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}}
%   \tabexample
% \end{center}
%
% The "R" column specifier also takes optional arguments
% (thanks go to Rolf Niepraschk for suggesting this and
% encouraging me). The optional parameters
% determine the characters used for the decimal sign in the
% input (\texttt{.tex}) and the output file (\texttt{.dvi} or
% perhaps \texttt{.pdf}), so the full syntax for the "R" column is
% \begin{flushleft}
% "\begin{tabular}{...R["\meta{character}"]["\meta{character}"]{"%
% \meta{number}"}{"\meta{number}"}...}"
% \end{flushleft}
% For example, "R[,][.]{1}{1}" will produce a column centered for
% numbers with one digit before and one after the decimal sign, which
% is a comma in the input file, but a point in the output.
% If only one optional parameter is given, this character will be used
% for input and output, so "R[!]{1}{1}" is equivalent to
% "R[!][!]{1}{1}".
%
% Another optional parameter is a "-" character after the "R" as in
% "R-{4}{0}". In this case, the width of a preceding negative sign (to
% be exact, the width of "$-$") will be taken into account when
% centering.
%
% \DescribeMacro\rcDecimalSign\DescribeMacro\rcDecimalSignInput
% \DescribeMacro\rcDecimalSignOutput
% The decimal sign can be changed with the commands "\rcDecimalSign",
% affecting both input and output. It can be changed separately 
% for input and output with 
% "\rcDecimalSignInput" and "\rcDecimalSignOutput". These commands 
% obey the normal grouping rules. Furthermore, there are some
% package options for setting the defaults (see below).
% To give an example, let's typeset the above table once again, but with
% "\rcDecimalSignOutput{\ensuremath{\cdot}}".
% \begin{center}
%  \rcDecimalSignOutput{\ensuremath{\cdot}}
%   \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}}
%   \tabexample
% \end{center}
%
%
% \section{Package Options}
% The \texttt{rccol} package can be loaded as any \LaTeX\ package via
% \begin{flushleft}
% "\usepackage["\meta{option list}"]{rccol}"
% \end{flushleft}
% with the following options.
% \begin{description}
% \item[rounding] Enable rounding, equivalent to
%  "\rcRoundingtrue" at the beginning of the document.
%  This is the default, so explicitly using this option is not
%  necessary.
% \item[norounding] Disable rounding by default, equivalent to
%  "\rcRoundingfalse" at the beginning of the document.
% \item[comma] Use a comma as the decimal sign, equivalent to
%  "\rcDecimalSign{,}" at the beginning of the document. This is 
%  the default, so it is normally not necessary to explicitly
%  give this option.
% \item[german] See comma.
% \item[english] Use a point as the decimal sign, equivalent
%  to "\rcDecimalSign{.}" at the beginning of the document.
% \item[USenglish] See english.
% \item[point] See english.
% \end{description}
%
%
% \section{Additional hints and remarks}
%
% \begin{itemize}
%
% \item Any tokens in the alignment entries which are not digits
%  are put in front of the alignment entry. This can be used
%  to switch to bold face or to add something like `$>$' before the
%  number. If the tokens have any width, it is your job
%  to correct this, e.\,g.\ by putting them into a "\makebox[0pt][r]".
%  You must enclose commands with arguments inside an extra pair
%  of curly braces to keep them together, otherwise error messages
%  will occur. Example:
% \begin{verbatim}
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}}
% \hline
% \multicolumn{1}{c}{Value 1} & \multicolumn{1}{c}{Value 2} &
% \multicolumn{1}{c}{Value 3}\tabularnewline
% \hline
% 2345,765 & {\mathversion{bold}} 1,6   & 21    \tabularnewline
%   45,130 & 0,2                        &  1,65 \tabularnewline 
%  543,99  & {\makebox[0mm][r]{$>{}$}}2 &  9,9  \tabularnewline
% \hline 
% \end{tabular}
% \end{verbatim}
% Result:
% \begin{center}
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}}
% \hline
% \multicolumn{1}{c}{Value 1} & \multicolumn{1}{c}{Value 2} &
% \multicolumn{1}{c}{Value 3}\tabularnewline
% \hline
% 2345,765 & {\mathversion{bold}} 1,6   & 21    \tabularnewline
%   45,130 & 0,2                        &  1,65 \tabularnewline 
%  543,99  & {\makebox[0mm][r]{$>{}$}}2 &  9,9  \tabularnewline
% \hline 
% \end{tabular}
% \end{center}
%
% \item Negative values are allowed as arguments for the \texttt{R}
% column. This makes it possible to round to multiples of ten, for
% example, by giving `\texttt{-2}' as the second mandatory argument.
% In general, rounding is performed to a precision
% of $10^{-n}$, if $n$ is the second mandatory argument of
% \texttt{R}.
%
% \item The first mandatory argument of the \texttt{R} column 
% specifier does not need to be the real number of digits 
% before the decimal point.
% You can shift the output to the left or to the right by 
% changing this value if you are not satisfied by the centered
% result. Negative values are legal.
%
% \item As with any macro, single token arguments can be given without
% braces. This means that `"R{4}{3}"' is equivalent to `"R43"'. Maybe 
% you will prefer the shorter alternative.
% \end{itemize}
%
% \section{Requirements}
% The \texttt{rccol} package needs the \texttt{array}~\cite{array}
% and the \texttt{fltpoint}~\cite{fltpoint} packages.
%
% \section{Final Remarks}
% There are some open problems and desirable features concerning this
% package, e.\,g.\ formatted output of numbers. However, I have ceased
% using \LaTeX, so I don't think that I will make further extensions to
% {\tt rccol}. You are free to do it yourself -- the license is LPPL.
% Furthermore, you might be interested in the following packages,
% available from CTAN if not already included in your distribution:
% \begin{itemize}
% \item {\tt dcolumn} of course,
% \item {\tt numprint} for formatting of numbers,
% \item {\tt fp} for calculations inside \TeX.
% \end{itemize}
%
% \StopEventually{%
%  \begin{thebibliography}{1}
%     \bibitem{dcolumn} David Carlisle, ``The \texttt{dcolumn}
%     package''. The \texttt{dcolumn} package is part of the standard
%     \LaTeX\ distribution.
%     \bibitem{array} Frank Mittelbach, David Carlisle, ``A new 
%      implementation of \LaTeX's \texttt{tabular} and \texttt{array}
%      environment''. The \texttt{array} package is part of the standard
%      \LaTeX\ distribution.
%     \bibitem{fltpoint} Eckhart Guth\"ohrlein, ``The \texttt{fltpoint}
%      package'', v1.1b, last revised 2004/11/12. The \texttt{fltpoint}
%      package is available from CTAN.
%  \end{thebibliography}%
% }
%
% \section{Implementation}
%
% \subsection{DriverFile}
% The \texttt{docstrip} utility can be used to generate
% a driver file producing the documentation.
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\usepackage{dcolumn}
\usepackage{rccol}
\AtBeginDocument{\DeleteShortVerb{\|}} % the default is not needed
%\OnlyDescription    % typeset only user documentation
\AlsoImplementation  % typeset implementation details
\EnableCrossrefs    % say \DisableCrossrefs if index is ready
%\DisableCrossrefs
\CodelineIndex      % index using codeline numbers
\RecordChanges      % keep change log
%\OldMakeindex       % use if your Makeindes is pre-v2.9
\begin{document}
   \DocInput{rccol.dtx}
\end{document}
%</driver>
%    \end{macrocode}
%
% \subsection{\LaTeX\ package info and options}
% \changes{v1.1b}{2000/09/08}{Added ngerman, austrian and naustrian
%                             package options.}
%    \begin{macrocode}
%<*rcmain>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{rccol}[2005/05/17 v1.2c right-centered columns]
\DeclareOption{rounding}{\AtBeginDocument{\rcRoundingtrue}}
\DeclareOption{norounding}{\AtBeginDocument{\rcRoundingfalse}}
\DeclareOption{USenglish}{\AtBeginDocument{\rcDecimalSign.}}
\DeclareOption{english}{\AtBeginDocument{\rcDecimalSign.}}
\DeclareOption{point}{\AtBeginDocument{\rcDecimalSign.}}
\DeclareOption{german}{\AtBeginDocument{\rcDecimalSign,}}
\DeclareOption{ngerman}{\AtBeginDocument{\rcDecimalSign,}}
\DeclareOption{austrian}{\AtBeginDocument{\rcDecimalSign,}}
\DeclareOption{naustrian}{\AtBeginDocument{\rcDecimalSign,}}
\DeclareOption{comma}{\AtBeginDocument{\rcDecimalSign,}}
\ProcessOptions*\relax
%    \end{macrocode}
% \subsection{Require packages}
% To work properly, \texttt{rccol} needs the \texttt{array} and
% the \texttt{fltpoint} packages. An up-to-date version of
% \texttt{fltpoint} is necessary.
%    \begin{macrocode}
\RequirePackage{array}
\RequirePackage{fltpoint}[2004/11/12]
%    \end{macrocode}
%
%
% \subsection{Registers \& Co}
%
% \begin{macro}{\rc@preskip}
% \begin{macro}{\rc@postskip}
% Allocate dimen registers "\rc@preskip" and "\rc@postskip".
%    \begin{macrocode}
\newdimen\rc@preskip
\newdimen\rc@postskip
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rc@digits}
% \changes{v1.1a}{2000/09/95}{Read all digits into one register,
%     no more separation of pre- and afterpoint digits.}
% \begin{macro}{\rc@preothertoks}
% \changes{v1.1b}{2000/09/08}{Separation of other tokens inserted^^A
%     before and after the number, now saved in "\rc@preothertoks"^^A
%     and "\rc@postothertoks".}
% \begin{macro}{\rc@postothertoks}
% Allocate token registers "\rc@digits", "\rc@preothertoks" 
% and "\rc@postothertoks".
%    \begin{macrocode}
\newtoks\rc@digits
\newtoks\rc@preothertoks
\newtoks\rc@postothertoks
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifrcRounding}
% \changes{v1.1a}{2000/09/05}{Rounding switch prefixed with `rc'.}
% Initialize "\ifrcRounding" as \texttt{true}.
%    \begin{macrocode}
\newif\ifrcRounding
\rcRoundingtrue
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Definition of the \texttt{R} column}
%
% \changes{v1.1a}{2000/09/05}{Optional parameters for the column
%        specifier.}
% \begin{macro}{\NC@rewrite@R}
% \begin{macro}{\rc@rewrite@}
% \begin{macro}{\rc@rewrite@@}
% \begin{macro}{\rc@rewrite@@@}
% The "\newcolumntype" mechanism of \texttt{array.sty} is used
% to set up the new column type. In order to have optional
% parameters, the rewrite macro is redefined to take one or
% two optional parameters, read by "\rc@rewrite@" and
% "\rc@rewrite@@". The optional parameters are used
% to change the decimal sign inside the column if this is
% desired. An appropriate "\fpDecimalSign" is put into
% the token registers "\rc@digits" (input) and "\rc@preothertoks"
% (output), which are somewhat misused for that purpose.
% The macro "\rc@rewrite@@@" reads the two mandatory arguments
% (the number of digits before and after the decimal point)
% and appends everything to the preamble so far. At the
% end "\NC@find" is called to continue the rewriting
% process (see~\cite{array} for further details).
%    \begin{macrocode}
\newcolumntype{R}{}
\def\NC@rewrite@R{%
   \rc@digits{}%
   \rc@preothertoks{}%
   \@ifnextchar-{\rc@rewrite}{\rc@rewrite\relax}}
\def\rc@rewrite#1{%
   \ifx#1-%
      \def\rc@withsign{{\setbox0\hbox{$-$}\hskip\wd0}}%
   \else
      \def\rc@withsign{}%
   \fi
   \@ifnextchar[{\rc@rewrite@}{\rc@rewrite@@@}}
\def\rc@rewrite@[#1]{%
   \rc@digits{\rcDecimalSignInput{#1}}%
   \@ifnextchar[{\rc@rewrite@@}%
      {\rc@preothertoks{\rcDecimalSignOutput{#1}}\rc@rewrite@@@}}
\def\rc@rewrite@@[#1]{%
   \rc@preothertoks{\rcDecimalSignOutput{#1}}\rc@rewrite@@@}
\def\rc@rewrite@@@#1#2{%
   \edef\rc@rewrite@scratch{\the\@temptokena>{\the\rc@digits
      \rc@withsign\noexpand\rc@begin}c<{\noexpand\rc@end
      \the\rc@preothertoks\noexpand\rc@write{#1}{#2}}}
   \@temptokena\expandafter{\rc@rewrite@scratch}%
   \NC@find}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{Macros for reading and processing the numbers}
%
% \begin{macro}{\rc@begin}
% The macro "\rc@begin" is inserted in front of every "R" alignment
% entry. It initializes the token registers "\rc@digits" and
% "\rc@othertoks" and calls "\rc@getnexttok" to read the following
% tokens.
%    \begin{macrocode}
\def\rc@begin{%
   \rc@digits={}%
   \rc@preothertoks={}%
   \rc@postothertoks={}%
   \let\rc@othertoks\rc@preothertoks
   \rc@getnexttok
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rc@getnexttok}
% \begin{macro}{\rc@savedigit}
% \begin{macro}{\rc@savetok}
% The macro "\rc@getnexttok" is used to read the alignment entry
% token after token. The macros "\rc@savedigit" and "\rc@savetok"
% are used to store digits and other tokens in the respective
% token register ("\rc@digits" or "\rc@othertoks").
% "\rc@savedigit" switches "\rc@othertoks" form
% "\rc@preothertoks" to "\rc@postothertoks".
% After processing the token, "\rc@next" is called
% which has been "\let" equal to the appropriate next action.
%    \begin{macrocode}
\def\rc@savedigit#1{\let\rc@othertoks\rc@postothertoks
   \edef\rc@scratch{\the\rc@digits#1}%
   \rc@digits=\expandafter{\rc@scratch}}
\def\rc@savetok#1{\rc@othertoks=\expandafter{\the\rc@othertoks#1}}
\def\rc@getnexttok#1{%
%    \end{macrocode}
% First, check if "\tabularnewline" or "\rc@end" follows.
%    \begin{macrocode}
   \ifx#1\tabularnewline
      \let\rc@next\tabularnewline
   \else
      \ifx#1\rc@end
         \let\rc@next\rc@end
      \else
%    \end{macrocode}
% If not, further tokens have to be read. If the current token
% is allowed by the syntax of fp numbers, save it in "\rc@digits",
% otherwise and if it is neither "\ignorespaces" nor "\unskip",
% save it in "\rc@othertoks".
%    \begin{macrocode}
         \let\rc@next\rc@getnexttok
         \ifx#10\rc@savedigit#1\else\ifx#11\rc@savedigit1\else\ifx#12%
            \rc@savedigit2\else\ifx#13\rc@savedigit3\else\ifx#14%
            \rc@savedigit4\else\ifx#15\rc@savedigit5\else\ifx#16%
            \rc@savedigit6\else\ifx#17\rc@savedigit7\else\ifx#18%
            \rc@savedigit8\else\ifx#19\rc@savedigit9\else%
            \if\noexpand#1\rc@decimalsigninput\rc@savedigit\rc@decimalsigninput%
            \else\ifx#1-\rc@savedigit-\else\ifx#1+\rc@savedigit+%
            \else\ifx#1e\rc@savedigit e\else\ifx#1E\rc@savedigit E%
         \else
            \ifx#1\ignorespaces\else
               \ifx#1\unskip\else
                  \rc@savetok{#1}%
               \fi
            \fi
         \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
      \fi
   \fi
%    \end{macrocode}
% Call "\rc@next".
%    \begin{macrocode}
   \rc@next
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rc@end}
% This macro marks the end of the alignment entry and reads
% the contents of "\rc@digits" into a \texttt{fltpoint} register.
%    \begin{macrocode}
\def\rc@end{\fpDecimalSign{\rc@decimalsigninput}%
   \fp@regread@raw{rc@temp}{\the\rc@digits}}%
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\rc@output}
% The macro "\rc@output" is called by "\rc@write". It takes one argument:
% the text to be typeset. It checks if the material is to be visible,
% and in this case if negative space has to be inserted, or if only
% positive space with the same width as the text has to be output.
% Any text to be finally output is appended to "\rc@number".
%    \begin{macrocode}
\def\rc@output#1{%
%    \end{macrocode}
% Set a box with the text in it to get its width.
%    \begin{macrocode}
   \setbox0=\hbox{#1}%
%    \end{macrocode}
% If the current position is greater than the first digit of the number,
% append nothing and increase "\rc@preskip".
%    \begin{macrocode}
   \ifnum\fp@loopcount>\ar@getul{rc@temp}\relax
      \def\rc@toappend{}%
      \advance\rc@preskip by \wd0
%    \end{macrocode}
% Similarly, if the last digit of the number has a position greater than
% the actual one, do the following: if rouinding is enabled,
% append "#1", if not, append nothing and increase "\rc@postskip".
%    \begin{macrocode}
   \else
      \ifnum\fp@loopcount<\ar@getll{rc@temp}\relax
         \ifrcRounding
            \def\rc@toappend{#1}%
         \else
            \def\rc@toappend{}%
            \advance\rc@postskip by \wd0
         \fi
%    \end{macrocode}
% Otherwise, append "#1". If the position is greater than the desired number of
% digits before the decimal sign, decrease "\rc@preskip". Accordingly, decrease
% "\rc@postskip" if necessary.
%    \begin{macrocode}
      \else
         \def\rc@toappend{#1}%
         \ifnum\fp@loopcount>\rc@outmax\relax
            \advance\rc@preskip by -\wd0
         \else
            \ifnum\fp@loopcount<\rc@outmin\relax
               \advance\rc@postskip by -\wd0
            \fi
         \fi
      \fi
   \fi
%    \end{macrocode}
% Append to "\rc@number" what is to be appended.
%    \begin{macrocode}
   \edef\rc@number{\rc@number\rc@toappend}%
} % end \rc@output
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rc@write}
% The macro "\rc@write" takes two arguments: the number of digits before and
% after the decimal sign.
%    \begin{macrocode}
\def\rc@write#1#2{%
%    \end{macrocode}
% Initialize "\rc@preskip" and "\rc@postskip". Initialize "\rc@number".
%    \begin{macrocode}
   \rc@preskip=0pt
   \rc@postskip=0pt
   \def\rc@number{}%
%    \end{macrocode}
% At the beginning, the tokens to be inserted in front of the
% number, saved in "\rc@preothertoks". This gives the user the possibility
% to change parameters locally for one alignment entry.
%    \begin{macrocode}
   \the\rc@preothertoks
%    \end{macrocode}
% If rounding is enabled, do it.
%    \begin{macrocode}
   \ifrcRounding
      \fp@reground{rc@temp}{-#2}%
   \fi
   \fpDecimalSign{\rc@decimalsignoutput}%
%    \end{macrocode}
% Determine start and end position for the output loop. Save the desired number
% of digits in "\rc@outmax" and "\rc@outmin". The loop starts at
% the desired maximal position or at the upper limit of the number,
% depending on which is greater. The final value is determined accordingly.
% The correction of $-1$ for "#1"
% is necessary because the first digit of a number with $n$ digits before the
% decimal sign means \lq multiple of $10^{(n-1)}$\rq.
%    \begin{macrocode}
   \fp@tempcount=#1\relax
   \advance\fp@tempcount by -1
   \edef\rc@outmax{\number\fp@tempcount}%
   \edef\rc@outmin{\number-#2}%
   \fp@loopcount=\rc@outmax\relax
   \fp@settomax{\fp@loopcount}{\fp@loopcount}{\ar@getul{rc@temp}}%
   \fp@settomin{\fp@loopcountii}{\rc@outmin}{\ar@getll{rc@temp}}%
%    \end{macrocode}
% The main loop follows. For output, "\rc@output" is used to append
% anything to "\rc@number". The thousand separator is inserted in the
% appropriate places, that means if
% $(n\bmod3=2)\vee \left((n\bmod3=-1)\wedge (n\neq-1)\right)$
% with $n$ standing for the value of "\fp@loopcount". The decimal sign
% is inserted in front of the digit if $n=-1$.
%    \begin{macrocode}
   \loop
      \fp@modulo{\fp@loopcount}{3}%
      \ifnum\fp@param=2
         \rc@output{\fp@thousandsep}%
      \else
         \ifnum\fp@param=-1
            \ifnum\fp@loopcount=-1\else
               \rc@output{\fp@thousandsep}%
            \fi
         \fi
      \fi
      \ifnum\fp@loopcount=-1
         \rc@output{\rc@decimalsignoutput}%
      \fi
      \fp@getdigit{rc@temp}{\fp@loopcount}%
      \rc@output{\fp@param}%
   \ifnum\fp@loopcount>\fp@loopcountii
      \advance\fp@loopcount by -1
   \repeat
%    \end{macrocode}
% If the number is smaller than zero, a minus sign is put in front
% of it. The usage of a token register prevents further expansion.
%    \begin{macrocode}
   \fp@regcomp{rc@temp}{@0}%
   \if\fp@param<%
      \rc@digits={\llap{$-$}}%
      \edef\rc@number{\the\rc@digits\rc@number}%
   \fi
%    \end{macrocode}
% "\rc@number" is preceded by the computed white space
% and by any tokens that have been found in the alignment entry and
% stored in "\rc@preothertoks" or "\rc@postothertoks".
%    \begin{macrocode}
	 \hfill
   \hskip\rc@preskip
   \rc@number
   \hskip\rc@postskip
   \the\rc@postothertoks
	 \hfill
}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Parameters and configuration}
%
% \begin{macro}{\rcDecimalSign}
% \changes{v1.1b}{2000/09/08}{Use "\def" instead of "\let".}
% \begin{macro}{\rcDecimalSignInput}
% \begin{macro}{\rcDecimalSignOutput}
% The macros "\rcDecimalSignInput" and "\rcDecimalSignOutput" can be 
% used to change the default use of a comma as the decimal sign.
% This can be done separately for input and output. 
% "\rcDecimalSign" changes both.
%    \begin{macrocode}
\def\rcDecimalSign#1{\rcDecimalSignInput{#1}\rcDecimalSignOutput{#1}}
\def\rcDecimalSignInput#1{\edef\rc@decimalsigninput{#1}}
\def\rcDecimalSignOutput#1{\edef\rc@decimalsignoutput{#1}}
\rcDecimalSign{,}
%</rcmain>
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \Finale
% \PrintIndex
% \PrintChanges
%
% \endinput