| 1 |
% \iffalse META-COMMENT |
| 2 |
% |
| 3 |
% The rccol package for use with TeX / LaTeX |
| 4 |
% Copyright 2000-2005 |
| 5 |
% Eckhart Guthoehrlein |
| 6 |
% e-mail <[email protected]> |
| 7 |
% |
| 8 |
% This program may be distributed and/or modified under the |
| 9 |
% conditions of the LaTeX Project Public License, either version 1.2 |
| 10 |
% of this license or (at your option) any later version. |
| 11 |
% The latest version of this license is in |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% and version 1.2 or later is part of all distributions of LaTeX |
| 14 |
% version 1999/12/01 or later. |
| 15 |
% |
| 16 |
% This program consists of the files 'rccol.dtx', 'rccol.ins' |
| 17 |
% and 'README'. |
| 18 |
% |
| 19 |
% The package provides a special column type for tables. |
| 20 |
% Numbers are centered to the title and flush right to each other, |
| 21 |
% as well as rounded to a given accuracy. It needs the |
| 22 |
% array package (sould be part of your LaTeX-distribution) |
| 23 |
% and the fltpoint package (by the author, available from CTAN). |
| 24 |
% |
| 25 |
% Run TeX over rccol.ins to produce the docstripped version |
| 26 |
% of the file. The documentation can be typeset by running |
| 27 |
% LaTeX over rccol.dtx. You can use the docstrip utility |
| 28 |
% with option 'driver' to generate a separate file for the |
| 29 |
% generation of the user guide. |
| 30 |
% |
| 31 |
% Please note that there is no further development of rccol. |
| 32 |
% Do it yourself according to the license. |
| 33 |
% |
| 34 |
% E.W.G. |
| 35 |
% |
| 36 |
% |
| 37 |
% \fi ^^A end meta-comment |
| 38 |
% \CheckSum{408} |
| 39 |
% \CharacterTable |
| 40 |
% {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 |
| 41 |
% 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 |
| 42 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 43 |
% Exclamation \! Double quote \" Hash (number) \# |
| 44 |
% Dollar \$ Percent \% Ampersand \& |
| 45 |
% Acute accent \' Left paren \( Right paren \) |
| 46 |
% Asterisk \* Plus \+ Comma \, |
| 47 |
% Minus \- Point \. Solidus \/ |
| 48 |
% Colon \: Semicolon \; Less than \< |
| 49 |
% Equals \= Greater than \> Question mark \? |
| 50 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 51 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 52 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 53 |
% Right brace \} Tilde \~} |
| 54 |
% |
| 55 |
% |
| 56 |
% ^^A The often-used and not very interesting example table... |
| 57 |
% \newcommand{\tabexample}{% |
| 58 |
% \hline |
| 59 |
% \multicolumn{1}{c}{Value 1} & \multicolumn{1}{c}{Value 2} & |
| 60 |
% \multicolumn{1}{c}{Value 3}\tabularnewline |
| 61 |
% \hline |
| 62 |
% 2345,765 & 1,6 & 21 \tabularnewline |
| 63 |
% 45,130 & 0,2 & 1,65\tabularnewline |
| 64 |
% 543,99 & 2 & 9,9 \tabularnewline |
| 65 |
% \hline |
| 66 |
% \end{tabular}} |
| 67 |
% |
| 68 |
% |
| 69 |
% \DoNotIndex{\def,\edef,\xdef,\gdef,\let,\global,\if,\ifx,\else,\fi, |
| 70 |
% \loop,\repeat,\noexpand,\expandafter,\newtoks,\newif,\ignorespaces, |
| 71 |
% \unskip,\setbox,\dimen,\count,\advance,\multiply,\divide,\wd, |
| 72 |
% \relax,\hskip,\the,\hfil,\hfill,\hbox,\ifnum, |
| 73 |
% \@ifnextchar,\tabularnewline,\documentclass,\usepackage, |
| 74 |
% \OnlyDescription,\AlsoImplementation,\EnableCrossrefs, |
| 75 |
% \DisableCrossrefs,\CodelineIndex,\RecordChanges,\DocInput, |
| 76 |
% \begin,\end,\NeedsTeXFormat,\DeclareOption,\ProvidesPackage, |
| 77 |
% \AtBeginDocument,\ProcessOptions,\RequirePackage, |
| 78 |
% \ar@getul,\ar@getll,\llap,\newdimen,\number} |
| 79 |
% |
| 80 |
% \MakeShortVerb{\"} |
| 81 |
% \catcode`\@=11 |
| 82 |
% |
| 83 |
% \changes{v1.0a}{2000/08/23}{First public release.} |
| 84 |
% \changes{v1.1a}{2000/09/05}{Minor corrections. |
| 85 |
% Better support for different decimal signs.} |
| 86 |
% \changes{v1.2b}{2004/11/12}{Some fixes, development freeze.} |
| 87 |
% \changes{v1.2c}{2005/05/17}{Small fix for decimal sign input/output.} |
| 88 |
% |
| 89 |
% \GetFileInfo{rccol.sty} |
| 90 |
% \title{The \texttt{rccol} package\thanks{This |
| 91 |
% file has version number \fileversion{} dated \filedate.}} |
| 92 |
% \author{Eckhart Guth\"ohrlein} |
| 93 |
% \date{} |
| 94 |
% \maketitle |
| 95 |
% |
| 96 |
% \begin{abstract} |
| 97 |
% This package provides a new |
| 98 |
% \lq right-centered\rq\ tabular column type \texttt{R}. Numbers |
| 99 |
% are centered with respect to other entries, but flushed right |
| 100 |
% to each other so that corresponding digits are vertically |
| 101 |
% aligned. Furthermore, numbers can be rounded |
| 102 |
% to the desired precision. |
| 103 |
% |
| 104 |
% Please note that there is no further development of rccol. |
| 105 |
% Do it yourself according to the license. |
| 106 |
% \end{abstract} |
| 107 |
% |
| 108 |
% |
| 109 |
% |
| 110 |
% \section{Introduction} |
| 111 |
% |
| 112 |
% It is often desirable to produce tables like the following. |
| 113 |
% \begin{center} |
| 114 |
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}} |
| 115 |
% \tabexample |
| 116 |
% \end{center} |
| 117 |
% You can see what is ment by \lq right-centered\rq\ columns: |
| 118 |
% The center of the largest number is centered with |
| 119 |
% the title, while the numbers are aligned with their corresponding |
| 120 |
% decimal places. This is, at least to the author's |
| 121 |
% opinion, the most aesthetic way to typeset numbers in a table. |
| 122 |
% |
| 123 |
% This package provides a general and easy-to-use solution for this |
| 124 |
% problem. In addition, the numbers given as alignment entries can be |
| 125 |
% rounded to a given precision and formatted in several ways. |
| 126 |
% |
| 127 |
% The next section deals with the various possibilities |
| 128 |
% to typeset numbers in tables with and without this package. |
| 129 |
% After that, the additional facilities of \texttt{rccol} and |
| 130 |
% their usage are described. |
| 131 |
% |
| 132 |
% |
| 133 |
% \section{Numbers in tables} |
| 134 |
% |
| 135 |
% The typesetting of numbers in tables needs special care. |
| 136 |
% Most importantly, the vertical alignment of corresponding |
| 137 |
% decimal places in a column should be ensured. |
| 138 |
% Furthermore, it is desirable to achieve a proper placement |
| 139 |
% (centering normally looks best) |
| 140 |
% with respect to the column title and other entries |
| 141 |
% which are not numbers. |
| 142 |
% |
| 143 |
% First, let us discuss the possibilities |
| 144 |
% available with and without this package, a small example |
| 145 |
% for each one is given below. |
| 146 |
% \begin{itemize} |
| 147 |
% \item Centered columns. This does not allow a vertical |
| 148 |
% alignment of corresponding digits, except if all numbers |
| 149 |
% have the exactly the same number of digits before and |
| 150 |
% after the decimal sign. |
| 151 |
% \item Flushed right columns. If the numbers have the same |
| 152 |
% number of digits after the decimal sign, the alignment |
| 153 |
% of corresponding digits will be correct. However, in any |
| 154 |
% case the placement with respect to the title will not |
| 155 |
% look good. |
| 156 |
% \item Flushed left columns. Similar restrictions as for |
| 157 |
% flushed right ones. |
| 158 |
% \item Use two columns with the decimal sign inserted between |
| 159 |
% them, e.\,g.\ "r@{,}l", |
| 160 |
% and typeset the title with "\multicolumn{2}{c}{Title}". |
| 161 |
% This provides correct alignment for corresponding digits, but |
| 162 |
% no proper placement with respect to the title if it is wider |
| 163 |
% than the numbers. |
| 164 |
% \item Use the \texttt{dcolumn} package~\cite{dcolumn}. |
| 165 |
% With version 1.03a, |
| 166 |
% the syntax has been extended so that both correct alignment |
| 167 |
% of digits and centering to other entries is possible. |
| 168 |
% \item Use the \texttt{rccol} package. Both correct alignment |
| 169 |
% and centering to other entries are possible. Furthermore, |
| 170 |
% other features like rounding of numbers are provided. |
| 171 |
% \end{itemize} |
| 172 |
% |
| 173 |
% Let us have a look at an example of these possibilities. |
| 174 |
% The following table shows the first four ones. |
| 175 |
% \begin{center} |
| 176 |
% \begin{tabular}{|c|r|l|r@{,}l|} |
| 177 |
% Column type \texttt{c} & Column type \texttt{r} & |
| 178 |
% Column type \texttt{l} & |
| 179 |
% \multicolumn{2}{c|}{Spaltentyp \texttt{r@\{,\}l}} |
| 180 |
% \tabularnewline |
| 181 |
% 100,5 & 100,5 & 100,5 & 100&5\tabularnewline |
| 182 |
% 7,93 & 7,93 & 7,93 & 7&93\tabularnewline |
| 183 |
% 17,123 & 17,123 & 17,123 & 17&123\tabularnewline |
| 184 |
% 3141,592 & 3141,592 & 3141,592 & 3141&592\tabularnewline |
| 185 |
% 13 & 13 & 13 & \multicolumn{1}{r@{}}{13} &\tabularnewline |
| 186 |
% 0,00017 & 0,00017 & 0,00017 & 0&00017\tabularnewline |
| 187 |
% \end{tabular} |
| 188 |
% \end{center} |
| 189 |
% |
| 190 |
% Obviously, none of the results is satisfying. The following |
| 191 |
% table shows the result with |
| 192 |
% the \texttt{dcolumn} and with the \texttt{rccol} package. |
| 193 |
% \begin{center} |
| 194 |
% \rcRoundingfalse |
| 195 |
% \begin{tabular}{|D{,}{,}{4.5}|R{4}{5}|} |
| 196 |
% \multicolumn{1}{|c|}{Column type \texttt{D\{,\}\{,\}\{4.5\}}} & |
| 197 |
% \multicolumn{1}{c|}{Column type \texttt{R\{4\}\{5\}}}\tabularnewline |
| 198 |
% 100,5 & 100,5\tabularnewline |
| 199 |
% 7,93 & 7,93\tabularnewline |
| 200 |
% 17,123 & 17,123\tabularnewline |
| 201 |
% 3141,592 & 3141,592\tabularnewline |
| 202 |
% 13 & 13\tabularnewline |
| 203 |
% 0,00017 & 0,00017\tabularnewline |
| 204 |
% \end{tabular} |
| 205 |
% \end{center} |
| 206 |
% |
| 207 |
% None of the special features of \texttt{rccol} have been used in |
| 208 |
% this example. As you can see, the final results of the two packages |
| 209 |
% are identical in this case. So, as long as you do not need the |
| 210 |
% features described in the next section, you can work equally well |
| 211 |
% with either of the two packages. |
| 212 |
% |
| 213 |
% \section{User interface} |
| 214 |
% The new column type "R" is used as normally in the preamble of a |
| 215 |
% \LaTeX\ table. It takes two mandatory arguments: the number of |
| 216 |
% digits before and the number of digits after the decimal sign. |
| 217 |
% The example table above has been produced by |
| 218 |
% \begin{verbatim} |
| 219 |
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}} |
| 220 |
% \hline |
| 221 |
% \multicolumn{1}{c}{Value 1} & \multicolumn{1}{c}{Value 2} & |
| 222 |
% \multicolumn{1}{c}{Value 3}\tabularnewline |
| 223 |
% \hline |
| 224 |
% 2345,765 & 1,6 & 21 \tabularnewline |
| 225 |
% 45,130 & 0,2 & 1,65\tabularnewline |
| 226 |
% 543,99 & 2 & 9,9 \tabularnewline |
| 227 |
% \hline |
| 228 |
% \end{tabular} |
| 229 |
% \end{verbatim} |
| 230 |
% |
| 231 |
% \DescribeMacro\rcRoundingtrue\DescribeMacro\rcRoundingfalse |
| 232 |
% By default, numbers are rounded to the given number of digits |
| 233 |
% after the decimal sign, and trailing zeros are appended if they are |
| 234 |
% missing in the input file. This behaviour can be toggled |
| 235 |
% with the switch "\rcRoundingtrue"/"\rcRoundingfalse", obeying |
| 236 |
% the normal grouping rules, and with the package options |
| 237 |
% \texttt{rounding} or \texttt{norounding} (see below.) |
| 238 |
% With "\rcRoundingfalse", the above input results into the following |
| 239 |
% result. Numbers are not rounded or altered in any way; trailing |
| 240 |
% zeros are not appended. |
| 241 |
% \begin{center} |
| 242 |
% \rcRoundingfalse |
| 243 |
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}} |
| 244 |
% \tabexample |
| 245 |
% \end{center} |
| 246 |
% |
| 247 |
% The "R" column specifier also takes optional arguments |
| 248 |
% (thanks go to Rolf Niepraschk for suggesting this and |
| 249 |
% encouraging me). The optional parameters |
| 250 |
% determine the characters used for the decimal sign in the |
| 251 |
% input (\texttt{.tex}) and the output file (\texttt{.dvi} or |
| 252 |
% perhaps \texttt{.pdf}), so the full syntax for the "R" column is |
| 253 |
% \begin{flushleft} |
| 254 |
% "\begin{tabular}{...R["\meta{character}"]["\meta{character}"]{"% |
| 255 |
% \meta{number}"}{"\meta{number}"}...}" |
| 256 |
% \end{flushleft} |
| 257 |
% For example, "R[,][.]{1}{1}" will produce a column centered for |
| 258 |
% numbers with one digit before and one after the decimal sign, which |
| 259 |
% is a comma in the input file, but a point in the output. |
| 260 |
% If only one optional parameter is given, this character will be used |
| 261 |
% for input and output, so "R[!]{1}{1}" is equivalent to |
| 262 |
% "R[!][!]{1}{1}". |
| 263 |
% |
| 264 |
% Another optional parameter is a "-" character after the "R" as in |
| 265 |
% "R-{4}{0}". In this case, the width of a preceding negative sign (to |
| 266 |
% be exact, the width of "$-$") will be taken into account when |
| 267 |
% centering. |
| 268 |
% |
| 269 |
% \DescribeMacro\rcDecimalSign\DescribeMacro\rcDecimalSignInput |
| 270 |
% \DescribeMacro\rcDecimalSignOutput |
| 271 |
% The decimal sign can be changed with the commands "\rcDecimalSign", |
| 272 |
% affecting both input and output. It can be changed separately |
| 273 |
% for input and output with |
| 274 |
% "\rcDecimalSignInput" and "\rcDecimalSignOutput". These commands |
| 275 |
% obey the normal grouping rules. Furthermore, there are some |
| 276 |
% package options for setting the defaults (see below). |
| 277 |
% To give an example, let's typeset the above table once again, but with |
| 278 |
% "\rcDecimalSignOutput{\ensuremath{\cdot}}". |
| 279 |
% \begin{center} |
| 280 |
% \rcDecimalSignOutput{\ensuremath{\cdot}} |
| 281 |
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}} |
| 282 |
% \tabexample |
| 283 |
% \end{center} |
| 284 |
% |
| 285 |
% |
| 286 |
% \section{Package Options} |
| 287 |
% The \texttt{rccol} package can be loaded as any \LaTeX\ package via |
| 288 |
% \begin{flushleft} |
| 289 |
% "\usepackage["\meta{option list}"]{rccol}" |
| 290 |
% \end{flushleft} |
| 291 |
% with the following options. |
| 292 |
% \begin{description} |
| 293 |
% \item[rounding] Enable rounding, equivalent to |
| 294 |
% "\rcRoundingtrue" at the beginning of the document. |
| 295 |
% This is the default, so explicitly using this option is not |
| 296 |
% necessary. |
| 297 |
% \item[norounding] Disable rounding by default, equivalent to |
| 298 |
% "\rcRoundingfalse" at the beginning of the document. |
| 299 |
% \item[comma] Use a comma as the decimal sign, equivalent to |
| 300 |
% "\rcDecimalSign{,}" at the beginning of the document. This is |
| 301 |
% the default, so it is normally not necessary to explicitly |
| 302 |
% give this option. |
| 303 |
% \item[german] See comma. |
| 304 |
% \item[english] Use a point as the decimal sign, equivalent |
| 305 |
% to "\rcDecimalSign{.}" at the beginning of the document. |
| 306 |
% \item[USenglish] See english. |
| 307 |
% \item[point] See english. |
| 308 |
% \end{description} |
| 309 |
% |
| 310 |
% |
| 311 |
% \section{Additional hints and remarks} |
| 312 |
% |
| 313 |
% \begin{itemize} |
| 314 |
% |
| 315 |
% \item Any tokens in the alignment entries which are not digits |
| 316 |
% are put in front of the alignment entry. This can be used |
| 317 |
% to switch to bold face or to add something like `$>$' before the |
| 318 |
% number. If the tokens have any width, it is your job |
| 319 |
% to correct this, e.\,g.\ by putting them into a "\makebox[0pt][r]". |
| 320 |
% You must enclose commands with arguments inside an extra pair |
| 321 |
% of curly braces to keep them together, otherwise error messages |
| 322 |
% will occur. Example: |
| 323 |
% \begin{verbatim} |
| 324 |
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}} |
| 325 |
% \hline |
| 326 |
% \multicolumn{1}{c}{Value 1} & \multicolumn{1}{c}{Value 2} & |
| 327 |
% \multicolumn{1}{c}{Value 3}\tabularnewline |
| 328 |
% \hline |
| 329 |
% 2345,765 & {\mathversion{bold}} 1,6 & 21 \tabularnewline |
| 330 |
% 45,130 & 0,2 & 1,65 \tabularnewline |
| 331 |
% 543,99 & {\makebox[0mm][r]{$>{}$}}2 & 9,9 \tabularnewline |
| 332 |
% \hline |
| 333 |
% \end{tabular} |
| 334 |
% \end{verbatim} |
| 335 |
% Result: |
| 336 |
% \begin{center} |
| 337 |
% \begin{tabular}{R{4}{3}R{1}{1}R{2}{2}} |
| 338 |
% \hline |
| 339 |
% \multicolumn{1}{c}{Value 1} & \multicolumn{1}{c}{Value 2} & |
| 340 |
% \multicolumn{1}{c}{Value 3}\tabularnewline |
| 341 |
% \hline |
| 342 |
% 2345,765 & {\mathversion{bold}} 1,6 & 21 \tabularnewline |
| 343 |
% 45,130 & 0,2 & 1,65 \tabularnewline |
| 344 |
% 543,99 & {\makebox[0mm][r]{$>{}$}}2 & 9,9 \tabularnewline |
| 345 |
% \hline |
| 346 |
% \end{tabular} |
| 347 |
% \end{center} |
| 348 |
% |
| 349 |
% \item Negative values are allowed as arguments for the \texttt{R} |
| 350 |
% column. This makes it possible to round to multiples of ten, for |
| 351 |
% example, by giving `\texttt{-2}' as the second mandatory argument. |
| 352 |
% In general, rounding is performed to a precision |
| 353 |
% of $10^{-n}$, if $n$ is the second mandatory argument of |
| 354 |
% \texttt{R}. |
| 355 |
% |
| 356 |
% \item The first mandatory argument of the \texttt{R} column |
| 357 |
% specifier does not need to be the real number of digits |
| 358 |
% before the decimal point. |
| 359 |
% You can shift the output to the left or to the right by |
| 360 |
% changing this value if you are not satisfied by the centered |
| 361 |
% result. Negative values are legal. |
| 362 |
% |
| 363 |
% \item As with any macro, single token arguments can be given without |
| 364 |
% braces. This means that `"R{4}{3}"' is equivalent to `"R43"'. Maybe |
| 365 |
% you will prefer the shorter alternative. |
| 366 |
% \end{itemize} |
| 367 |
% |
| 368 |
% \section{Requirements} |
| 369 |
% The \texttt{rccol} package needs the \texttt{array}~\cite{array} |
| 370 |
% and the \texttt{fltpoint}~\cite{fltpoint} packages. |
| 371 |
% |
| 372 |
% \section{Final Remarks} |
| 373 |
% There are some open problems and desirable features concerning this |
| 374 |
% package, e.\,g.\ formatted output of numbers. However, I have ceased |
| 375 |
% using \LaTeX, so I don't think that I will make further extensions to |
| 376 |
% {\tt rccol}. You are free to do it yourself -- the license is LPPL. |
| 377 |
% Furthermore, you might be interested in the following packages, |
| 378 |
% available from CTAN if not already included in your distribution: |
| 379 |
% \begin{itemize} |
| 380 |
% \item {\tt dcolumn} of course, |
| 381 |
% \item {\tt numprint} for formatting of numbers, |
| 382 |
% \item {\tt fp} for calculations inside \TeX. |
| 383 |
% \end{itemize} |
| 384 |
% |
| 385 |
% \StopEventually{% |
| 386 |
% \begin{thebibliography}{1} |
| 387 |
% \bibitem{dcolumn} David Carlisle, ``The \texttt{dcolumn} |
| 388 |
% package''. The \texttt{dcolumn} package is part of the standard |
| 389 |
% \LaTeX\ distribution. |
| 390 |
% \bibitem{array} Frank Mittelbach, David Carlisle, ``A new |
| 391 |
% implementation of \LaTeX's \texttt{tabular} and \texttt{array} |
| 392 |
% environment''. The \texttt{array} package is part of the standard |
| 393 |
% \LaTeX\ distribution. |
| 394 |
% \bibitem{fltpoint} Eckhart Guth\"ohrlein, ``The \texttt{fltpoint} |
| 395 |
% package'', v1.1b, last revised 2004/11/12. The \texttt{fltpoint} |
| 396 |
% package is available from CTAN. |
| 397 |
% \end{thebibliography}% |
| 398 |
% } |
| 399 |
% |
| 400 |
% \section{Implementation} |
| 401 |
% |
| 402 |
% \subsection{DriverFile} |
| 403 |
% The \texttt{docstrip} utility can be used to generate |
| 404 |
% a driver file producing the documentation. |
| 405 |
% \begin{macrocode} |
| 406 |
%<*driver> |
| 407 |
\documentclass{ltxdoc} |
| 408 |
\usepackage{dcolumn} |
| 409 |
\usepackage{rccol} |
| 410 |
\AtBeginDocument{\DeleteShortVerb{\|}} % the default is not needed |
| 411 |
%\OnlyDescription % typeset only user documentation |
| 412 |
\AlsoImplementation % typeset implementation details |
| 413 |
\EnableCrossrefs % say \DisableCrossrefs if index is ready |
| 414 |
%\DisableCrossrefs |
| 415 |
\CodelineIndex % index using codeline numbers |
| 416 |
\RecordChanges % keep change log |
| 417 |
%\OldMakeindex % use if your Makeindes is pre-v2.9 |
| 418 |
\begin{document} |
| 419 |
\DocInput{rccol.dtx} |
| 420 |
\end{document} |
| 421 |
%</driver> |
| 422 |
% \end{macrocode} |
| 423 |
% |
| 424 |
% \subsection{\LaTeX\ package info and options} |
| 425 |
% \changes{v1.1b}{2000/09/08}{Added ngerman, austrian and naustrian |
| 426 |
% package options.} |
| 427 |
% \begin{macrocode} |
| 428 |
%<*rcmain> |
| 429 |
\NeedsTeXFormat{LaTeX2e} |
| 430 |
\ProvidesPackage{rccol}[2005/05/17 v1.2c right-centered columns] |
| 431 |
\DeclareOption{rounding}{\AtBeginDocument{\rcRoundingtrue}} |
| 432 |
\DeclareOption{norounding}{\AtBeginDocument{\rcRoundingfalse}} |
| 433 |
\DeclareOption{USenglish}{\AtBeginDocument{\rcDecimalSign.}} |
| 434 |
\DeclareOption{english}{\AtBeginDocument{\rcDecimalSign.}} |
| 435 |
\DeclareOption{point}{\AtBeginDocument{\rcDecimalSign.}} |
| 436 |
\DeclareOption{german}{\AtBeginDocument{\rcDecimalSign,}} |
| 437 |
\DeclareOption{ngerman}{\AtBeginDocument{\rcDecimalSign,}} |
| 438 |
\DeclareOption{austrian}{\AtBeginDocument{\rcDecimalSign,}} |
| 439 |
\DeclareOption{naustrian}{\AtBeginDocument{\rcDecimalSign,}} |
| 440 |
\DeclareOption{comma}{\AtBeginDocument{\rcDecimalSign,}} |
| 441 |
\ProcessOptions*\relax |
| 442 |
% \end{macrocode} |
| 443 |
% \subsection{Require packages} |
| 444 |
% To work properly, \texttt{rccol} needs the \texttt{array} and |
| 445 |
% the \texttt{fltpoint} packages. An up-to-date version of |
| 446 |
% \texttt{fltpoint} is necessary. |
| 447 |
% \begin{macrocode} |
| 448 |
\RequirePackage{array} |
| 449 |
\RequirePackage{fltpoint}[2004/11/12] |
| 450 |
% \end{macrocode} |
| 451 |
% |
| 452 |
% |
| 453 |
% \subsection{Registers \& Co} |
| 454 |
% |
| 455 |
% \begin{macro}{\rc@preskip} |
| 456 |
% \begin{macro}{\rc@postskip} |
| 457 |
% Allocate dimen registers "\rc@preskip" and "\rc@postskip". |
| 458 |
% \begin{macrocode} |
| 459 |
\newdimen\rc@preskip |
| 460 |
\newdimen\rc@postskip |
| 461 |
% \end{macrocode} |
| 462 |
% \end{macro} |
| 463 |
% \end{macro} |
| 464 |
% |
| 465 |
% \begin{macro}{\rc@digits} |
| 466 |
% \changes{v1.1a}{2000/09/95}{Read all digits into one register, |
| 467 |
% no more separation of pre- and afterpoint digits.} |
| 468 |
% \begin{macro}{\rc@preothertoks} |
| 469 |
% \changes{v1.1b}{2000/09/08}{Separation of other tokens inserted^^A |
| 470 |
% before and after the number, now saved in "\rc@preothertoks"^^A |
| 471 |
% and "\rc@postothertoks".} |
| 472 |
% \begin{macro}{\rc@postothertoks} |
| 473 |
% Allocate token registers "\rc@digits", "\rc@preothertoks" |
| 474 |
% and "\rc@postothertoks". |
| 475 |
% \begin{macrocode} |
| 476 |
\newtoks\rc@digits |
| 477 |
\newtoks\rc@preothertoks |
| 478 |
\newtoks\rc@postothertoks |
| 479 |
% \end{macrocode} |
| 480 |
% \end{macro} |
| 481 |
% \end{macro} |
| 482 |
% \end{macro} |
| 483 |
% |
| 484 |
% \begin{macro}{\ifrcRounding} |
| 485 |
% \changes{v1.1a}{2000/09/05}{Rounding switch prefixed with `rc'.} |
| 486 |
% Initialize "\ifrcRounding" as \texttt{true}. |
| 487 |
% \begin{macrocode} |
| 488 |
\newif\ifrcRounding |
| 489 |
\rcRoundingtrue |
| 490 |
% \end{macrocode} |
| 491 |
% \end{macro} |
| 492 |
% |
| 493 |
% |
| 494 |
% \subsection{Definition of the \texttt{R} column} |
| 495 |
% |
| 496 |
% \changes{v1.1a}{2000/09/05}{Optional parameters for the column |
| 497 |
% specifier.} |
| 498 |
% \begin{macro}{\NC@rewrite@R} |
| 499 |
% \begin{macro}{\rc@rewrite@} |
| 500 |
% \begin{macro}{\rc@rewrite@@} |
| 501 |
% \begin{macro}{\rc@rewrite@@@} |
| 502 |
% The "\newcolumntype" mechanism of \texttt{array.sty} is used |
| 503 |
% to set up the new column type. In order to have optional |
| 504 |
% parameters, the rewrite macro is redefined to take one or |
| 505 |
% two optional parameters, read by "\rc@rewrite@" and |
| 506 |
% "\rc@rewrite@@". The optional parameters are used |
| 507 |
% to change the decimal sign inside the column if this is |
| 508 |
% desired. An appropriate "\fpDecimalSign" is put into |
| 509 |
% the token registers "\rc@digits" (input) and "\rc@preothertoks" |
| 510 |
% (output), which are somewhat misused for that purpose. |
| 511 |
% The macro "\rc@rewrite@@@" reads the two mandatory arguments |
| 512 |
% (the number of digits before and after the decimal point) |
| 513 |
% and appends everything to the preamble so far. At the |
| 514 |
% end "\NC@find" is called to continue the rewriting |
| 515 |
% process (see~\cite{array} for further details). |
| 516 |
% \begin{macrocode} |
| 517 |
\newcolumntype{R}{} |
| 518 |
\def\NC@rewrite@R{% |
| 519 |
\rc@digits{}% |
| 520 |
\rc@preothertoks{}% |
| 521 |
\@ifnextchar-{\rc@rewrite}{\rc@rewrite\relax}} |
| 522 |
\def\rc@rewrite#1{% |
| 523 |
\ifx#1-% |
| 524 |
\def\rc@withsign{{\setbox0\hbox{$-$}\hskip\wd0}}% |
| 525 |
\else |
| 526 |
\def\rc@withsign{}% |
| 527 |
\fi |
| 528 |
\@ifnextchar[{\rc@rewrite@}{\rc@rewrite@@@}} |
| 529 |
\def\rc@rewrite@[#1]{% |
| 530 |
\rc@digits{\rcDecimalSignInput{#1}}% |
| 531 |
\@ifnextchar[{\rc@rewrite@@}% |
| 532 |
{\rc@preothertoks{\rcDecimalSignOutput{#1}}\rc@rewrite@@@}} |
| 533 |
\def\rc@rewrite@@[#1]{% |
| 534 |
\rc@preothertoks{\rcDecimalSignOutput{#1}}\rc@rewrite@@@} |
| 535 |
\def\rc@rewrite@@@#1#2{% |
| 536 |
\edef\rc@rewrite@scratch{\the\@temptokena>{\the\rc@digits |
| 537 |
\rc@withsign\noexpand\rc@begin}c<{\noexpand\rc@end |
| 538 |
\the\rc@preothertoks\noexpand\rc@write{#1}{#2}}} |
| 539 |
\@temptokena\expandafter{\rc@rewrite@scratch}% |
| 540 |
\NC@find} |
| 541 |
% \end{macrocode} |
| 542 |
% \end{macro} |
| 543 |
% \end{macro} |
| 544 |
% \end{macro} |
| 545 |
% \end{macro} |
| 546 |
% |
| 547 |
% |
| 548 |
% \subsection{Macros for reading and processing the numbers} |
| 549 |
% |
| 550 |
% \begin{macro}{\rc@begin} |
| 551 |
% The macro "\rc@begin" is inserted in front of every "R" alignment |
| 552 |
% entry. It initializes the token registers "\rc@digits" and |
| 553 |
% "\rc@othertoks" and calls "\rc@getnexttok" to read the following |
| 554 |
% tokens. |
| 555 |
% \begin{macrocode} |
| 556 |
\def\rc@begin{% |
| 557 |
\rc@digits={}% |
| 558 |
\rc@preothertoks={}% |
| 559 |
\rc@postothertoks={}% |
| 560 |
\let\rc@othertoks\rc@preothertoks |
| 561 |
\rc@getnexttok |
| 562 |
} |
| 563 |
% \end{macrocode} |
| 564 |
% \end{macro} |
| 565 |
% |
| 566 |
% \begin{macro}{\rc@getnexttok} |
| 567 |
% \begin{macro}{\rc@savedigit} |
| 568 |
% \begin{macro}{\rc@savetok} |
| 569 |
% The macro "\rc@getnexttok" is used to read the alignment entry |
| 570 |
% token after token. The macros "\rc@savedigit" and "\rc@savetok" |
| 571 |
% are used to store digits and other tokens in the respective |
| 572 |
% token register ("\rc@digits" or "\rc@othertoks"). |
| 573 |
% "\rc@savedigit" switches "\rc@othertoks" form |
| 574 |
% "\rc@preothertoks" to "\rc@postothertoks". |
| 575 |
% After processing the token, "\rc@next" is called |
| 576 |
% which has been "\let" equal to the appropriate next action. |
| 577 |
% \begin{macrocode} |
| 578 |
\def\rc@savedigit#1{\let\rc@othertoks\rc@postothertoks |
| 579 |
\edef\rc@scratch{\the\rc@digits#1}% |
| 580 |
\rc@digits=\expandafter{\rc@scratch}} |
| 581 |
\def\rc@savetok#1{\rc@othertoks=\expandafter{\the\rc@othertoks#1}} |
| 582 |
\def\rc@getnexttok#1{% |
| 583 |
% \end{macrocode} |
| 584 |
% First, check if "\tabularnewline" or "\rc@end" follows. |
| 585 |
% \begin{macrocode} |
| 586 |
\ifx#1\tabularnewline |
| 587 |
\let\rc@next\tabularnewline |
| 588 |
\else |
| 589 |
\ifx#1\rc@end |
| 590 |
\let\rc@next\rc@end |
| 591 |
\else |
| 592 |
% \end{macrocode} |
| 593 |
% If not, further tokens have to be read. If the current token |
| 594 |
% is allowed by the syntax of fp numbers, save it in "\rc@digits", |
| 595 |
% otherwise and if it is neither "\ignorespaces" nor "\unskip", |
| 596 |
% save it in "\rc@othertoks". |
| 597 |
% \begin{macrocode} |
| 598 |
\let\rc@next\rc@getnexttok |
| 599 |
\ifx#10\rc@savedigit#1\else\ifx#11\rc@savedigit1\else\ifx#12% |
| 600 |
\rc@savedigit2\else\ifx#13\rc@savedigit3\else\ifx#14% |
| 601 |
\rc@savedigit4\else\ifx#15\rc@savedigit5\else\ifx#16% |
| 602 |
\rc@savedigit6\else\ifx#17\rc@savedigit7\else\ifx#18% |
| 603 |
\rc@savedigit8\else\ifx#19\rc@savedigit9\else% |
| 604 |
\if\noexpand#1\rc@decimalsigninput\rc@savedigit\rc@decimalsigninput% |
| 605 |
\else\ifx#1-\rc@savedigit-\else\ifx#1+\rc@savedigit+% |
| 606 |
\else\ifx#1e\rc@savedigit e\else\ifx#1E\rc@savedigit E% |
| 607 |
\else |
| 608 |
\ifx#1\ignorespaces\else |
| 609 |
\ifx#1\unskip\else |
| 610 |
\rc@savetok{#1}% |
| 611 |
\fi |
| 612 |
\fi |
| 613 |
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi |
| 614 |
\fi |
| 615 |
\fi |
| 616 |
% \end{macrocode} |
| 617 |
% Call "\rc@next". |
| 618 |
% \begin{macrocode} |
| 619 |
\rc@next |
| 620 |
} |
| 621 |
% \end{macrocode} |
| 622 |
% \end{macro} |
| 623 |
% \end{macro} |
| 624 |
% \end{macro} |
| 625 |
% |
| 626 |
% \begin{macro}{\rc@end} |
| 627 |
% This macro marks the end of the alignment entry and reads |
| 628 |
% the contents of "\rc@digits" into a \texttt{fltpoint} register. |
| 629 |
% \begin{macrocode} |
| 630 |
\def\rc@end{\fpDecimalSign{\rc@decimalsigninput}% |
| 631 |
\fp@regread@raw{rc@temp}{\the\rc@digits}}% |
| 632 |
% \end{macrocode} |
| 633 |
% \end{macro} |
| 634 |
% |
| 635 |
% |
| 636 |
% \begin{macro}{\rc@output} |
| 637 |
% The macro "\rc@output" is called by "\rc@write". It takes one argument: |
| 638 |
% the text to be typeset. It checks if the material is to be visible, |
| 639 |
% and in this case if negative space has to be inserted, or if only |
| 640 |
% positive space with the same width as the text has to be output. |
| 641 |
% Any text to be finally output is appended to "\rc@number". |
| 642 |
% \begin{macrocode} |
| 643 |
\def\rc@output#1{% |
| 644 |
% \end{macrocode} |
| 645 |
% Set a box with the text in it to get its width. |
| 646 |
% \begin{macrocode} |
| 647 |
\setbox0=\hbox{#1}% |
| 648 |
% \end{macrocode} |
| 649 |
% If the current position is greater than the first digit of the number, |
| 650 |
% append nothing and increase "\rc@preskip". |
| 651 |
% \begin{macrocode} |
| 652 |
\ifnum\fp@loopcount>\ar@getul{rc@temp}\relax |
| 653 |
\def\rc@toappend{}% |
| 654 |
\advance\rc@preskip by \wd0 |
| 655 |
% \end{macrocode} |
| 656 |
% Similarly, if the last digit of the number has a position greater than |
| 657 |
% the actual one, do the following: if rouinding is enabled, |
| 658 |
% append "#1", if not, append nothing and increase "\rc@postskip". |
| 659 |
% \begin{macrocode} |
| 660 |
\else |
| 661 |
\ifnum\fp@loopcount<\ar@getll{rc@temp}\relax |
| 662 |
\ifrcRounding |
| 663 |
\def\rc@toappend{#1}% |
| 664 |
\else |
| 665 |
\def\rc@toappend{}% |
| 666 |
\advance\rc@postskip by \wd0 |
| 667 |
\fi |
| 668 |
% \end{macrocode} |
| 669 |
% Otherwise, append "#1". If the position is greater than the desired number of |
| 670 |
% digits before the decimal sign, decrease "\rc@preskip". Accordingly, decrease |
| 671 |
% "\rc@postskip" if necessary. |
| 672 |
% \begin{macrocode} |
| 673 |
\else |
| 674 |
\def\rc@toappend{#1}% |
| 675 |
\ifnum\fp@loopcount>\rc@outmax\relax |
| 676 |
\advance\rc@preskip by -\wd0 |
| 677 |
\else |
| 678 |
\ifnum\fp@loopcount<\rc@outmin\relax |
| 679 |
\advance\rc@postskip by -\wd0 |
| 680 |
\fi |
| 681 |
\fi |
| 682 |
\fi |
| 683 |
\fi |
| 684 |
% \end{macrocode} |
| 685 |
% Append to "\rc@number" what is to be appended. |
| 686 |
% \begin{macrocode} |
| 687 |
\edef\rc@number{\rc@number\rc@toappend}% |
| 688 |
} % end \rc@output |
| 689 |
% \end{macrocode} |
| 690 |
% \end{macro} |
| 691 |
% |
| 692 |
% \begin{macro}{\rc@write} |
| 693 |
% The macro "\rc@write" takes two arguments: the number of digits before and |
| 694 |
% after the decimal sign. |
| 695 |
% \begin{macrocode} |
| 696 |
\def\rc@write#1#2{% |
| 697 |
% \end{macrocode} |
| 698 |
% Initialize "\rc@preskip" and "\rc@postskip". Initialize "\rc@number". |
| 699 |
% \begin{macrocode} |
| 700 |
\rc@preskip=0pt |
| 701 |
\rc@postskip=0pt |
| 702 |
\def\rc@number{}% |
| 703 |
% \end{macrocode} |
| 704 |
% At the beginning, the tokens to be inserted in front of the |
| 705 |
% number, saved in "\rc@preothertoks". This gives the user the possibility |
| 706 |
% to change parameters locally for one alignment entry. |
| 707 |
% \begin{macrocode} |
| 708 |
\the\rc@preothertoks |
| 709 |
% \end{macrocode} |
| 710 |
% If rounding is enabled, do it. |
| 711 |
% \begin{macrocode} |
| 712 |
\ifrcRounding |
| 713 |
\fp@reground{rc@temp}{-#2}% |
| 714 |
\fi |
| 715 |
\fpDecimalSign{\rc@decimalsignoutput}% |
| 716 |
% \end{macrocode} |
| 717 |
% Determine start and end position for the output loop. Save the desired number |
| 718 |
% of digits in "\rc@outmax" and "\rc@outmin". The loop starts at |
| 719 |
% the desired maximal position or at the upper limit of the number, |
| 720 |
% depending on which is greater. The final value is determined accordingly. |
| 721 |
% The correction of $-1$ for "#1" |
| 722 |
% is necessary because the first digit of a number with $n$ digits before the |
| 723 |
% decimal sign means \lq multiple of $10^{(n-1)}$\rq. |
| 724 |
% \begin{macrocode} |
| 725 |
\fp@tempcount=#1\relax |
| 726 |
\advance\fp@tempcount by -1 |
| 727 |
\edef\rc@outmax{\number\fp@tempcount}% |
| 728 |
\edef\rc@outmin{\number-#2}% |
| 729 |
\fp@loopcount=\rc@outmax\relax |
| 730 |
\fp@settomax{\fp@loopcount}{\fp@loopcount}{\ar@getul{rc@temp}}% |
| 731 |
\fp@settomin{\fp@loopcountii}{\rc@outmin}{\ar@getll{rc@temp}}% |
| 732 |
% \end{macrocode} |
| 733 |
% The main loop follows. For output, "\rc@output" is used to append |
| 734 |
% anything to "\rc@number". The thousand separator is inserted in the |
| 735 |
% appropriate places, that means if |
| 736 |
% $(n\bmod3=2)\vee \left((n\bmod3=-1)\wedge (n\neq-1)\right)$ |
| 737 |
% with $n$ standing for the value of "\fp@loopcount". The decimal sign |
| 738 |
% is inserted in front of the digit if $n=-1$. |
| 739 |
% \begin{macrocode} |
| 740 |
\loop |
| 741 |
\fp@modulo{\fp@loopcount}{3}% |
| 742 |
\ifnum\fp@param=2 |
| 743 |
\rc@output{\fp@thousandsep}% |
| 744 |
\else |
| 745 |
\ifnum\fp@param=-1 |
| 746 |
\ifnum\fp@loopcount=-1\else |
| 747 |
\rc@output{\fp@thousandsep}% |
| 748 |
\fi |
| 749 |
\fi |
| 750 |
\fi |
| 751 |
\ifnum\fp@loopcount=-1 |
| 752 |
\rc@output{\rc@decimalsignoutput}% |
| 753 |
\fi |
| 754 |
\fp@getdigit{rc@temp}{\fp@loopcount}% |
| 755 |
\rc@output{\fp@param}% |
| 756 |
\ifnum\fp@loopcount>\fp@loopcountii |
| 757 |
\advance\fp@loopcount by -1 |
| 758 |
\repeat |
| 759 |
% \end{macrocode} |
| 760 |
% If the number is smaller than zero, a minus sign is put in front |
| 761 |
% of it. The usage of a token register prevents further expansion. |
| 762 |
% \begin{macrocode} |
| 763 |
\fp@regcomp{rc@temp}{@0}% |
| 764 |
\if\fp@param<% |
| 765 |
\rc@digits={\llap{$-$}}% |
| 766 |
\edef\rc@number{\the\rc@digits\rc@number}% |
| 767 |
\fi |
| 768 |
% \end{macrocode} |
| 769 |
% "\rc@number" is preceded by the computed white space |
| 770 |
% and by any tokens that have been found in the alignment entry and |
| 771 |
% stored in "\rc@preothertoks" or "\rc@postothertoks". |
| 772 |
% \begin{macrocode} |
| 773 |
\hfill |
| 774 |
\hskip\rc@preskip |
| 775 |
\rc@number |
| 776 |
\hskip\rc@postskip |
| 777 |
\the\rc@postothertoks |
| 778 |
\hfill |
| 779 |
} |
| 780 |
% \end{macrocode} |
| 781 |
% \end{macro} |
| 782 |
% |
| 783 |
% |
| 784 |
% \subsection{Parameters and configuration} |
| 785 |
% |
| 786 |
% \begin{macro}{\rcDecimalSign} |
| 787 |
% \changes{v1.1b}{2000/09/08}{Use "\def" instead of "\let".} |
| 788 |
% \begin{macro}{\rcDecimalSignInput} |
| 789 |
% \begin{macro}{\rcDecimalSignOutput} |
| 790 |
% The macros "\rcDecimalSignInput" and "\rcDecimalSignOutput" can be |
| 791 |
% used to change the default use of a comma as the decimal sign. |
| 792 |
% This can be done separately for input and output. |
| 793 |
% "\rcDecimalSign" changes both. |
| 794 |
% \begin{macrocode} |
| 795 |
\def\rcDecimalSign#1{\rcDecimalSignInput{#1}\rcDecimalSignOutput{#1}} |
| 796 |
\def\rcDecimalSignInput#1{\edef\rc@decimalsigninput{#1}} |
| 797 |
\def\rcDecimalSignOutput#1{\edef\rc@decimalsignoutput{#1}} |
| 798 |
\rcDecimalSign{,} |
| 799 |
%</rcmain> |
| 800 |
% \end{macrocode} |
| 801 |
% \end{macro} |
| 802 |
% \end{macro} |
| 803 |
% \end{macro} |
| 804 |
% |
| 805 |
% \Finale |
| 806 |
% \PrintIndex |
| 807 |
% \PrintChanges |
| 808 |
% |
| 809 |
% \endinput |