| 1 |
% \iffalse meta-comment |
| 2 |
% Copyright (C) 2015--2026 by Edgar Olthof |
| 3 |
% |
| 4 |
% This file may be distributed and/or modified under the |
| 5 |
% conditions of the LaTeX Project Public License, either |
| 6 |
% version 1.3 of this license or (at your option) any later |
| 7 |
% version. The latest version of this license is in |
| 8 |
% |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% |
| 11 |
% and version 1.3 or later is part of all distributions of |
| 12 |
% LaTeX version 1999/12/01 or later. |
| 13 |
% |
| 14 |
% \fi |
| 15 |
% \iffalse |
| 16 |
%<package>\ProvidesPackage{fcolumn} |
| 17 |
%<package> [2026/05/20 v1.4.5 Automatic Currency Package (EHTO)] |
| 18 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 19 |
%<package>\RequirePackage{array}[v2.6d] |
| 20 |
%<*driver> |
| 21 |
%\DocumentMetadata{lang=en,tagging=on} % Uncommenting this line is OK, except for |
| 22 |
% the verbatim tables (they contain the percentage sign) and for the captions in |
| 23 |
% normal tabulars (in longtable everything is fine). |
| 24 |
\documentclass{ltxdoc} |
| 25 |
\usepackage{dcolumn} |
| 26 |
\usepackage{booktabs} |
| 27 |
\usepackage[tableposition=top,aboveskip=0pt]{caption} |
| 28 |
% The next lines are a fix to the caption package, as that package is incompatible with tagging. |
| 29 |
%\RemoveFromHook{begindocument}[latex-lab-testphase-float] |
| 30 |
%\makeatletter \ExplSyntaxOn |
| 31 |
%\socket_new_plug:nnn{tagsupport/parbox/before}{caption} |
| 32 |
% {\tagpdfparaOn %restart para tagging |
| 33 |
% \tl_if_empty:NTF\@current@float@struct{\tag_struct_begin:n{tag=Caption,firstkid}} |
| 34 |
% {\tag_struct_begin:n{tag=Caption,parent=\@current@float@struct,firstkid}}} |
| 35 |
%\socket_new_plug:nnn{tagsupport/parbox/after}{caption}{\tag_struct_end:} |
| 36 |
%\l@addto@macro\caption@beginex@hook{% |
| 37 |
% \tagpdfparaOff %leavevmode in parbox should not start paragraph structure |
| 38 |
% \AssignSocketPlug{tagsupport/parbox/before}{caption} |
| 39 |
% \AssignSocketPlug{tagsupport/parbox/after}{caption}} |
| 40 |
%\ExplSyntaxOff \makeatother % End fix |
| 41 |
\DeclareCaptionStyle{normal}{labelfont={rm,bf,small},textfont={rm,small}, |
| 42 |
indention=0pt,labelsep=colon,justification=raggedright} |
| 43 |
\captionsetup[table]{style=normal} |
| 44 |
\captionsetup{singlelinecheck=false} |
| 45 |
\usepackage{url} |
| 46 |
\usepackage{eurosym} |
| 47 |
\usepackage{color} |
| 48 |
\usepackage[hang,symbol*,perpage]{footmisc} |
| 49 |
\setlength\footnotemargin{10pt} |
| 50 |
\usepackage{fcolumn} |
| 51 |
\usepackage{longtable} |
| 52 |
\EnableCrossrefs |
| 53 |
\CodelineIndex |
| 54 |
% The next definition of \LT@output is to fix a flaw in longtable.sty. |
| 55 |
% It can be removed once the fix is implemented; expected completion |
| 56 |
% date around end Q1, 2026, according to David Carlisle. |
| 57 |
\ExplSyntaxOn \makeatletter \def\LT@output{% |
| 58 |
\ifnum\outputpenalty <-\@Mi |
| 59 |
\ifnum\outputpenalty > -\LT@end@pen |
| 60 |
\LT@err{floats~ and~ marginpars~ not~ allowed~ in~ a~ longtable}\@ehc |
| 61 |
\else |
| 62 |
\setbox\z@\vbox{\unvbox\@cclv}% |
| 63 |
\ifdim \ht\LT@lastfoot>\ht\LT@foot |
| 64 |
\dimen@\pagegoal |
| 65 |
\advance\dimen@\ht\LT@foot |
| 66 |
\advance\dimen@-\ht\LT@lastfoot |
| 67 |
\ifdim\dimen@<\ht\z@ |
| 68 |
\setbox\@cclv\vbox{\unvbox\z@\copy\LT@foot |
| 69 |
% \vss % old line |
| 70 |
\vskip 0pt plus \maxdimen minus \normalbaselineskip |
| 71 |
}\@makecol |
| 72 |
\@expl@@@mark@update@singlecol@structures@@ |
| 73 |
\@outputpage |
| 74 |
\global\vsize\@colroom |
| 75 |
\setbox\z@\vbox{\box\LT@head}% |
| 76 |
\fi |
| 77 |
\fi |
| 78 |
\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi |
| 79 |
\UseTaggingSocket{tbl/longtable/foot} |
| 80 |
\fi |
| 81 |
\else |
| 82 |
\setbox\@cclv\vbox{\unvbox\@cclv\copy\LT@foot |
| 83 |
% \vss % old line |
| 84 |
\vskip 0pt plus \maxdimen minus \normalbaselineskip |
| 85 |
}\UseTaggingSocket{tbl/longtable/foot}\@makecol |
| 86 |
\@expl@@@mark@update@singlecol@structures@@ |
| 87 |
\@outputpage |
| 88 |
\global\vsize\@colroom |
| 89 |
\copy\LT@head\nobreak |
| 90 |
\fi} |
| 91 |
\makeatother \ExplSyntaxOff |
| 92 |
\begin{document} |
| 93 |
\DocInput{\jobname.dtx} |
| 94 |
\end{document} |
| 95 |
%</driver> |
| 96 |
%\fi |
| 97 |
%\RecordChanges |
| 98 |
%\CheckSum{1278} |
| 99 |
%\CharacterTable |
| 100 |
% {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 |
| 101 |
% 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 |
| 102 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 103 |
% Exclamation \! Double quote \" Hash (number) \# |
| 104 |
% Dollar \$ Percent \% Ampersand \& |
| 105 |
% Acute accent \' Left paren \( Right paren \) |
| 106 |
% Asterisk \* Plus \+ Comma \, |
| 107 |
% Minus \- Point \. Solidus \/ |
| 108 |
% Colon \: Semicolon \; Less than \< |
| 109 |
% Equals \= Greater than \> Question mark \? |
| 110 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 111 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 112 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 113 |
% Right brace \} Tilde \~} |
| 114 |
% |
| 115 |
%\changes{v0.1}{2015/02/06}{First working version.} |
| 116 |
%\changes{v1.0}{2015/03/07}{Three-argument version is working properly.} |
| 117 |
%\changes{v1.1}{2015/09/14}{Automatic checking of column balance performed when number of |
| 118 |
% F-columns is even (behaviour can be overridden). Empty entries are now recognised and |
| 119 |
% correctly treated as such, except for the one ended by the double backslash. Not serious; |
| 120 |
% workaround possible. Furthermore optimisation of code: minimised the number of private |
| 121 |
% counts and resetting of column counter done in a nicer way.} |
| 122 |
%\changes{v1.1.1}{2015/09/27}{Installation procedure changed from .ins-in-.dtx to separate |
| 123 |
% .ins and .dtx after discussion with Karl Berry, as well as some minor code improvements.} |
| 124 |
%\changes{v1.1.2}{2015/09/29}{Some inconsistencies between explanatory text and actual |
| 125 |
% code removed.} |
| 126 |
%\changes{v1.2}{2019/03/06}{Input parsing changed after comment from Frank Mittelbach. |
| 127 |
% He (Frank) also gave various suggestions for improving robustness or user friendliness |
| 128 |
% of this package. This version is only backwards compatible when zero decimal digits were |
| 129 |
% and are specified as modifier.} |
| 130 |
%\changes{v1.3}{2021/01/03}{Christian Hoff requested the possibility to provide extra formatting |
| 131 |
% information to a column, e.g., colouring. That was implemented by having an extra parameter |
| 132 |
% to the generic F-column. The current solution is not very robust, as font and/or size change |
| 133 |
% in math environment are very tricky, but providing colour information works, see the example |
| 134 |
% in the main text. This version is now compatible with package longtable and backwards |
| 135 |
% compatible to fcolumn v1.2: it only adds functionality.} |
| 136 |
%\changes{v1.4}{2021/11/21}{More robust version on the extra formatting information: alternative |
| 137 |
% formatting after the comma (if any), instead of additional information. Corrected a few typos.} |
| 138 |
%\changes{v1.4.1}{2022/02/01}{Definition needed for longtable only if that package is loaded. |
| 139 |
% General update, streamlining code. Excess digits silently ignored when all zero.} |
| 140 |
%\changes{v1.4.2}{2023/07/25}{Better documentation. Removed redundant endgroup/begingroup |
| 141 |
% pairs and other small improvements. Unbalanced columns are reported by stating their |
| 142 |
% difference. Implementation of option ``red''. No changes in user experience.} |
| 143 |
%\changes{v1.4.3}{2026/01/10}{Attempt to make fcolumn tagging-aware. Included my name and |
| 144 |
% e-mail in README (CTAN obligation). Changed makefile to produce a fcolumn.tgz that contains |
| 145 |
% files in fcolumn/. Removed some typos.} |
| 146 |
%\changes{v1.4.4}{2026/01/16}{Repair of v1.4.3, which was a complete disaster in terms of tagging, |
| 147 |
% resulting in a broken package. Hooks will be used to introduce code in array.sty and longtable.sty |
| 148 |
% instead of overwriting definitions once those Hooks are implemented there. Until that time |
| 149 |
% fcolumn falls back to the original solution of redefining three macros in those packages. |
| 150 |
% Changed makefile to produce fcolumn.zip instead of fcolumn.tgz. Changed README file: it |
| 151 |
% had extension .md in v1.4.3 but was (and is) raw ASCII.} |
| 152 |
%\changes{v1.4.5}{2026/05/20}{Intermediate version ensuring a smooth transition when going |
| 153 |
% to the 2026-06-01 LaTeX kernel.} |
| 154 |
%\GetFileInfo{fcolumn.sty} |
| 155 |
%\DoNotIndex{\@@,\@@endpbox,\@@startpbox,\@@@@endpbox,\@@@@startpbox,\@acol,\@arstrut,\@arstrutbox} |
| 156 |
%\DoNotIndex{\@classiv,\@classz,\@currentHref,\@depth,\cs,\@endpbox,\@firstampfalse,\@firstamptrue} |
| 157 |
%\DoNotIndex{\@gobble,\@halignto,\@height,\@mkpream,\@ne,\@nextchar,\@preamble,\@sharp,\@startpbox} |
| 158 |
%\DoNotIndex{\@tabacol,\@tabarray,\@tabclassiv,\@tabclassz,\@tempdima,\@tempswafalse,\@tempswatrue} |
| 159 |
%\DoNotIndex{\@temptokena,\@tfor,\@whilesw,\@width,\advance,\arraystretch,\baselineskip,\bgroup} |
| 160 |
%\DoNotIndex{\break,\count,\count@,\cr,\def,\divide,\do,\dp,\edef,\else,\egroup,\fi,\fill,\g,\global} |
| 161 |
%\DoNotIndex{\hfil,\hline,\ht,\hsize,\if,\if@firstamp,\if@tempswa,\ifcase,\ifdim,\ifnum,\ifodd,\ifx} |
| 162 |
%\DoNotIndex{\int,\kill,\lineskip,\LT@@hl,\LT@@@@hl,\LT@@tabarray,\LT@@@@tabarray,\LT@bchunk} |
| 163 |
%\DoNotIndex{\LT@caption,\LTcaptype,\LTchunksize,\LT@endpbox,\LT@hline,\LT@kill,\LT@LL@FM@cr} |
| 164 |
%\DoNotIndex{\LT@make@row,\LT@mcol,\LT@no@pgbk,\LT@nofcols,\LT@rows,\LT@setprevdepth,\LT@startpbox} |
| 165 |
%\DoNotIndex{\LT@tabularcr,\LTleft,\LTright,\let,\loop,\mathsurround,\m@ne,\message,\multiply} |
| 166 |
%\DoNotIndex{\newpage,\nopagebreak,\or,\pagebreak,\par,\prepnext@tok,\protect,\refstepcounter} |
| 167 |
%\DoNotIndex{\relax,\repeat,\rlap,\setbox,\space,\stepcounter,\string,\strutbox,\tabcolsep} |
| 168 |
%\DoNotIndex{\tabskip,\tabularnewline,\the,\theHLT@tables,\the@toks,\thr@@,\tbl,\tl,\tw@,\unhbox} |
| 169 |
%\DoNotIndex{\vbox,\vcenter,\vrule,\vskip,\vtop,\wd,\xdef,\z@,\z@skip} |
| 170 |
%\title{The \textsf{fcolumn} package\thanks{This file has version number~\fileversion, |
| 171 |
%last revised~\filedate.}} |
| 172 |
%\author{Edgar Olthof\\ |
| 173 |
%\texttt{edgar <dot> olthof <at> inter <dot> nl <dot> net}} |
| 174 |
%\date{Printed \today} |
| 175 |
%\maketitle |
| 176 |
%\begin{abstract} |
| 177 |
%\noindent In financial reports, text and currency amounts are regularly put in |
| 178 |
%one table, e.g., a year balance or a profit-and-loss overview. This |
| 179 |
%package provides the settings for automatically typesetting and checking |
| 180 |
%such columns, including the sum line (preceded by a rule of the correct |
| 181 |
%width), using the specifier |f|. |
| 182 |
%\end{abstract} |
| 183 |
% |
| 184 |
%\section{Introduction}\label{intro} |
| 185 |
%The package |fcolumn| provides the macros for an extra tabular specifier |
| 186 |
%that makes creating financial tables easy. The column specifier~|f| |
| 187 |
%itself is rather simple; it is the predefined version of a generic |
| 188 |
%column~|F|. The generic version expects four arguments: 1)~grouping |
| 189 |
%character of the integer part on output, 2)~decimal mark used on output, |
| 190 |
%3)~compact additional information on input/output characteristics, and |
| 191 |
%4)~anything, but primarily used for providing formatting information, see below. |
| 192 |
% |
| 193 |
%The f-column in the current version of the package is defined for the |
| 194 |
%continental European standard: |\newcolumntype{f}{F.,{3,2}{}}|. This |
| 195 |
%means that a number like 12345,67 will be typeset as $12{.}345{,}67$. |
| 196 |
%People in the Anglo-Saxon world would rather code |
| 197 |
%|\newcolumntype{f}{F,.{3,2}{}}| for the same input, yielding |
| 198 |
%$12{,}345{.}67$ as output for the number given above. The default |
| 199 |
%value for |#3| is |3,2|, indicating that grouping of the integer |
| 200 |
%part is by three digits, that a comma is used in the \TeX-source to |
| 201 |
%indicate the decimal mark, and that the decimal part consists of |
| 202 |
%two digits. However, if in your country or company grouping is done |
| 203 |
%with a thinspace every four digits, that the decimal mark in the |
| 204 |
%source should be the character |p|, and there are three digits after |
| 205 |
%the decimal mark---that happens to be a |\cdot|---, then simply specify |
| 206 |
%|\newcolumntype{f}{F\,\cdot{4p3}{}}| in that case. The input could |
| 207 |
%be 123456p78 then, yielding $12{\,}3456{\cdot}780$ as output. |
| 208 |
% |
| 209 |
%By default two digits are used for the decimal part, so if you really |
| 210 |
%want no decimal digits (in that case of course also skipping the decimal |
| 211 |
%mark) you have to explicitly specify~|x,0| for some~|x|. If you want no |
| 212 |
%grouping character, specify~|0,x|. |
| 213 |
% |
| 214 |
%As the fourth parameter you can insert anything just before the typesetting |
| 215 |
%of an amount in a column takes place. Its purpose is to add additional |
| 216 |
%formatting information, e.g., |\color{blue}| to have the contents of a column |
| 217 |
%coloured blue, but it can be misused, so use with care. And it can't do all! |
| 218 |
% |
| 219 |
%\floatsep=5pt plus 2pt minus 3pt |
| 220 |
%\textfloatsep=5pt plus 2pt minus 3pt |
| 221 |
%\renewcommand{\bottomfraction}{0.9} |
| 222 |
%\renewcommand{\textfraction}{0.1} |
| 223 |
%\begin{table}[htb] |
| 224 |
%\caption{Example Table.} \label{tab:fcraw} |
| 225 |
%\begin{tabular}{@{}lflf@{}} |
| 226 |
%\multicolumn4{@{}c@{}}{\bfseries Balance sheet}\\ |
| 227 |
%\toprule |
| 228 |
%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\ |
| 229 |
%\midrule |
| 230 |
%house & 200000 & equity capital & 50000 \\ |
| 231 |
%bank account & -603,23 & mortgage & 150000 \\ |
| 232 |
%savings & 28000 \\ |
| 233 |
%cash & 145,85 & profit & 27542,62 \\ |
| 234 |
%\sumline |
| 235 |
%\bottomrule |
| 236 |
%\end{tabular} |
| 237 |
%\end{table} |
| 238 |
%This package requires and loads the |array| package~\cite{array}. To |
| 239 |
%show where and how the |F|-column is used, let's look at some typical |
| 240 |
%financial information as shown in Table~\ref{tab:fcraw} |
| 241 |
%and how this is entered in \LaTeX\ (Table~\ref{tab:fcrawverb}). |
| 242 |
%\begin{table}[htb] |
| 243 |
%\caption{Verbatim version of Example Table~\ref{tab:fcraw}.} |
| 244 |
%\label{tab:fcrawverb} \topsep0pt |
| 245 |
%\begin{verbatim} |
| 246 |
%\begin{table}[htb] |
| 247 |
%\caption{Example Table.} \label{tab:fcraw} |
| 248 |
%\begin{tabular}{@{}lflf@{}} |
| 249 |
%\multicolumn4{@{}c@{}}{\bfseries Balance sheet}\\ |
| 250 |
%\toprule |
| 251 |
%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\ |
| 252 |
%\midrule |
| 253 |
%house & 200000 & equity capital & 50000 \\ |
| 254 |
%bank account & -603,23 & mortgage & 150000 \\ |
| 255 |
%savings & 28000 \\ |
| 256 |
%cash & 145,85 & profit & 27542,62 \\ |
| 257 |
%\sumline |
| 258 |
%\bottomrule |
| 259 |
%\end{tabular} |
| 260 |
%\end{table} |
| 261 |
%\end{verbatim} |
| 262 |
%\end{table} |
| 263 |
%All the work was done by the column specifier~|f| (for ``finance''). |
| 264 |
%In this case it constructs the |\sumline|, typesets the numbers, |
| 265 |
%calculates the totals, determines the widths of the sumrules, and checks |
| 266 |
%whether the two columns are in balance; if not, the user is warned via a |
| 267 |
%|\PackageWarning|. Of course for nice settings the |booktabs| |
| 268 |
%package~\cite{booktabs} was used, but that is not the point here. |
| 269 |
% |
| 270 |
%This package is heavily inspired by the |dcolumn| package by |
| 271 |
%David Carlisle~\cite{dcolumn}; some constructions are more or less |
| 272 |
%copied from that package. From version~1.3 onwards it incorporates the idea |
| 273 |
%of Christian Hoff of providing additional (formatting) information per column. |
| 274 |
%A rather contrived example is given in Table~\ref{tab:fcformat}, combining colour and fonts. |
| 275 |
%\newcolumntype{q}[1]{F.,{3,2}{#1}} |
| 276 |
%\begin{table}[htb] |
| 277 |
%\caption{Example Table with column formatting.} \label{tab:fcformat} |
| 278 |
%\begin{tabular}{@{}lq{\color{blue}\mathsf,\mathbf}lq{\color{magenta}}@{}} |
| 279 |
%\multicolumn4{@{}c@{}}{\bfseries Balance sheet}\\ |
| 280 |
%\toprule |
| 281 |
%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\ |
| 282 |
%\midrule |
| 283 |
%house & 200000 & equity capital & 50000 \\ |
| 284 |
%bank account & -603,23 & mortgage & 150000 \\ |
| 285 |
%savings & 28000 \\ |
| 286 |
%cash & 145,85 & profit & 27542,62 \\ |
| 287 |
%\sumline |
| 288 |
%\bottomrule |
| 289 |
%\end{tabular} |
| 290 |
%\end{table} |
| 291 |
%How this is entered in \LaTeX\ is shown in Table~\ref{tab:fcformatverb}. The font changing commands |
| 292 |
%like |\mathsf| and |\mathbf| act on an argument, hence require braces, |
| 293 |
%but these are already provided internally for this purpose. For that reason this |
| 294 |
%type of commands must be given last, without braces (and if you don't specify a font |
| 295 |
%changing command, these extra internal braces are just redundant). The fourth argument to the |
| 296 |
%\begin{table}[htb] |
| 297 |
%\caption{Almost verbatim version of Example Table~\ref{tab:fcformat}.} |
| 298 |
%\label{tab:fcformatverb} \topsep0pt |
| 299 |
%\begin{verbatim} |
| 300 |
%\newcolumntype{q}[1]{F.,{3,2}{#1}} |
| 301 |
%\begin{table}[htb] |
| 302 |
%\caption{Example Table with column formatting.} \label{tab:fcformat} |
| 303 |
%\begin{tabular}{@{}lq{\color{blue}\mathsf,\mathbf}lq{\color{magenta}}@{}} |
| 304 |
%\multicolumn4{@{}c@{}}{\bfseries Balance sheet}\\ |
| 305 |
%... |
| 306 |
%... (Same financial contents as in Table 1.) |
| 307 |
%... |
| 308 |
%\end{tabular} |
| 309 |
%\end{table} |
| 310 |
%\end{verbatim} |
| 311 |
%\end{table} |
| 312 |
%new columntype may consist of two parts, separated by a comma. In that case, the part to |
| 313 |
%the left of the comma is applied to the data entered by the user and the right part, if |
| 314 |
%non-empty, is the replacement formatting for the result. The example in Table~\ref{tab:fcformat} |
| 315 |
%shows this: the bold font is only used in the |\sumline| and there is no colour specification, |
| 316 |
%so that's back to the default (black). If you want formatting for the whole column, like magenta |
| 317 |
%in the case of the last column of Table~\ref{tab:fcformat}, leave out the comma. |
| 318 |
%Font size changes, e.g., ``|\huge|'' in ``|\huge\mathbf|'' |
| 319 |
%as parameter to column type |q| are ignored by \LaTeX, since the formatting |
| 320 |
%information is used in math environment, which has its own way of handling this. |
| 321 |
%This isn't bad, as size changes in one column, without overall changes to the |
| 322 |
%table look terrible. If you want something huge, make a |\huge| table. |
| 323 |
% |
| 324 |
%As will be demonstrated by Table~\ref{tab:fclong} in the next page break, the package |
| 325 |
%|fcolumn| now also works with |longtable|~\cite{longtable}, irrespective of the order |
| 326 |
%in which these packages are loaded. The raw formatting of the multipage table |
| 327 |
%is shown in Table~\ref{tab:fclongverb}. While constructing this example with tagging, |
| 328 |
%see section~\ref{tagging}, it turned out that |booktabs| caused problems that were |
| 329 |
%solved by including option |firstaid|. For more information on how to handle |\endhead| |
| 330 |
%and its ilk, see the documentation of |longtable|~\cite{longtable}. Not shown here are |
| 331 |
%the new |fcolumn| formatting possibilities (like new fonts and/or colours), but it has |
| 332 |
%been checked they do work in combination with |longtable|. The packages |
| 333 |
%|supertabular|~\cite{supertabular} and |fcolumn| also work happily together, so you can |
| 334 |
%choose which package you want if you need this. There is no race condition with |
| 335 |
%|supertabular| either. |
| 336 |
%\begin{longtable}[l]{@{}lflf@{}} |
| 337 |
%\caption{Table showing compatibility of fcolumn and |
| 338 |
% longtable.\label{tab:fclong}}\\ |
| 339 |
%\multicolumn4{@{}c@{}}{\bfseries Balance sheet}\\ |
| 340 |
%\toprule |
| 341 |
%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\ |
| 342 |
%\midrule |
| 343 |
%\endfirsthead |
| 344 |
%\caption[]{\textit{(continued from previous page)\/}}\\ |
| 345 |
%\toprule |
| 346 |
%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\ |
| 347 |
%\midrule |
| 348 |
%\endhead |
| 349 |
%\bottomrule |
| 350 |
%\multicolumn4{@{}r@{}}{\small\textit{(Table continues on |
| 351 |
% next page)\/}}\\ |
| 352 |
%\endfoot |
| 353 |
%\bottomrule |
| 354 |
%\endlastfoot |
| 355 |
%house & 200000 & equity capital & 50000 \\ |
| 356 |
%bank account & -603,23 & mortgage & 150000 \\ |
| 357 |
%savings 1 & 5600 \\ |
| 358 |
%savings 2 & 5600 \\ |
| 359 |
%savings 3 & 5600 \\ |
| 360 |
%savings 4 & 5600 \\ |
| 361 |
%savings 5 & 5600 \\ |
| 362 |
%cash & 145,85 & profit & 27542,62 \\ |
| 363 |
%\sumline |
| 364 |
%\end{longtable} |
| 365 |
% |
| 366 |
%\begin{table}[htb] |
| 367 |
%\caption{Almost verbatim version of Example Table~\ref{tab:fclong}.} |
| 368 |
%\label{tab:fclongverb} \topsep0pt |
| 369 |
%\begin{verbatim} |
| 370 |
%\begin{longtable}[l]{@{}lflf@{}} |
| 371 |
%\caption{Table showing compatibility of fcolumn and |
| 372 |
% longtable.\label{tab:fclong}}\\ |
| 373 |
%\multicolumn4{@{}c@{}}{\bfseries Balance sheet}\\ |
| 374 |
%\toprule |
| 375 |
%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\ |
| 376 |
%\midrule |
| 377 |
%\endfirsthead |
| 378 |
%\caption[]{\textit{(continued from previous page)\/}}\\ |
| 379 |
%\toprule |
| 380 |
%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\ |
| 381 |
%\midrule |
| 382 |
%\endhead |
| 383 |
%\bottomrule |
| 384 |
%\multicolumn4{@{}r@{}}{\small\textit{(Table continues on |
| 385 |
% next page)\/}}\\ |
| 386 |
%\endfoot |
| 387 |
%\bottomrule |
| 388 |
%\endlastfoot |
| 389 |
%house & 200000 & equity capital & 50000 \\ |
| 390 |
%... |
| 391 |
%... (Somewhat altered financial contents compared to |
| 392 |
%... Table 1 to demonstrate the page break.) |
| 393 |
%... |
| 394 |
%\sumline |
| 395 |
%\end{longtable} |
| 396 |
%\end{verbatim} |
| 397 |
%\end{table} |
| 398 |
%Unlike in the package |dcolumn|~\cite{dcolumn}, the alignment on the decimal mark in |
| 399 |
%|fcolumn| is achieved by right aligning numbers that all have the same number of |
| 400 |
%digits to the right of this mark, in combination with the fact that all decimal glyphs |
| 401 |
%have the same width\footnote{The so-called tabular numerals. If the font you use has |
| 402 |
%proportional numerals, the alignment won't work in general.}. This width is font specific, |
| 403 |
%so changing fonts within a column may ruin the alignment, see, e.g., the first |F|-column |
| 404 |
%in Table~\ref{tab:fcformat}. |
| 405 |
%\section{Commands} |
| 406 |
%The user only needs to know five commands and two options; these are given here. |
| 407 |
%\begin{macro}{F} |
| 408 |
%In the tabular the column specifier |F| can be given with arguments, or |
| 409 |
%the predefined version~|f|, where the four arguments of |F| are |.|, |
| 410 |
%|,|, |{3,2}|, and |{}|. If you want |g| to be your own definition like the |
| 411 |
%curious one given in Section~\ref{intro}, then specify |
| 412 |
%|\newcolumntype{g}{F\,\cdot{4p3}{}}| prior to using |g| in a tabular. |
| 413 |
% |
| 414 |
%Entries in an |F|-column are, from that moment on, treated as numbers unless |
| 415 |
%explicitly escaped by |\leeg|, see below. The numbers are typeset |
| 416 |
%according to the template the user gives with his/her |F|-column. |
| 417 |
%The ``middle'' character of |#3| is an important switch: it does more |
| 418 |
%than just setting the input decimal mark. By default the input grouping |
| 419 |
%character is the dot, except when the dot is specified as input decimal |
| 420 |
%mark; in that case the comma is acting as input grouping character. With |
| 421 |
%this convention continental Europe and the Anglo-Saxon part of the world are |
| 422 |
%served. This is hard coded, but using input grouping characters is optional anyway. |
| 423 |
%\end{macro} |
| 424 |
%\begin{macro}{\sumline} |
| 425 |
%The numbers in an |F|-column are typeset as a financial amount, but the real |
| 426 |
%benefit comes with the |\sumline|. It does three things: |
| 427 |
%\iffalse This used to be done with compactenum from paralist but that package |
| 428 |
%is not compatible with tagging \fi |
| 429 |
% |
| 430 |
%\begingroup \hangindent=12pt \hangafter=1 |
| 431 |
%\noindent 1)~It calculates and shows the total of the column so far and the maximum |
| 432 |
% width encountered so far, including the width of the total; |
| 433 |
% |
| 434 |
%\hangindent=12pt \hangafter=1 |
| 435 |
%\noindent 2)~It generates a rule with width calculated in the first item; |
| 436 |
% |
| 437 |
%\hangindent=12pt \hangafter=1 |
| 438 |
%\noindent 3)~It checks the columns that are supposed to balance whether or not |
| 439 |
% they actually do. If so, nothing happens. Otherwise a |\PackageWarning| is |
| 440 |
% given that column~$i$ and~$j$ do not balance, where $i$ and $j$ are the relevant |
| 441 |
% columns. This is only done automatically if the total number of |F|-columns |
| 442 |
% is even, e.g., if there are six |F|-columns, then~1 is checked against~4, 2 |
| 443 |
% against~5, and 3 against~6. If the number of |F|-columns is odd then anything |
| 444 |
% could be possible in that table and nothing is assumed about structure within |
| 445 |
% the table. This behaviour can be overridden, see below. |
| 446 |
% |
| 447 |
%\endgroup |
| 448 |
%By default the vertical separation between the rule and the total is |
| 449 |
%2\thinspace pt, but this can be changed by the optional argument to |
| 450 |
%|\sumline|. Give, e.g., |\sumline[10pt]|, in case you want this spacing |
| 451 |
%to be 10\thinspace pt. And you may even give two options, like in |
| 452 |
%|\sumline[10pt][5pt]|, in which the second option is the extra space below |
| 453 |
%the summary row. In fact that second option is parsed to |\\|, that is |
| 454 |
%implicit in |\sumline|. |
| 455 |
%\end{macro} |
| 456 |
%\begin{macro}{\resetsumline} |
| 457 |
%Suppose you want to typeset one tabular with the profit-and-loss of many |
| 458 |
%projects individually. In case the layout of those tabulars is similar it |
| 459 |
%were nice if all columns were aligned. This can be done by making it one |
| 460 |
%big tabular with a fresh start for each project. The macro |\resetsumline| |
| 461 |
%is used for that: it resets all totals and all column widths, see for example |
| 462 |
%Table~\ref{tab:fcmult}. |
| 463 |
%\begin{table}[htb] |
| 464 |
%\caption{Example: multiple projects.} \label{tab:fcmult} |
| 465 |
%\begin{tabular}{@{}lfflff@{}} |
| 466 |
%\multicolumn6{@{}c@{}}{\bfseries Project~1}\\ |
| 467 |
%\toprule |
| 468 |
%expense & \leeg{actual} & \leeg{budget} & |
| 469 |
%income & \leeg{actual} & \leeg{budget} \\ |
| 470 |
%\midrule |
| 471 |
%food & 450,20 & 500 & tickets & 1200 & 1000 \\ |
| 472 |
%drinks & 547,5 & 400 \\ |
| 473 |
%music & 180 & 100 \\ |
| 474 |
%profit & 22,3 \\ |
| 475 |
%\sumline[2pt][10pt] |
| 476 |
%\resetsumline |
| 477 |
%\multicolumn6{@{}c@{}}{\bfseries Project~2}\\ |
| 478 |
%\toprule |
| 479 |
%expense & \leeg{actual} & \leeg{budget} & |
| 480 |
%income & \leeg{actual} & \leeg{budget} \\ |
| 481 |
%\midrule |
| 482 |
%food & 250 & 300 & tickets & 400 & 450 \\ |
| 483 |
%drinks & 100 & 80 \\ |
| 484 |
%music & 80 & 70 & loss & 30 \\ |
| 485 |
%\sumline |
| 486 |
%\bottomrule |
| 487 |
%\end{tabular} |
| 488 |
%\end{table} |
| 489 |
%Note that the rules in the first and third |F|-columns of Project~1 cover |
| 490 |
%$1{.}200{,}00$ whereas in Project~2 those rules are narrower since they |
| 491 |
%only cover $430{,}00$; still the columns are aligned (similar story for |
| 492 |
%|F|-columns two and four). The verbatim way of setting up Table~\ref{tab:fcmult} |
| 493 |
%is given in Table~\ref{tab:fcmultverb}. |
| 494 |
%\begin{table}[htb] |
| 495 |
%\caption{Verbatim version of Table~\ref{tab:fcmult}.} |
| 496 |
%\label{tab:fcmultverb} \topsep0pt |
| 497 |
%\begin{verbatim} |
| 498 |
%\begin{table}[htb] |
| 499 |
%\caption{Example: multiple projects.} \label{tab:fcmult} |
| 500 |
%\begin{tabular}{@{}lfflff@{}} |
| 501 |
%\multicolumn6{@{}c@{}}{\bfseries Project~1}\\ |
| 502 |
%\toprule |
| 503 |
%expense & \leeg{actual} & \leeg{budget} & |
| 504 |
%income & \leeg{actual} & \leeg{budget} \\ |
| 505 |
%\midrule |
| 506 |
%food & 450,20 & 500 & tickets & 1200 & 1000 \\ |
| 507 |
%drinks & 547,5 & 400 \\ |
| 508 |
%music & 180 & 100 \\ |
| 509 |
%profit & 22,3 \\ |
| 510 |
%\sumline[2pt][10pt] |
| 511 |
%\resetsumline |
| 512 |
%\multicolumn6{@{}c@{}}{\bfseries Project~2}\\ |
| 513 |
%\toprule |
| 514 |
%expense & \leeg{actual} & \leeg{budget} & |
| 515 |
%income & \leeg{actual} & \leeg{budget} \\ |
| 516 |
%\midrule |
| 517 |
%food & 250 & 300 & tickets & 400 & 450 \\ |
| 518 |
%drinks & 100 & 80 \\ |
| 519 |
%music & 80 & 70 & loss & 30 \\ |
| 520 |
%\sumline |
| 521 |
%\bottomrule |
| 522 |
%\end{tabular} |
| 523 |
%\end{table} |
| 524 |
%\end{verbatim} |
| 525 |
%\end{table} |
| 526 |
%\end{macro} |
| 527 |
%\begin{macro}{\leeg} |
| 528 |
%If an |F|-column should be empty then simply leave it empty. If, however, it is |
| 529 |
%not empty but the entry should be treated as text---even if it is a number---, |
| 530 |
%this can be done with |\leeg|. It expects an argument and this argument is |
| 531 |
%typeset in the column. The common case is where |p.m.| (\textit{pro memoria}) |
| 532 |
%is entered or in column headers. |
| 533 |
%\end{macro} |
| 534 |
%\begin{macro}{\checkfcolumns} |
| 535 |
%The automatic column balance check can also be done manually. If |
| 536 |
%|F|-columns~1 and~4 should balance and you want them to be checked, |
| 537 |
%then simply say |\checkfcolumns14|. With more than nine |F|-columns |
| 538 |
%you may be forced to say something like |\checkfcolumns{10}{12}|. If |
| 539 |
%|\checkfcolumns| is used, the automatic check is disabled. Multiple |
| 540 |
%|\checkfcolumns|s are supported; if |F|-columns~1, 2, and~3 should |
| 541 |
%balance, you specify |\checkfcolumns12| and |\checkfcolumns23|. |
| 542 |
%There is no explicit command to disable all checking, but |
| 543 |
%|\checkfcolumns11| obviously does the trick, at the expense of |
| 544 |
%some trivial calculations. |
| 545 |
%\end{macro} |
| 546 |
%\begin{macro}{\ifstrict@ccounting} |
| 547 |
%\begin{macro}{\ifminusr@d} |
| 548 |
%In the rare occasion that a negative number occurs in a financial table, |
| 549 |
%the sign of that number can be an explicit minus sign, i.e.,~`$-$' or the |
| 550 |
%number is coloured red, or it is typeset between parentheses, and there |
| 551 |
%may be even other ways. By default (for aesthetic reasons) |fcolumn| |
| 552 |
%typesets it with a minus~sign, but strict accounting prescribes that the |
| 553 |
%number should be put between parentheses. The latter can be accomplished |
| 554 |
%by setting |\strict@ccountingtrue|, but since this contains a non-letter, |
| 555 |
%it is more \LaTeX-like to invoke |fcolumn| with the option |strict|, i.e., |
| 556 |
%|\usepackage[strict]{fcolumn}|, which sets this flag. If you want the |
| 557 |
%negative numbers to be coloured red, use the option |red|, i.e., |
| 558 |
%|\usepackage[red]{fcolumn}|, but note that |strict| and |red| |
| 559 |
%are mutually exclusive: if both are used, |red| is reset because |
| 560 |
%|strict| is strict. |
| 561 |
%\end{macro} |
| 562 |
%\end{macro} |
| 563 |
%\section{Tagging}\label{tagging} |
| 564 |
%Additional code for making tagged PDF~\cite{tagging} is available by |
| 565 |
%generating the style file with option ``tagging''. If you don't want |
| 566 |
%this or if your \TeX-distribution doesn't support tagging (yet), it |
| 567 |
%is possible to exclude these lines. This is still highly experimental, |
| 568 |
%and to properly process the document you are reading now you can't |
| 569 |
%use tagging by having |\DocumentMetadata| as first line, because |ltxdoc| |
| 570 |
%doesn't work well with tagging (a next version will be done with |l3doc|; |
| 571 |
%it has been checked that that works fine). For ``normal'' documents, |
| 572 |
%e.g., using |\documentclass{article}| you can start with |
| 573 |
%|\DocumentMetadata{tagging=on}| as first line, see the example file |
| 574 |
%fcexample.tex, that is also included in the distribution. |
| 575 |
%In this version the math-tagging is switched off again in |
| 576 |
%the |F|-columns of a |tabular| environment, since the math there is fake math. |
| 577 |
%\StopEventually{\PrintChanges\PrintIndex} |
| 578 |
%\section{The macros} |
| 579 |
%Here follows the actual code; most users will stop reading here, but |
| 580 |
%some examples that may be interesting are presented below. Previous |
| 581 |
%versions can be loaded for not-up-to-date systems, but v1.4.3 is lacking |
| 582 |
%here, because it had a severe bug. |
| 583 |
% \begin{macrocode} |
| 584 |
\DeclareRelease{v1.4.2}{2023-07-25}{fcolumn-2023-07-25.sty} |
| 585 |
\DeclareRelease{v1.4.4}{2026-01-26}{fcolumn-2026-01-16.sty} |
| 586 |
\DeclareCurrentRelease{v1.4.5}{2026-05-20} |
| 587 |
\NeedsTeXFormat{LaTeX2e}[2025/06/01] |
| 588 |
% \end{macrocode} |
| 589 |
%\subsection{Options} |
| 590 |
%\begin{macro}{option red} |
| 591 |
%\begin{macro}{option strict} |
| 592 |
%There are two options. If |red| is set, negative numbers are displayed in red. |
| 593 |
%If |strict| is set, strict accounting rules are used in display and this overrules |
| 594 |
%a possibly set |red|. Depending on the two booleans associated with these options |
| 595 |
%the |color| package~\cite{color} will be loaded or not. |
| 596 |
% \begin{macrocode} |
| 597 |
\newif\ifminusr@d \minusr@dfalse |
| 598 |
\newif\ifstrict@ccounting \strict@ccountingfalse |
| 599 |
\DeclareOption{red}{\minusr@dtrue} |
| 600 |
\DeclareOption{strict}{\strict@ccountingtrue} |
| 601 |
\ProcessOptions \ifminusr@d \ifstrict@ccounting \minusr@dfalse |
| 602 |
\PackageWarningNoLine{fcolumn}{Option `red' is reset due to use |
| 603 |
of `strict'}\else\usepackage{color}\fi\fi |
| 604 |
% \end{macrocode} |
| 605 |
%\end{macro} |
| 606 |
%\end{macro} |
| 607 |
%\subsection{Definitions} |
| 608 |
%\begin{macro}{column F} |
| 609 |
%\begin{macro}{column f} |
| 610 |
%The column specifier |F| is the generic one, and |f| is the default |
| 611 |
%(continental European) one for easy use. Note that the definition of the |
| 612 |
%column type |f| does not use private macros (no~|@|), so overriding its |
| 613 |
%definition is easy for a user. |
| 614 |
% \begin{macrocode} |
| 615 |
\newcolumntype{F}[4]{>{\b@fi{#1}{#2}{#3}{#4}}r<{\e@fi}} |
| 616 |
\newcolumntype{f}{F.,{3,2}{}} |
| 617 |
% \end{macrocode} |
| 618 |
%\end{macro} |
| 619 |
%\end{macro} |
| 620 |
%\begin{macro}{\FCsc@l} |
| 621 |
%\begin{macro}{\FCtc@l} |
| 622 |
%Two \meta{count}s are defined, that both start at zero: the \meta{count} |
| 623 |
%|\FCsc@l|, that keeps track at which |F|-column the tabular is working on |
| 624 |
%and the \meta{count} |\FCtc@l|, that records the number of |F|-columns |
| 625 |
%that were encountered so far in the document. Later in the package the |
| 626 |
%code can be found for generating a new \meta{count} and a new \meta{dimen} |
| 627 |
%if the number of requested |F|-columns is larger than currently available. |
| 628 |
%This is of course the case when an |F|-column is used for the first time. |
| 629 |
% \begin{macrocode} |
| 630 |
\newcount\FCsc@l \FCsc@l=0 \newcount\FCtc@l \FCtc@l=0 |
| 631 |
% \end{macrocode} |
| 632 |
%\end{macro} |
| 633 |
%\end{macro} |
| 634 |
%\begin{macro}{\geldm@cro} |
| 635 |
%The macro |\geldm@cro| takes a number and by default interprets this as |
| 636 |
%an amount expressed in cents (dollar cents, euro cents, centen, Pfennige, |
| 637 |
%centimes, kopecks, groszy) and typesets it as the amount in entire |
| 638 |
%currency units (dollars, euros, guldens, Marke, francs, rubles, z\l oty) |
| 639 |
%with comma as decimal mark and the dot as grouping character |
| 640 |
%(thousand separator if the first part of |#1| is~3). |
| 641 |
%As explained, this can be changed. It uses three private booleans: |
| 642 |
%|\ifwiths@p|, |\ifstrict@ccounting|, and |\ifminusr@d|. The latter two |
| 643 |
%are used to typeset negative numbers in a special way. By default it |
| 644 |
%doesn't do this: a minus sign is used. |
| 645 |
% \begin{macrocode} |
| 646 |
\newif\ifwiths@p |
| 647 |
% \end{macrocode} |
| 648 |
%Actually |\geldm@cro| is only a wrapper around |\g@ldm@cro|. |
| 649 |
% \begin{macrocode} |
| 650 |
\def\geldm@cro#1#2{\withs@pfalse |
| 651 |
\afterassignment\g@ldm@cro\count@#1\relax{#2}} |
| 652 |
% \end{macrocode} |
| 653 |
%\end{macro} |
| 654 |
%\begin{macro}{\g@ldm@cro} |
| 655 |
%After setting the environment for formatting, this macro starts by looking |
| 656 |
%at the sign of |#2|: if it is negative, it prints the correct indicator (a parenthesis, |
| 657 |
%a minus sign, or nothing at all in case of |red|), assigns the absolute value |
| 658 |
%of~|#2| to |\count2| and goes on. Note that |\geldm@cro| and therefore |\g@ldm@cro| |
| 659 |
%are always used within |$|s, so it is really a minus sign that is printed, not a hyphen. |
| 660 |
%All calculations are done with |\count0|, |\count1|, etc., i.e., without |F|-column-specific |
| 661 |
%\meta{count}s because it is all done locally. Leaving the tabular environment will |
| 662 |
%restore their values. This is also true for the effect of |\FCform@t|, so that |
| 663 |
%formatting information is local to this column. The reason for inserting the |{| |
| 664 |
%between |\FCform@t| and |\ifnum| (and the accompanying |}| just before finishing |
| 665 |
%this definition) is to facilitate the possible use of |\mathbf| or any other font |
| 666 |
%changing command as the last item in |\FCform@t|. |
| 667 |
% |
| 668 |
%When |\FCform@t| includes a colour change, this is overruled for negative numbers |
| 669 |
%when option |red| is set. For that reason it is unwise to use a red colour for the |
| 670 |
%whole column in combination with the option |red|: sign information is obscured then. |
| 671 |
% \begin{macrocode} |
| 672 |
\def\g@ldm@cro#1\relax#2{\ifstrict@ccounting\def\bm@nus{(} |
| 673 |
\def\em@nus{)}\else\def\em@nus{}\ifminusr@d\def\bm@nus{\color{red}} |
| 674 |
\else\def\bm@nus{-}\fi\fi\FCform@t{\ifnum#2<0 \bm@nus\count2=-#2 |
| 675 |
\else\count2=#2 \fi |
| 676 |
% \end{macrocode} |
| 677 |
%Calculate the entire currency units: this is the result of $x/a$ as integer |
| 678 |
%division, with $a=10^n$ and $n$ the part of |#1| after the separator (if any). |
| 679 |
%Here the first character of |#1| is discarded, so the separator in |#1| is not strict: |
| 680 |
%you could also specify |3.2| instead of |3,2| (or even |3p2|). |
| 681 |
% \begin{macrocode} |
| 682 |
\count4=\ifx\relax#1\relax 2 \else\@gobble#1\relax\fi |
| 683 |
\count3=0 |
| 684 |
\loop\ifnum\count3<\count4 |
| 685 |
\divide\count2 by 10 \advance\count3 by \@ne |
| 686 |
\repeat |
| 687 |
% \end{macrocode} |
| 688 |
%Note that |\count3| now equals |\count4|: this going up-and-down will be used more often, |
| 689 |
%it saves several assignments. The value in |\count2| is then output by |\g@ldens| using |
| 690 |
%the separation given (and stored in |\count@|). |
| 691 |
% \begin{macrocode} |
| 692 |
\g@ldens{\the\count@}% |
| 693 |
% \end{macrocode} |
| 694 |
%If there is a decimal part\dots |
| 695 |
% \begin{macrocode} |
| 696 |
\ifnum\count3>0 {\decim@lmark} |
| 697 |
% \end{macrocode} |
| 698 |
%Next the decimal part is dealt with. Now $x\bmod a$ is calculated in the |
| 699 |
%usual way: $x-(x/a)*a$ with integer division. The minus sign necessary |
| 700 |
%for this calculation is introduced in the next line by changing the |
| 701 |
%comparison from |<| to |>|. |
| 702 |
% \begin{macrocode} |
| 703 |
\ifnum#2>0 \count2=-#2\else\count2=#2 \fi |
| 704 |
\loop\ifnum\count3>0 |
| 705 |
\divide\count2 by 10 \advance\count3 by \m@ne |
| 706 |
\repeat |
| 707 |
% \end{macrocode} |
| 708 |
%The value of |\count3| is now~0, so counting up again. |
| 709 |
% \begin{macrocode} |
| 710 |
\loop\ifnum\count3<\count4 |
| 711 |
\multiply\count2 by 10 \advance\count3 by \@ne |
| 712 |
\repeat |
| 713 |
\ifnum#2>0 \advance\count2 by #2 |
| 714 |
\else \advance\count2 by -#2 |
| 715 |
\fi |
| 716 |
\zerop@d{\number\count3}{\number\count2}% |
| 717 |
\fi |
| 718 |
% \end{macrocode} |
| 719 |
%If the negative number is indicated by putting it between parentheses, |
| 720 |
%then the closing parenthesis should stick out of the column, otherwise |
| 721 |
%the alignment of this entry in the column is wrong. This is done by an |
| 722 |
%|\rlap| and therefore does not influence the column width. For the rightmost |
| 723 |
%column this means that this parenthesis may even stick out of the table. |
| 724 |
%I don't like this, therefore I chose to put |\strict@ccountingfalse|. |
| 725 |
%Change if you like, by setting the option |strict|. |
| 726 |
% |
| 727 |
%If overflow was detected, an exclamation mark is output to the right of |
| 728 |
%the value that caused this. This of course ruins the appearance of the |
| 729 |
%table, but in this case that serves a clear goal: there's something wrong |
| 730 |
%and you should know. |
| 731 |
% \begin{macrocode} |
| 732 |
\ifx\FCs@gn\m@ne\ifnum#2<0 \rlap{\em@nus~!} |
| 733 |
\else\rlap{\phantom{\em@nus}~!}\fi |
| 734 |
\else\ifnum#2<0 \rlap{\em@nus}\fi\fi}} |
| 735 |
% \end{macrocode} |
| 736 |
% \end{macro} |
| 737 |
%\begin{macro}{\g@ldens} |
| 738 |
%Here the whole currency units are dealt with. The macro |\g@ldens| is |
| 739 |
%used recursively, therefore the double braces; this allows to use |
| 740 |
%|\count0| locally. This also implies that tail recursion is not |
| 741 |
%possible here, but that is not very important, as the largest number |
| 742 |
%(which is $2^{31}-1$) will only cause a threefold recursion using the |
| 743 |
%default |3,2| (ninefold when using~|1,0|, but who does that?). The |
| 744 |
%largest amount this package can deal with is therefore 2.147.483.647 |
| 745 |
%(using |3,0|). For most people this is probably more than enough if |
| 746 |
%the currency is euros or dollars. And otherwise clearly state that you |
| 747 |
%use a currency unit of~k\EUR{} (or even M\EUR{} for the very rich). |
| 748 |
% |
| 749 |
%There is no obvious interpretation of |#1| being zero or negative, |
| 750 |
%therefore this is used as an indicator that no grouping character should be used. |
| 751 |
% \begin{macrocode} |
| 752 |
\def\g@ldens#1{{\count3=\count2 \count0=#1 |
| 753 |
% \end{macrocode} |
| 754 |
%First divide by $10^n$, where $n$ is |#1|. |
| 755 |
% \begin{macrocode} |
| 756 |
\ifnum\count0<1 \count0=3 \fi |
| 757 |
\loop \ifnum\count0>0 \divide\count2 by 10 \advance\count0 by \m@ne |
| 758 |
\repeat |
| 759 |
% \end{macrocode} |
| 760 |
%Here is the recursive part, |
| 761 |
% \begin{macrocode} |
| 762 |
\ifnum\count2>0 \g@ldens{#1}\fi |
| 763 |
% \end{macrocode} |
| 764 |
%and then reconstruct the rest of the number. |
| 765 |
% \begin{macrocode} |
| 766 |
\count0=#1 |
| 767 |
\ifnum\count0<1 \count0=3 \fi |
| 768 |
\loop \ifnum\count0>0 \multiply\count2 by 10 \advance\count0 by \m@ne |
| 769 |
\repeat |
| 770 |
\count2=-\count2 |
| 771 |
\advance\count2 by \count3 \du@zendprint{#1}}} |
| 772 |
% \end{macrocode} |
| 773 |
%\end{macro} |
| 774 |
%\begin{macro}{\du@zendprint} |
| 775 |
%The macro |\du@zendprint| takes care of correctly printing the separator |
| 776 |
%and possible trailing zeros. The former, however, is only done if |#1| |
| 777 |
%is larger than zero. |
| 778 |
% \begin{macrocode} |
| 779 |
\def\du@zendprint#1{\ifwiths@p\ifnum#1>0 {\sep@rator}\fi |
| 780 |
\zerop@d{#1}{\number\count2}% |
| 781 |
\else\zerop@d1{\number\count2}\fi\global\withs@ptrue} |
| 782 |
% \end{macrocode} |
| 783 |
%\end{macro} |
| 784 |
%\begin{macro}{\zerop@d} |
| 785 |
%The macro |\zerop@d| uses at least |#1| digits for printing the |
| 786 |
%number |#2|, padding with zeros when necessary. Note: |#1| being |
| 787 |
%zero or negative is a flag that it should be interpreted as 3. |
| 788 |
%A bit ugly, but it works, since the related code knows about this. |
| 789 |
% |
| 790 |
%It is done within an extra pair of braces, so that |\count0| |
| 791 |
%and |\count1| can be used without disturbing their values in other macros. |
| 792 |
% \begin{macrocode} |
| 793 |
\def\zerop@d#1#2{{\count0=1 \count1=#2 |
| 794 |
% \end{macrocode} |
| 795 |
%First determine the number of digits of |#2| (expressed in the decimal |
| 796 |
%system). This number is in |\count0| and is at least~1. |
| 797 |
% \begin{macrocode} |
| 798 |
\loop \divide \count1 by 10 \ifnum\count1>0 \advance\count0 by \@ne |
| 799 |
\repeat |
| 800 |
% \end{macrocode} |
| 801 |
%If |#1| is positive, the number of zeros to be padded is the maximum |
| 802 |
%of~0 and |#1-\count0| (the latter can be negative), so a |
| 803 |
%simple loop suffices. If it is zero or negative, this is a signal |
| 804 |
%that it should be interpreted as 3 (and no separator will be output). |
| 805 |
% \begin{macrocode} |
| 806 |
\ifnum#1>0 \loop\ifnum\count0<#1\relax 0\advance\count0 by \@ne |
| 807 |
\repeat\else\advance\count0 by -3 |
| 808 |
\loop\ifnum\count0<0 0\advance\count0 by \@ne \repeat |
| 809 |
\fi\number#2}} |
| 810 |
% \end{macrocode} |
| 811 |
%\end{macro} |
| 812 |
%\begin{macro}{\zetg@ld} |
| 813 |
%This macro takes care of several things: it increases the subtotal for a |
| 814 |
%given |F|-column, it checks whether or not that subtotal has overflown, it |
| 815 |
%records the largest width of the entries in that column and it typesets |
| 816 |
%|#1| via |\geldm@cro|. |
| 817 |
% \begin{macrocode} |
| 818 |
\def\zetg@ld#1#2{\count0=#2\relax \let\FCs@gn=\@ne |
| 819 |
% \end{macrocode} |
| 820 |
%First it checks whether there is a risk of overflow in this step. If |
| 821 |
%$A$ and $B$ are two \TeX-registers and $B$ is to be added to $A$, |
| 822 |
%overflow cannot occur if 1)~one is (or both are) zero or 2)~if $A$ and~$B$ |
| 823 |
%have different signs; otherwise be careful. Note that \TeX\ does not |
| 824 |
%check for overflow when performing an |\advance| (done in section~1238 |
| 825 |
%of Ref.~\cite{CandTB}), in contrast to |\multiply|, see section~105. |
| 826 |
% \begin{macrocode} |
| 827 |
\ifnum\count0<0 \ifnum\csname FCtot@\romannumeral\FCsc@l\endcsname<0 |
| 828 |
\let\FCs@gn=\m@ne \fi\fi |
| 829 |
\ifnum\count0>0 \ifnum\csname FCtot@\romannumeral\FCsc@l\endcsname>0 |
| 830 |
\let\FCs@gn=\m@ne \fi\fi |
| 831 |
\global\advance\csname FCtot@\romannumeral\FCsc@l\endcsname by \count0 |
| 832 |
\ifx\FCs@gn\m@ne |
| 833 |
% \end{macrocode} |
| 834 |
%They have the same sign, hence risk of overflow. Record the sign |
| 835 |
%of |\count0| (and of the original total of this column; we just established |
| 836 |
%they were the same) in |\FCs@gn|. Table~\ref{tab:fcoverflow} |
| 837 |
%\begin{table}[htb] |
| 838 |
%\def\PackageError#1#2#3{\PackageWarning{#1}{#2: #3}} |
| 839 |
%\caption{Examples on overflow.} |
| 840 |
%\label{tab:fcoverflow} |
| 841 |
%\begin{tabular}{@{}lfff@{}} |
| 842 |
%\multicolumn4{@{}c@{}}{\bfseries Projects}\\ |
| 843 |
%\toprule |
| 844 |
%income & \leeg{31 dec 2014} & \leeg{31 dec 2015} & \leeg{31 dec 2016} \\ |
| 845 |
%\midrule |
| 846 |
%item~1 & 20000000 & 20000000 & 20000000 \\ |
| 847 |
%item~2 & 10000000 & 2000000 & -1500000 \\ |
| 848 |
%item~3 & 5000000 & -1500000 & 2000000 \\ |
| 849 |
%\checkfcolumns23 |
| 850 |
%\sumline |
| 851 |
%\bottomrule |
| 852 |
%\end{tabular} |
| 853 |
%\end{table} |
| 854 |
%shows what can go wrong if the numbers are too large: in the left |
| 855 |
%|F|-column the sumline is incorrect and the number that caused |
| 856 |
%the overflow is indicated by an exclamation mark. In the middle |
| 857 |
%|F|-column, overflow occurs twice and because this is once positive, |
| 858 |
%once negative here, cancellation of errors occurs and the sumline |
| 859 |
%is correct in the end. Nevertheless, it is advised to swap the two |
| 860 |
%items that caused the overflow, as shown in the right |F|-column. |
| 861 |
% |
| 862 |
%Check that the sign of the updated column total is still correct. |
| 863 |
%If so, |\FCs@gn| is reset (to |\@ne|) at the end of this chunk. |
| 864 |
% \begin{macrocode} |
| 865 |
\ifnum\count0>0 \let\FCs@gn\@ne \fi |
| 866 |
\count0=\csname FCtot@\romannumeral\FCsc@l\endcsname |
| 867 |
\ifnum\FCs@gn<0 \count0=-\count0 \fi |
| 868 |
\ifnum\count0<0 |
| 869 |
\let\FCs@gn=\m@ne |
| 870 |
\PackageError{fcolumn}{Register overflow}{Overflow occurred in |
| 871 |
fcolumn \number\FCsc@l\space near or at line \the\inputlineno. |
| 872 |
You can press\MessageBreak <enter> now and I'll proceed, but |
| 873 |
check your table. The offending entry\MessageBreak is indicated |
| 874 |
with an exclamation mark in the output.}% |
| 875 |
\else\let\FCs@gn=\@ne |
| 876 |
\fi |
| 877 |
\fi |
| 878 |
% \end{macrocode} |
| 879 |
%The value of |\FCs@gn| is used in |\geldm@cro| below. |
| 880 |
% \begin{macrocode} |
| 881 |
\setbox0=\hbox{$\geldm@cro{#1}{#2}$}% |
| 882 |
\ifdim\wd0>\csname FCwd@\romannumeral\FCsc@l\endcsname |
| 883 |
\global\csname FCwd@\romannumeral\FCsc@l\endcsname=\wd0 |
| 884 |
\fi\unhbox0} |
| 885 |
% \end{macrocode} |
| 886 |
%\end{macro} |
| 887 |
% |
| 888 |
%The \meta{count}s |\FC@l| and |\FC@r| capture the parts to the left and to the |
| 889 |
%right of the decimal mark, respectively. |
| 890 |
% \begin{macrocode} |
| 891 |
\newcount\FC@l \newcount\FC@r |
| 892 |
% \end{macrocode} |
| 893 |
%Some auxiliary definitions for capturing compacted information. |
| 894 |
% \begin{macrocode} |
| 895 |
\def\setucc@de#1#2\relax{\uccode`\~=`#1 } |
| 896 |
\def\assignform@t#1,#2,#3\assignform@t{\def\FCform@t{#1}% |
| 897 |
\def\FCform@tt{#2}\ifx\FCform@tt\@empty \def\FCform@tt{#1}\fi} |
| 898 |
% \end{macrocode} |
| 899 |
%\begin{macro}{\m@thcodeswitch} |
| 900 |
%As will be shown below, once the first digit, or sign, or decimal mark, or |
| 901 |
%grouping character is scanned, the decimal digits should loose their activeness. |
| 902 |
%That is done here for the digits in a rather blunt way, by putting their |
| 903 |
%|\mathcode|s to zero if |#1| equals~0, since the actual |\mathcode| is not |
| 904 |
%important---as long as it is not |"8000|---because the digits are not used for |
| 905 |
%typesetting. (And even if they were; it's inside |\box0|, whose contents will be |
| 906 |
%discarded.) When the |$| in |\e@fi| is encountered, the digits get back their |
| 907 |
%original |\mathcode|s so that the actual typesetting in |\zetg@ld| is correct again. |
| 908 |
%With a non-zero |#1| the activeness is switched on. |
| 909 |
% \begin{macrocode} |
| 910 |
\def\m@thcodeswitch#1{\count0=10 \loop\ifnum\count0>0 |
| 911 |
\advance\count0 by \m@ne\mathcode\expandafter`\the\count0= |
| 912 |
\ifnum#1=0 0 \else "8000 \fi\repeat} |
| 913 |
% \end{macrocode} |
| 914 |
%\end{macro} |
| 915 |
%\def\<#1>{\leavevmode\hbox{$\langle$#1\/$\rangle$}} |
| 916 |
%\begin{macro}{\b@fi} |
| 917 |
%The macro |\b@fi| provides the beginning of the financial column. It |
| 918 |
%will be inserted in the column to capture the number entered by the user. |
| 919 |
%The separator and decimal mark are within a math environment, so you |
| 920 |
%can indeed specify |\,| instead of |\thinspace|, but there are extra |
| 921 |
%braces around them in the code where they are used, so it doesn't |
| 922 |
%affect the spacing between the digits (trick copied from |dcolumn|, |
| 923 |
%Ref.~\cite{dcolumn}). |
| 924 |
% \begin{macrocode} |
| 925 |
\def\b@fi#1#2#3#4{\sep@xt#1\sep@xt\def\decim@lmark{#2}\def\sp@l{#3} |
| 926 |
\assignform@t#4,,\assignform@t\global\advance\FCsc@l by \@ne |
| 927 |
\global\FC@l=0 \global\FC@r=1 |
| 928 |
% \end{macrocode} |
| 929 |
%The next statement is missing in |\@array| (see section~\ref{adaptations}) |
| 930 |
%for good reasons; it indicates to the tagging engine that what follows is |
| 931 |
%fake math, not to be tagged. But for |fcolumn| that's exactly what's going |
| 932 |
%on, so include it here, but only in columns with specifier~|F|, i.e., |
| 933 |
%in the current macro. |
| 934 |
% \begin{macrocode} |
| 935 |
%<*tagging> |
| 936 |
\m@th |
| 937 |
%</tagging> |
| 938 |
% \end{macrocode} |
| 939 |
%The value specified by the user is then captured by |\FC@l| and |
| 940 |
%this is done in a special way: |\FC@l| is assigned globally within |
| 941 |
%|\box0|. Why? To use it as scribbling paper to examine what the |
| 942 |
%user entered, without dumping it into the horizontal list. |
| 943 |
% |
| 944 |
%There are four parts to an |F|-column entry, all parts optional, |
| 945 |
%making 16 combinations. The sequence is |
| 946 |
%(in the Backus--Naur notation of Ref.~\cite{CandTA}): |
| 947 |
%\<sign> \<integer constant> \<decimal mark> |
| 948 |
%\<integer constant>. Here \<sign> is a plus or minus character with |
| 949 |
%category code~12, \<integer constant> is a sequence of zero |
| 950 |
%or more (decimal) \<digit>s, and \<decimal mark> is the middel |
| 951 |
%part of |#3|, i.e., the comma in |3,2| or the period in |3.2|. If |
| 952 |
%the \<decimal mark> is absent with no space characters between the |
| 953 |
%two \<integer constant> terms, these merge, making four redundant |
| 954 |
%entries. One of the combinations is \<empty>, a sequence of characters |
| 955 |
%outside the ones that are made active, e.g., plain text or nothing at all: |
| 956 |
%this is the only combination that doesn't put anything in an |F|-column---and |
| 957 |
%was the most difficult part to handle. |
| 958 |
% |
| 959 |
%The minus sign must be captured separately, because in an entry like |
| 960 |
%|-0,07| the 7~cents are negative, but this cannot be seen from the |
| 961 |
%part to the left of the decimal mark, since $-0$ is~$0$ in \TeX\ (in |
| 962 |
%fact in most computer languages, but not in~MIX~\cite{TAOCP1}), so |
| 963 |
%|\ifnum-0<0| yields |false|. |\FCs@gn| is a general purpose flag. Its |
| 964 |
%first use is to capture the sign. |
| 965 |
% \begin{macrocode} |
| 966 |
\let\FCs@gn=\@ne\relax \setbox0\hbox\bgroup$ |
| 967 |
% \end{macrocode} |
| 968 |
%Do the scan inside a box and inside math mode. Start with defining all |
| 969 |
%characters that may appear as the first one in an |F|-column as active; |
| 970 |
%digits first. This needs a complicated |\edef| with accompanying |\noexpand| |
| 971 |
%because the starting digit for |\FC@l| must be packed inside each definition. |
| 972 |
% \begin{macrocode} |
| 973 |
\count@=10 \loop\ifnum\count@>0 \advance\count@ by \m@ne |
| 974 |
\uccode`\~=\expandafter`\the\count@ \uppercase{\edef~}{\noexpand |
| 975 |
\m@thcodeswitch0 \global\FC@l=\the\count@}\repeat |
| 976 |
% \end{macrocode} |
| 977 |
%For the input decimal mark something extra is needed: if it is the |
| 978 |
%first character in an |F|-column (like in |,07|), it should also |
| 979 |
%restore the |\mathcode|s of the digits. Checking whether or not it |
| 980 |
%is the first is easy, since in that case the |\mathcode|s of the |
| 981 |
%decimal digits are still |"8000|. The assignment to |\FC@r| starts |
| 982 |
%with~1 (with no space following), so that appended digits get captured |
| 983 |
%correctly, even if they start with~0; postprocessing of |\FC@r| is done |
| 984 |
%in |\e@fi|. The input decimal mark switches itself off as active |
| 985 |
%character, so at most one input decimal mark is allowed (N.B.: |
| 986 |
%this makes sense). |
| 987 |
% \begin{macrocode} |
| 988 |
\afterassignment\setucc@de\count@#3\relax |
| 989 |
\uppercase{\def~}{\ifnum\mathcode`\0="8000 \m@thcodeswitch0 \fi |
| 990 |
\afterassignment\deactdecm@rk\count@#3\relax \global\FC@r=1} |
| 991 |
% \end{macrocode} |
| 992 |
%The input grouping character effectively expands to ``nothing, i.e., |
| 993 |
%ignore'' in a complicated way: it ignores the character and resumes |
| 994 |
%scanning the number. The test prior to that action is needed if |
| 995 |
%the grouping character is the first character encountered in the |
| 996 |
%|F|-column. Which part to continue with depends on whether or not an |
| 997 |
%input decimal mark was encountered; that can be checked by looking |
| 998 |
%at its |\mathcode|. |
| 999 |
% |
| 1000 |
%The input grouping character is the dot ``|.|'', except when that character |
| 1001 |
%was already chosen as input decimal mark. In that case, the grouping |
| 1002 |
%character will be the comma. This is easy to check because the |\uccode| |
| 1003 |
%of |`\~| is still preserved. |
| 1004 |
% \begin{macrocode} |
| 1005 |
\ifnum\uccode`\~=`. \uccode`\~=`,\relax\else \uccode`\~=`.\relax\fi |
| 1006 |
\uppercase{\def~}{\ifnum\mathcode`\0="8000 \m@thcodeswitch0 \fi |
| 1007 |
\afterassignment\d@cm\count@#3\relax |
| 1008 |
% \end{macrocode} |
| 1009 |
%The |\expandafter| below is necessary because the global assignment |
| 1010 |
%should act after the |\fi|. |
| 1011 |
% \begin{macrocode} |
| 1012 |
\ifnum\count@=\mathcode`- \expandafter\global\FC@l=\the\FC@l |
| 1013 |
\else \expandafter\global\FC@r=\the\FC@r\fi}% |
| 1014 |
% \end{macrocode} |
| 1015 |
%The signs are relatively simple: record the sign, restore |\mathcode|s if |
| 1016 |
%needed (it should be: a minus sign between digits screws up everything), |
| 1017 |
%and start scanning the number. |
| 1018 |
% \begin{macrocode} |
| 1019 |
\uccode`\~=`+\relax \uppercase{\def~}{\ifnum\mathcode`\0="8000 |
| 1020 |
\m@thcodeswitch0 \fi\global\FC@l=0} |
| 1021 |
\uccode`\~=`-\relax \uppercase{\def~}{\ifnum\mathcode`\0="8000 |
| 1022 |
\m@thcodeswitch0 \fi\global\let\FCs@gn\m@ne \global\FC@l=0} |
| 1023 |
% \end{macrocode} |
| 1024 |
%Now actually activate all these codes. |
| 1025 |
% \begin{macrocode} |
| 1026 |
\mathcode`-="8000 \mathcode`+="8000 \mathcode`.="8000 |
| 1027 |
% \end{macrocode} |
| 1028 |
%These three remain active until the |$| in |\e@fi| is encountered. |
| 1029 |
%The following ones will, except in the \<empty> case, have their activeness |
| 1030 |
%turned off at some time. |
| 1031 |
% \begin{macrocode} |
| 1032 |
\m@thcodeswitch1 \afterassignment\actdecm@rk\count@#3\relax} |
| 1033 |
% \end{macrocode} |
| 1034 |
%\end{macro} |
| 1035 |
%\begin{macro}{\sep@xt} |
| 1036 |
%\begin{macro}{\actdecm@rk} |
| 1037 |
%\begin{macro}{\deactdecm@rk} |
| 1038 |
%\begin{macro}{\d@cm} |
| 1039 |
%Again a few small macros to do important work. At first |\sep@xt| to extract |
| 1040 |
%the first character of |#1|, which in most cases will be the only character. |
| 1041 |
%Then |\actdecm@rk| and |\deactdecm@rk| to activate and deactive respectively the |
| 1042 |
%decimal mark. Finally, |\d@cm| captures a |\mathcode| for further investigation. |
| 1043 |
% \begin{macrocode} |
| 1044 |
\def\sep@xt#1#2\sep@xt{\def\sep@rator{#1}} |
| 1045 |
\def\actdecm@rk#1#2\relax{\ifx#1.\relax \mathcode`,="8000 |
| 1046 |
\else \mathcode`#1="8000 \fi} |
| 1047 |
\def\deactdecm@rk#1#2\relax{\mathcode`#1=0 }% |
| 1048 |
\def\d@cm#1#2{\count@=\mathcode`#1 } |
| 1049 |
% \end{macrocode} |
| 1050 |
%\end{macro} |
| 1051 |
%\end{macro} |
| 1052 |
%\end{macro} |
| 1053 |
%\end{macro} |
| 1054 |
%\begin{macro}{\e@fi} |
| 1055 |
%If the digits are still active then either nothing, or only |
| 1056 |
%characters that did not deactivate the digits were entered. In |
| 1057 |
%both cases the output should be \<empty>. To flag this situation outside |
| 1058 |
%the group that started with the opening |$| of |\b@fi|, |\FC@r| is set |
| 1059 |
%globally to a negative value. This doesn't harm, because it didn't |
| 1060 |
%contain relevant information anyway. Outside the group, the sign |
| 1061 |
%of |\FC@r| can be tested then. This is a slight misuse of this |
| 1062 |
%|\count|, but now it's documented. In effect, |\FC@r| can only be~$-1$, |
| 1063 |
%1, or at least~10, so the comparison |\ifnum\FC@r>0| does not miss~0. |
| 1064 |
% \begin{macrocode} |
| 1065 |
\def\e@fi{\ifnum\mathcode`\0="8000 \global\FC@r=\m@ne\fi$\egroup |
| 1066 |
\ifnum\FC@r>0 |
| 1067 |
% \end{macrocode} |
| 1068 |
%If there was no decimal mark or if there was a decimal mark but no |
| 1069 |
%decimal part, |\FC@r| will still be~1, which doesn't parse well with |
| 1070 |
%|\secd@xt|, so a zero is appended, i.e., yielding~|10|. |
| 1071 |
% \begin{macrocode} |
| 1072 |
\ifnum\FC@r=1 \FC@r=10 \fi |
| 1073 |
% \end{macrocode} |
| 1074 |
%Next is a loop for bringing the decimal part in the correct way to |
| 1075 |
%the integer part. This loop is performed the number of decimal |
| 1076 |
%digits to be printed (the~2 in |3,2| of the default setting). The higher |
| 1077 |
%this number is, e.g., 6~when |3,6| is chosen as |#3|---but who does that?---, |
| 1078 |
%the lower the maximum initial value for |\FC@l| can be, before a low-level |
| 1079 |
%\TeX\ arithmetic overflow will occur, so don't overdo it. |
| 1080 |
% \begin{macrocode} |
| 1081 |
\afterassignment\i@ts\count@\sp@l |
| 1082 |
\loop\ifnum\count0>0 \multiply\FC@l by 10 \expandafter\secd@xt |
| 1083 |
\number\FC@r\secd@xt \advance\count0 by \m@ne \repeat |
| 1084 |
% \end{macrocode} |
| 1085 |
%This also means that if more decimal digits than this are provided, the excess |
| 1086 |
%digit(s) will not be handled. This is truncation, not rounding! If all |
| 1087 |
%truncated digits are zero, this truncation is exact and they are silently ignored, |
| 1088 |
%see the example Table~\ref{tab:fctrunc}, |
| 1089 |
%\begin{table}[htb] |
| 1090 |
%\newcolumntype{d}{D,,{-1}} |
| 1091 |
%\caption{Truncating excess digits.} |
| 1092 |
%\label{tab:fctrunc} |
| 1093 |
%\begin{tabular}{@{}ldfl@{}} |
| 1094 |
%\toprule |
| 1095 |
%composer & \multicolumn1c{raw entry} & \leeg{debt} & remark \\ |
| 1096 |
%\midrule |
| 1097 |
%Berg & 123,450 & 123,450 & silently ignoring digit ``0'' \\ |
| 1098 |
%Eisler & 234,563 & 234,563 & warning: digit ``3'' ignored \\ |
| 1099 |
%Sch\"onberg & 345,6704 & 345,6704 & warning: digits ``04'' ignored \\ |
| 1100 |
%Webern & 2,3456 & 2,3456 & warning: digits ``56'' ignored, i.e.,\\ |
| 1101 |
% & & & \quad without rounding this entry to 2,35 \\ |
| 1102 |
%\sumline |
| 1103 |
%\bottomrule |
| 1104 |
%\end{tabular} |
| 1105 |
%\end{table} |
| 1106 |
%that was created with |@{}ldfl@{}| (|d| for centering on the decimal |
| 1107 |
%mark~\cite{dcolumn}) as tabular key. If, however, at least one of them is |
| 1108 |
%not zero, a |\PackageWarning| will be given, showing the discarded digit(s). |
| 1109 |
%There is nothing magical about the constant~19 below: it is simply the |
| 1110 |
%concatenation of~|1| and the largest decimal digit. The smallest next value |
| 1111 |
%that |\FC@r| can have is~100, so all values from~19 up to and including~99 |
| 1112 |
%would have worked here. |
| 1113 |
% \begin{macrocode} |
| 1114 |
\ifnum\expandafter\@gobble\number\FC@r>0 |
| 1115 |
\PackageWarning{fcolumn}{Excess digit\ifnum\FC@r>19 s\fi\space |
| 1116 |
``\expandafter\tw@l\number\FC@r\relax'' in decimal part |
| 1117 |
\MessageBreak ignored near or} |
| 1118 |
\fi |
| 1119 |
% \end{macrocode} |
| 1120 |
%Don't forget to correct for the sign (once this is done, |\FCs@gn| |
| 1121 |
%is free again and can and will be used for other purposes). |
| 1122 |
%Then output the result. |
| 1123 |
% \begin{macrocode} |
| 1124 |
\ifx\FCs@gn\m@ne\relax\FC@l=-\FC@l\fi\zetg@ld{\sp@l}{\FC@l}\fi} |
| 1125 |
% \end{macrocode} |
| 1126 |
%\end{macro} |
| 1127 |
%\begin{macro}{\i@ts} |
| 1128 |
%\begin{macro}{\tw@l} |
| 1129 |
%Macro |\e@fi| uses two very tiny macros, given here. In previous versions |
| 1130 |
%these were defined inside |\e@fi|, so they also got undefined when |\e@fi| |
| 1131 |
%ended. The current solution makes execution a bit faster. |
| 1132 |
% \begin{macrocode} |
| 1133 |
\def\i@ts#1#2{\count0=#2} \def\tw@l#1#2\relax{#2} |
| 1134 |
% \end{macrocode} |
| 1135 |
%\end{macro} |
| 1136 |
%\end{macro} |
| 1137 |
%\begin{macro}{\secd@xt} |
| 1138 |
%The second digit from the left is needed from a string of characters |
| 1139 |
%representing a decimal number (that should be at least 10 and start with |
| 1140 |
%a~|1|, but that is guaranteed by |\e@fi|). The macro |\secd@xt| extracts |
| 1141 |
%that digit, which is then added to |\FC@l|. A new number is assigned to |
| 1142 |
%|\FC@r|, that consists of the digits of |1#2|, unless |#2| was empty; in |
| 1143 |
%that case~10 is assigned. In this way |\FC@r| is prepared for insertion |
| 1144 |
%in the next invocation of |\secd@xt|. In iterating: 1234 yields~134, |
| 1145 |
%yields~14, yields~10, stays~10, etc. |
| 1146 |
% \begin{macrocode} |
| 1147 |
\def\secd@xt1#1#2\secd@xt{\advance\FC@l by #1 |
| 1148 |
\FC@r=1#2 \ifnum\FC@r=1 \FC@r=10 \fi} |
| 1149 |
% \end{macrocode} |
| 1150 |
%\end{macro} |
| 1151 |
%\subsection{The sumline, close to a postamble} |
| 1152 |
%\begin{macro}{\@mksumline} |
| 1153 |
%The construction of the sumline is much easier than that of the preamble (see |
| 1154 |
%Section~\ref{adaptations}) for several reasons. It may be safely assumed that |
| 1155 |
%the preamble specifier is grammatically correct because it has already been |
| 1156 |
%screened by |\@mkpream|. Furthermore, most entries will simply add nothing |
| 1157 |
%to |\s@ml@ne|, e.g., |@|, |!|, and \verb+|+ can be fully ignored. Ampersands |
| 1158 |
%are only inserted by |c|, |l|, |r|, |p|, |m|, and |b|. So, if |\x| is a macro |
| 1159 |
%that prints the desired result of the column (see below), then a specifier |
| 1160 |
%like |lflf| will yield the sumline |&\x&&\x\\|. Had the specifier been |
| 1161 |
%\verb+l|f||@{ }l|f+, then the same sumline must be constructed: all |
| 1162 |
%difficulties are already picked up and solved in the creation of the preamble. |
| 1163 |
% |
| 1164 |
%In reality the sumline must be constructed from the expanded form of the |
| 1165 |
%specifier, so |@{}lf@{}| will expand as |
| 1166 |
%|@{}l>{\b@fi.,{3,2}{}}r<{\e@fi}@{}|. The rules for constructing the |
| 1167 |
%\begingroup \parskip0pt |
| 1168 |
%\iffalse Clumsy way to have bulleted items because package paralist |
| 1169 |
% is not compatible with tagging \fi |
| 1170 |
%sumline are now very simple: |
| 1171 |
% |
| 1172 |
%\setbox0\hbox{$\bullet$~} |
| 1173 |
%\noindent\copy0 add an ampersand when |c|, |l|, |r|, |p|, |m|, or |b| is found, |
| 1174 |
%unless it is the first one (this \hbox to \wd0{\hfil}is the same as in the preamble); |
| 1175 |
% |
| 1176 |
%\noindent\copy0 add a |\x| when |<{\e@fi}| is found; |
| 1177 |
% |
| 1178 |
%\noindent\copy0 ignore everything else; |
| 1179 |
% |
| 1180 |
%\noindent\box0 close with a |\\|. |
| 1181 |
% |
| 1182 |
%\noindent (For completeness' sake it should be mentioned that prior to the |\\| also the column |
| 1183 |
%\endgroup |
| 1184 |
%check is inserted, see |\aut@check|.) |
| 1185 |
%To discriminate, a special version of |\@testpach|~\cite{array} |
| 1186 |
%could be written, but that is not necessary: |\@testpach| can do all the work, |
| 1187 |
%although much of it will be discarded. Here speed is sacrificed for space |
| 1188 |
%and this can be afforded because the creation of the sumline is done only |
| 1189 |
%once per |tabular| or |longtable|. |
| 1190 |
% |
| 1191 |
%The start is copied from |\@mkpream|. |
| 1192 |
% \begin{macrocode} |
| 1193 |
\def\@mksumline#1{\gdef\s@ml@ne{}\@lastchclass 4 \@firstamptrue |
| 1194 |
% \end{macrocode} |
| 1195 |
%At first the column number is reset and the actual code for what was |
| 1196 |
%called |\x| above is made inactive. |
| 1197 |
% \begin{macrocode} |
| 1198 |
\global\FCsc@l=0 \let\prr@sult=\relax |
| 1199 |
% \end{macrocode} |
| 1200 |
%Then |\@mkpream| is picked up again. |
| 1201 |
% \begin{macrocode} |
| 1202 |
\@temptokena{#1}\@tempswatrue\@whilesw\if@tempswa\fi{\@tempswafalse |
| 1203 |
\the\NC@list}\count0\m@ne\let\the@toks\relax\prepnext@tok |
| 1204 |
% \end{macrocode} |
| 1205 |
%Next is the loop over all tokens in the expanded form of the specifier. The change |
| 1206 |
%with respect to |\@mkpream| is that the body of the loop is now only dealing |
| 1207 |
%with F-classes~0, 2, and 10. What to do in those cases is of course different from |
| 1208 |
%what to do when constructing the preamble, so special definitions are created, see |
| 1209 |
%below. |
| 1210 |
% \begin{macrocode} |
| 1211 |
\expandafter\@tfor\expandafter\@nextchar\expandafter:\expandafter=\the |
| 1212 |
\@temptokena\do{\@testpach\ifcase\@chclass\@classfz\or\or\@classfii\or |
| 1213 |
\or\or\or\or\or\or\or\@classfx\fi\@lastchclass\@chclass}% |
| 1214 |
% \end{macrocode} |
| 1215 |
%And the macro is finished by applying the |\aut@check| and appending the |
| 1216 |
%|\\| to the sumline. Note that the |\aut@check| is performed {\itshape |
| 1217 |
%in\/} the last column, but since it does not put anything in the |
| 1218 |
%horizontal list---it only writes to screen and transcript file---, this |
| 1219 |
%is harmless. |
| 1220 |
% \begin{macrocode} |
| 1221 |
\xdef\s@ml@ne{\s@ml@ne\noexpand\aut@check\noexpand\\}} |
| 1222 |
% \end{macrocode} |
| 1223 |
%\end{macro} |
| 1224 |
%\begin{macro}{\@addtosumline} |
| 1225 |
%Macro |\@addtosumline|, as its name already suggests, adds something to the |
| 1226 |
%sumline, like its counterpart |\@addtopreamble| did to the preamble. |
| 1227 |
% \begin{macrocode} |
| 1228 |
\def\@addtosumline#1{\xdef\s@ml@ne{\s@ml@ne #1}} |
| 1229 |
% \end{macrocode} |
| 1230 |
%\end{macro} |
| 1231 |
%\begin{macro}{\@classfx} |
| 1232 |
%Class~f10 for the sumline creation is a stripped down version of |\@classx|: add an |
| 1233 |
%ampersand unless it is the first. It deals with the specifiers |b|, |m|, |p|, |c|, |
| 1234 |
%|l|, and |r|. |
| 1235 |
% \begin{macrocode} |
| 1236 |
\def\@classfx{\if@firstamp \@firstampfalse \else \@addtosumline &\fi} |
| 1237 |
% \end{macrocode} |
| 1238 |
%\end{macro} |
| 1239 |
%\begin{macro}{\@classfz} |
| 1240 |
%Class~f0 is applicable for specifiers |c|, |l|, and |r|, and if the arguments |
| 1241 |
%of |p|, |m|, or |b| are given. The latter three cases, with |\@chnum| is 0, |
| 1242 |
%1, or~2 should be ignored and the first three cases are now similar to class~f10. |
| 1243 |
% \begin{macrocode} |
| 1244 |
\def\@classfz{\ifnum\@chnum<\thr@@ \@classfx\fi} |
| 1245 |
% \end{macrocode} |
| 1246 |
% \end{macro} |
| 1247 |
%\begin{macro}{\@classfii} |
| 1248 |
%Here comes the nice and nasty part. Class~f2 is applicable if a~|<| is |
| 1249 |
%specified. This is tested by checking |\@lastchclass|, which should be |
| 1250 |
%equal to~8. Then it is checked that the argument to |<| is indeed |
| 1251 |
%|\e@fi|. This check is rather clumsy but this was the first way, after |
| 1252 |
%many attempts, that worked. It is necessary because the usage of |<| |
| 1253 |
%is not restricted to |\e@fi|: the user may have specified other |
| 1254 |
%\LaTeX-code using~|<|. |
| 1255 |
% \begin{macrocode} |
| 1256 |
\def\@classfii{\ifnum\@lastchclass=8 |
| 1257 |
\edef\t@stm{\expandafter\string\@nextchar} |
| 1258 |
\edef\t@stn{\string\e@fi} \ifx\t@stm\t@stn |
| 1259 |
% \end{macrocode} |
| 1260 |
%If both tests yield |true|, i.e., we encountered a |<{\e@fi}| where |
| 1261 |
%we expect one to find, then add the macro to typeset everything (this |
| 1262 |
%is what was mentioned |\x| above for brevity). |
| 1263 |
% \begin{macrocode} |
| 1264 |
\@addtosumline{\prr@sult} |
| 1265 |
% \end{macrocode} |
| 1266 |
%But we're not done yet: in the following lines of code the appropriate |
| 1267 |
%\meta{count}s and \meta{dimen}s are created, if necessary. Note that |
| 1268 |
%|\FCsc@l| was set to~0 in the beginning of |\@mksumline|, so it is |
| 1269 |
%well-defined when |\@classfii| is used. |
| 1270 |
% \begin{macrocode} |
| 1271 |
\global\advance\FCsc@l by \@ne \ifnum\FCsc@l>\FCtc@l |
| 1272 |
% \end{macrocode} |
| 1273 |
%Apparently the number of requested columns is larger than the currently |
| 1274 |
%available number of relevant \meta{count}s and \meta{dimen}s, so new ones |
| 1275 |
%should be created. What is checked here is merely the existence of |
| 1276 |
%|\FCtot@<some romannumeral>|. If it already exists---although it may not |
| 1277 |
%even be a \meta{count}; that cannot be checked---it is not created by |
| 1278 |
%|fcolumn| and an error is given. In case it is a \meta{count} you're just |
| 1279 |
%lucky, and you could ignore that error, although any change to this |
| 1280 |
%\meta{count} is global anyway, so things will be overwritten. In the |
| 1281 |
%case it is not a \meta{count}, things will go haywire and you'll soon |
| 1282 |
%find out. The remedy then is to rename your \meta{count} prior to |
| 1283 |
%|fcolumn| to avoid this name clash. |
| 1284 |
% \begin{macrocode} |
| 1285 |
\expandafter\ifx\csname FCtot@\romannumeral\FCsc@l\endcsname\relax |
| 1286 |
\expandafter\newcount\csname FCtot@\romannumeral\FCsc@l\endcsname |
| 1287 |
\else |
| 1288 |
\PackageError{fcolumn}{Name clash for <count>}{\expandafter\csname |
| 1289 |
FCtot@\romannumeral\FCsc@l\endcsname is already defined and it may |
| 1290 |
not even be a <count>. If you're\MessageBreak sure it is a <count>, |
| 1291 |
you can press <enter> now and I'll proceed, but things\MessageBreak |
| 1292 |
will get overwritten.}% |
| 1293 |
\fi |
| 1294 |
% \end{macrocode} |
| 1295 |
%And the same is applicable for the \meta{dimen}: in case of a name |
| 1296 |
%clash you have to rename your \meta{dimen} prior to |fcolumn|. |
| 1297 |
% \begin{macrocode} |
| 1298 |
\expandafter\ifx\csname FCwd@\romannumeral\FCsc@l\endcsname\relax |
| 1299 |
\expandafter\newdimen\csname FCwd@\romannumeral\FCsc@l\endcsname |
| 1300 |
% \end{macrocode} |
| 1301 |
%If the creation was successful, the \meta{count} |\FCtc@l| should be |
| 1302 |
%increased. |
| 1303 |
% \begin{macrocode} |
| 1304 |
\global\FCtc@l=\FCsc@l |
| 1305 |
\else |
| 1306 |
\PackageError{fcolumn}{Name clash for <dimen>}{\expandafter\csname |
| 1307 |
FCwd@\romannumeral\FCsc@l\endcsname is already defined and it may |
| 1308 |
not even be a <dimen>. If you're\MessageBreak sure it is a <dimen>, |
| 1309 |
you can press <enter> now and I'll proceed, but things\MessageBreak |
| 1310 |
will get overwritten.}% |
| 1311 |
\fi |
| 1312 |
\fi |
| 1313 |
\fi |
| 1314 |
\fi} |
| 1315 |
% \end{macrocode} |
| 1316 |
%Once created, it is not necessary to initialise them here because that |
| 1317 |
%is done later in one go. |
| 1318 |
%\end{macro} |
| 1319 |
%\begin{macro}{\sumline} |
| 1320 |
%The command for the sumline has one optional argument: the separation |
| 1321 |
%between the rule and the total. By default this is 2\thinspace pt, but |
| 1322 |
%the user may, e.g., specify |\sumline[10pt]| if that separation needs to be |
| 1323 |
%10\thinspace pt. The assignment needs to be global, because it is done |
| 1324 |
%in the first column of the tabular, but is valid for the whole line. |
| 1325 |
% \begin{macrocode} |
| 1326 |
\newdimen\s@mlinesep |
| 1327 |
\def\sumline{\@ifnextchar[\s@mline{\s@mline[2pt]}} |
| 1328 |
\def\s@mline[#1]{\global\s@mlinesep=#1 \s@ml@ne} |
| 1329 |
% \end{macrocode} |
| 1330 |
%In the introduction it was stated that |\sumline| has two options, but in |
| 1331 |
%reality that second option is the option to |\\|, that is issued by |\s@ml@ne|. |
| 1332 |
%\end{macro} |
| 1333 |
%\begin{macro}{\prr@sult} |
| 1334 |
%The macro |\prr@sult| actually puts the information together. It starts |
| 1335 |
%like |\leeg|. |
| 1336 |
% \begin{macrocode} |
| 1337 |
\def\prr@sult{$\egroup \let\e@fi=\relax \let\FCform@t=\FCform@tt |
| 1338 |
% \end{macrocode} |
| 1339 |
%Then the information for the last line is computed. It is not sufficient |
| 1340 |
%to calculate the width of the result (in points) to use that as the width |
| 1341 |
%of the rule separating the individual entries and the result. It may happen |
| 1342 |
%that the sum is wider (in points) than any of the entries, e.g., when the |
| 1343 |
%result of $6+6$ (using specifier~|3,2|) is typeset. The width of the rule |
| 1344 |
%should be equal to the width of |\hbox{$12{,}00$}| then. On the other |
| 1345 |
%hand the width of the rule when summing $24$ and $-24$ should be that of |
| 1346 |
%|\hbox{$-24{,}00$}| (or |\hbox{$(24{,}00$}|, see above), not the width of |
| 1347 |
%the result |\hbox{$0{,}00$}|. Therefore the maximum of all entry widths, |
| 1348 |
%including the result, was calculated. This excludes the extension to the |
| 1349 |
%right in case parentheses are used, again for aesthetic reasons. |
| 1350 |
% \begin{macrocode} |
| 1351 |
\setbox0=\hbox{$\geldm@cro{\sp@l}{\number\csname |
| 1352 |
FCtot@\romannumeral\FCsc@l\endcsname}$}% |
| 1353 |
\ifdim\wd0>\csname FCwd@\romannumeral\FCsc@l\endcsname |
| 1354 |
\global\csname FCwd@\romannumeral\FCsc@l\endcsname=\wd0 |
| 1355 |
\fi |
| 1356 |
\vbox{\hrule width \csname FCwd@\romannumeral\FCsc@l\endcsname |
| 1357 |
\vskip\s@mlinesep |
| 1358 |
\hbox to \csname FCwd@\romannumeral\FCsc@l\endcsname{\hfil\unhbox0}}} |
| 1359 |
% \end{macrocode} |
| 1360 |
%\end{macro} |
| 1361 |
%\subsection{Other checks} |
| 1362 |
%\begin{macro}{\leeg} |
| 1363 |
%This macro is used to overrule the default behaviour of the pair |\b@fi| |
| 1364 |
%and |\e@fi|. It starts with ending the groups in the |
| 1365 |
%same way that |\e@fi| would normally do. Then the effect of |\e@fi| |
| 1366 |
%(that is still in the preamble) is neutralised by |\let|ting it to |
| 1367 |
%be |\relax|. This |\let| is only local to the current column. Then |
| 1368 |
%the argument to |\leeg| is processed in the normal way for a right |
| 1369 |
%aligned column. |
| 1370 |
% |
| 1371 |
%Since the user may from time to time also need a column entry other than |
| 1372 |
%a number in the table, e.g., |\leeg{p.m.}|, this definition is without |
| 1373 |
%at-sign. By defining |\leeg| in this way, instead of |\multicolumn1r{}| |
| 1374 |
%(which contains |\omit|), the default spacing in the column is retained. |
| 1375 |
%It doesn't alter the width of the sumrule, but has its normal effect on |
| 1376 |
%the column width, so be careful: don't insert the unabridged version of |
| 1377 |
%Romeo and Juliet~\cite{RJ} here. It is not typeset in math mode, nor |
| 1378 |
%does it use the extra (formatting) information of |#4| of the fcolumn, |
| 1379 |
%so you're completely free here. |
| 1380 |
% \begin{macrocode} |
| 1381 |
\def\leeg#1{$\egroup \let\e@fi=\relax #1} |
| 1382 |
% \end{macrocode} |
| 1383 |
%Note that anything may be given as argument to |\leeg|, so in principle |
| 1384 |
%it can also be used to cheat: |\leeg{0,03}| will insert the text~|0,03| |
| 1385 |
%in the table but it doesn't increase the totals of that column by~3 |
| 1386 |
%(assuming |3,2| coding for the separations). But you won't cheat, won't you? |
| 1387 |
%\end{macro} |
| 1388 |
%\begin{macro}{\res@tsumline} |
| 1389 |
%Since all changes to the totals and widths of the columns are global, |
| 1390 |
%they have to be reset actively at the start of a tabular or array. |
| 1391 |
%That is an action by itself, but it may occur more often, on request |
| 1392 |
%of the user, therefore a special macro is defined. A side effect of |
| 1393 |
%this macro is that |\FCsc@l| is reset to~0. This is an advantage: |
| 1394 |
%it should be zero at the beginning of a line in the table (for other |
| 1395 |
%lines this is done by the |\\|). |
| 1396 |
% \begin{macrocode} |
| 1397 |
\def\res@tsumline{\FCsc@l=\FCtc@l\loop\ifnum\FCsc@l>0 |
| 1398 |
\global\csname FCtot@\romannumeral\FCsc@l\endcsname=0 |
| 1399 |
\global\csname FCwd@\romannumeral\FCsc@l\endcsname=\z@ |
| 1400 |
\advance\FCsc@l by \m@ne\repeat} |
| 1401 |
% \end{macrocode} |
| 1402 |
%\end{macro} |
| 1403 |
%\begin{macro}{\resetsumline} |
| 1404 |
%To reset a sumline within a table, it should be done within a |\noalign|. |
| 1405 |
% \begin{macrocode} |
| 1406 |
\def\resetsumline{\noalign{\res@tsumline}} |
| 1407 |
% \end{macrocode} |
| 1408 |
%\end{macro} |
| 1409 |
%\begin{macro}{\aut@check} |
| 1410 |
%If the number of |F|-columns is even, it is assumed that they are part of |
| 1411 |
%two sets of columns of which each column of the first set should balance |
| 1412 |
%the appropriate column of the second set. If on the other hand the number |
| 1413 |
%of columns is odd, then at least one column has nothing to balance against |
| 1414 |
%and no automatic checking occurs. It is correct to check for oddness of |
| 1415 |
%|\FCsc@l| since this |\aut@check| is only performed in the last column of |
| 1416 |
%the tabular: the value of |\FCsc@l| now equals the number of columns used |
| 1417 |
%in the current tabular (and may be less than |\FCtc@l|). |
| 1418 |
% |
| 1419 |
%The output is only to screen and the transcript file; it doesn't change |
| 1420 |
%the appearance of your document, so in case the assumption is wrong you |
| 1421 |
%can safely ignore the result and go on. The \meta{count}s~0 and~1 are |
| 1422 |
%used here and this can be done because any content of those \meta{count}s |
| 1423 |
%from previous calculations has become irrelevant at this moment. |
| 1424 |
% |
| 1425 |
%If the list |\FC@chklist| is empty, the list for the automatic check is |
| 1426 |
%generated (which will remain empty if |\FCsc@l| is odd). |
| 1427 |
% \begin{macrocode} |
| 1428 |
\def\FC@chklist{} |
| 1429 |
\def\aut@check{\ifx\@empty\FC@chklist\relax |
| 1430 |
\ifodd\FCsc@l\else |
| 1431 |
\count0=\@ne \count1=\FCsc@l \divide\count1 by \tw@ |
| 1432 |
\loop\ifnum\count1<\FCsc@l \advance\count1 by \@ne |
| 1433 |
\xdef\FC@chklist{\FC@chklist\number\count0,\number\count1;}% |
| 1434 |
\advance\count0 by\@ne \repeat |
| 1435 |
\fi |
| 1436 |
\fi |
| 1437 |
% \end{macrocode} |
| 1438 |
%Then this list is peeled off and processed. |
| 1439 |
%The comparison is done between the internal representation of the totals, |
| 1440 |
%so this only makes sense when the decimal part, i.e., the |2| of |3,2| in |
| 1441 |
%the default value for |#3| of~|f| is the same for both columns. That is |
| 1442 |
%almost always the case due to the nature of this type of tabulars. The |
| 1443 |
%\meta{count} |\FC@l| is free to be used for the calculations needed here. |
| 1444 |
% \begin{macrocode} |
| 1445 |
\loop\ifx\FC@chklist\@empty\else |
| 1446 |
\expandafter\fre@t\FC@chklist\fre@t |
| 1447 |
\FC@l=\csname FCtot@\romannumeral\count0\endcsname |
| 1448 |
\advance\FC@l by -\csname FCtot@\romannumeral\count1\endcsname |
| 1449 |
\ifnum\FC@l=0 \else \ifnum\FC@l<0 \FC@l=-\FC@l \fi |
| 1450 |
\PackageWarning{fcolumn}{Representations of F-columns \number |
| 1451 |
\count0 \space and \number\count1 \space differ by\MessageBreak |
| 1452 |
\number\FC@l\space due to \string\sumline\space near or}% |
| 1453 |
\fi |
| 1454 |
\repeat} |
| 1455 |
% \end{macrocode} |
| 1456 |
%When |\aut@check| is finished, |\FC@chklist| is empty again, i.e., well |
| 1457 |
%prepared for the next time it is used. This also means that the default |
| 1458 |
%behaviour kicks in again: if that's not what you want, you should |
| 1459 |
%specify the appropriate |\checkfcolumns| lines again. |
| 1460 |
%\end{macro} |
| 1461 |
%\begin{macro}{\fre@t} |
| 1462 |
%This function eats the first two numbers off |\FC@chklist|. |
| 1463 |
% \begin{macrocode} |
| 1464 |
\def\fre@t#1,#2;#3\fre@t{\count0=#1 \count1=#2 \xdef\FC@chklist{#3}} |
| 1465 |
% \end{macrocode} |
| 1466 |
%\end{macro} |
| 1467 |
%\begin{macro}{\checkfcolumns} |
| 1468 |
%But the assumptions for |\aut@check| may be wrong, therefore manual |
| 1469 |
%control on this checking is also made possible here. The macro |
| 1470 |
%|\checkfcolumns| provides a way to the user to check that the appropriate |
| 1471 |
%columns are balanced (as it should in a balance). Arguments |#1| and |
| 1472 |
%|#2| are the |F|-column numbers to compare. It is the responsibility of |
| 1473 |
%the user to provide the correct numbers here, otherwise bogus output |
| 1474 |
%is generated. If this manual check is inserted, the automatic check |
| 1475 |
%will not be performed. |
| 1476 |
% \begin{macrocode} |
| 1477 |
\def\checkfcolumns#1#2{\noalign{\xdef\FC@chklist{\FC@chklist #1,#2;}}} |
| 1478 |
% \end{macrocode} |
| 1479 |
%\end{macro} |
| 1480 |
% |
| 1481 |
%\subsection{Adaptations to existing macros}\label{adaptations} |
| 1482 |
%\begin{macro}{\@array} |
| 1483 |
%The definition of |\@array| had to be extended slightly because it should |
| 1484 |
%also include |\@mksumline| (acting on the same |#2| that |\@mkpream| gets). |
| 1485 |
%This change is transparant: it only adds functionality and if you don't |
| 1486 |
%use that, you won't notice the difference. This addition to |\@array| |
| 1487 |
%by redefining it is distracting and error-prone and is better implemented |
| 1488 |
%via the Hook-mechanism~\cite{hook}; from the June~1, 2026 version onwards, |
| 1489 |
%package |array| will contain two dedicated Hooks~\cite{LTN43} for adding |
| 1490 |
%various chunks, among which the code on |\@mksumline| in |\@array| and for |
| 1491 |
%resetting |\FCsc@l| in |\ar@ialign|, see below. But till that date it is |
| 1492 |
%|fcolumn| that should take care of those Hooks and that is done here. |
| 1493 |
% \begin{macrocode} |
| 1494 |
\IfFormatAtLeastF{2026-06-01}{\NewHookWithArguments{tbl/init}{2} |
| 1495 |
\NewHook{tbl/row/end}} |
| 1496 |
% \end{macrocode} |
| 1497 |
%Now fill those Hooks. The |#2| is the actual |#2| from |\@array|. |
| 1498 |
% \begin{macrocode} |
| 1499 |
\AddToHookWithArguments{tbl/init}{\begingroup\@mksumline{#2}% |
| 1500 |
\res@tsumline\endgroup} |
| 1501 |
% \end{macrocode} |
| 1502 |
%No arguments for this one. |
| 1503 |
% \begin{macrocode} |
| 1504 |
\AddToHook{tbl/row/end}{\global\FCsc@l=0 } |
| 1505 |
% \end{macrocode} |
| 1506 |
%Redefining starts by just copying the original definition from v2.6d (or later) |
| 1507 |
%of the |array| package~\cite{array}, compacted. |
| 1508 |
% \begin{macrocode} |
| 1509 |
%<*tagging> |
| 1510 |
\ExplSyntaxOn |
| 1511 |
%</tagging> |
| 1512 |
\IfFormatAtLeastF{2026-06-01}{\def\@array[#1]#2{\@tempdima\ht |
| 1513 |
\strutbox\advance\@tempdima by \extrarowheight\setbox\@arstrutbox |
| 1514 |
\hbox{\vrule\@height\arraystretch\@tempdima\@depth\arraystretch |
| 1515 |
\dp\strutbox\@width\z@}% |
| 1516 |
%<*tagging> |
| 1517 |
\tbl_init_cell_data_for_table: |
| 1518 |
%</tagging> |
| 1519 |
\begingroup\@mkpream{#2}% |
| 1520 |
%<*tagging> |
| 1521 |
\tbl_count_table_cols: |
| 1522 |
%</tagging> |
| 1523 |
\xdef\@preamble{\noexpand\ar@ialign\@halignto |
| 1524 |
\bgroup\@arstrut |
| 1525 |
%<*tagging> |
| 1526 |
\UseTaggingSocket{tbl/row/begin} |
| 1527 |
\tbl_init_cell_data_for_row: |
| 1528 |
%</tagging> |
| 1529 |
\@preamble\tabskip\z@\cr}\endgroup |
| 1530 |
% \end{macrocode} |
| 1531 |
%After this |\endgroup| a |\begingroup| is issued; this ensures that |
| 1532 |
%|\@mksumline| that is created there experiences the same environment that |
| 1533 |
%|\@mkpream| saw. As a side product of |\@mksumline| also the \meta{count}s |
| 1534 |
%for the totals and \meta{dimen}s for the widths of the columns are created. |
| 1535 |
%All columns should start fresh, i.e., totals are~0 and widths are 0\thinspace pt. |
| 1536 |
%This can be done within the group, as these resettings are global. |
| 1537 |
% \begin{macrocode} |
| 1538 |
\UseHookWithArguments{tbl/init}{2}{}{#2} |
| 1539 |
% \end{macrocode} |
| 1540 |
%From here on it is just the old definition of |array.sty|. |
| 1541 |
% \begin{macrocode} |
| 1542 |
\@arrayleft\if #1t\vtop\else\if#1b\vbox\else\vcenter\fi\fi |
| 1543 |
\bgroup\let\@sharp ##\let\protect\relax\lineskip\z@\baselineskip\z@ |
| 1544 |
\mathsurround \z@ \let\\\@arraycr \let\tabularnewline\\\let\par\@empty |
| 1545 |
%<*tagging> |
| 1546 |
\UseTaggingSocket{tbl/init} |
| 1547 |
%</tagging> |
| 1548 |
\@preamble} |
| 1549 |
% \end{macrocode} |
| 1550 |
%Because |\@array| was changed here and it is this version that should |
| 1551 |
%be used, |\@@array| should be |\let| equal to |\@array| again. |
| 1552 |
% \begin{macrocode} |
| 1553 |
\let\@@array=\@array\def\ar@ialign{\everycr{\noalign{% |
| 1554 |
%<*tagging> |
| 1555 |
\tbl_if_row_was_started:T{\UseTaggingSocket{tbl/row/end}} |
| 1556 |
\tbl_update_cell_data_for_next_row: |
| 1557 |
%</tagging> |
| 1558 |
% \end{macrocode} |
| 1559 |
%\end{macro} |
| 1560 |
%Here comes an accompanying change: after each |\\| (or |\cr| for that matter) |
| 1561 |
%the \meta{count} |\FCsc@l| should be reset. This is easiest done with |
| 1562 |
%|\everycr|, but |\everycr| is essentially put to |{}| by |\ar@ialign|, so |
| 1563 |
%that definition should change. The resetting should be done globally. |
| 1564 |
% \begin{macrocode} |
| 1565 |
\UseHook{tbl/row/end} |
| 1566 |
% \end{macrocode} |
| 1567 |
%Then the definition is picked up again. |
| 1568 |
% \begin{macrocode} |
| 1569 |
}}\tabskip\z@skip\halign}} |
| 1570 |
% \end{macrocode} |
| 1571 |
%Much of the techniques here are repeated in |\LT@array|, see the next section. |
| 1572 |
% |
| 1573 |
%\subsection{Support for multipage tables} |
| 1574 |
%Packages |longtable|~\cite{longtable} and |supertabular|~\cite{supertabular} |
| 1575 |
%can be used for tables that span multiple pages. Package |supertabular| works |
| 1576 |
%with |fcolumn| out of the box (no changes needed), but may lead to different |
| 1577 |
%column widths on individual pages. If you don't want that, use |longtable|. |
| 1578 |
%The packages |fcolumn| and |longtable| also work together because only one |
| 1579 |
%definition of |longtable| needs to be changed if it is present. That change |
| 1580 |
%is done via a Hook~\cite{hook}, so it no longer matters in which order |
| 1581 |
%|fcolumn| and |longtable| are loaded. More happens under the hood if also |
| 1582 |
%|caption|~\cite{caption} is loaded, and even that is running fine. But with |
| 1583 |
%the near infinite number of packages that exist nowadays I did not check |
| 1584 |
%all combinations, so I may have overlooked some. |
| 1585 |
% \begin{macrocode} |
| 1586 |
%<*tagging> |
| 1587 |
%<@@=tbl> |
| 1588 |
%</tagging> |
| 1589 |
% \end{macrocode} |
| 1590 |
%\begin{macro}{\LT@array} |
| 1591 |
%And here is the only definition of |longtable| that needs to be extended |
| 1592 |
%to make |fcolumn| work with that package. The lines are compacted a bit |
| 1593 |
%w.r.t.\ the original |longtable| code; if you want to study the |
| 1594 |
%code, have a look at the documentation~\cite{longtable}. It is defined, even |
| 1595 |
%if |longtable| is not loaded. Similar Hooks as in |array| will be placed in |
| 1596 |
%package |longtable|, after which this section can be removed in |
| 1597 |
%the next version. |
| 1598 |
% \begin{macrocode} |
| 1599 |
\IfFormatAtLeastF{2026-06-01}{\AtBeginDocument{\def\LT@array[#1]#2{% |
| 1600 |
%<*tagging> |
| 1601 |
\UseTaggingSocket{tbl/init}\tl_if_empty:eTF{\LTcaptype}% |
| 1602 |
{\tl_gset:Ne\@currentHref{LT@tables.\theHLT@tables}}{% |
| 1603 |
%</tagging> |
| 1604 |
\@kernel@refstepcounter{\LTcaptype}\stepcounter{LT@tables} |
| 1605 |
%<*tagging> |
| 1606 |
\tl_gset:Ne\@currentHref{\LTcaptype.\cs_if_exist_use:c |
| 1607 |
{theH\LTcaptype}}}\tbl_gzero_row_count: |
| 1608 |
\UseTaggingSocket{tbl/longtable/init} |
| 1609 |
%</tagging> |
| 1610 |
\if l#1\LTleft\z@\LTright\fill\else\if r#1\LTleft\fill\LTright\z@ |
| 1611 |
\else\if c#1\LTleft\fill\LTright\fill\fi\fi\fi\let\LT@mcol |
| 1612 |
\multicolumn\let\LT@@@@tabarray\@tabarray\let\LT@@@@hl\hline |
| 1613 |
\def\@tabarray{\let\hline\LT@@@@hl\let\multicolumn\LT@mcol |
| 1614 |
\LT@@@@tabarray}\let\\\LT@tabularcr\let\tabularnewline\\ |
| 1615 |
\def\newpage{\noalign{\break}}\def\pagebreak{\noalign{\ifnum`}=0 |
| 1616 |
\fi\@testopt{\LT@no@pgbk-}4}\def\nopagebreak{\noalign{\ifnum`}=0 |
| 1617 |
\fi\@testopt\LT@no@pgbk4}\let\hline\LT@hline\let\kill\LT@kill |
| 1618 |
\let\caption\LT@caption\@tempdima\ht\strutbox\let\@endpbox |
| 1619 |
\LT@endpbox\ifx\extrarowheight\@undefined\let\@acol\@tabacol\let |
| 1620 |
\@classz\@tabclassz\let\@classiv\@tabclassiv\def\@startpbox{% |
| 1621 |
\vtop\LT@startpbox}\let\@@@@startpbox\@startpbox\let\@@@@endpbox |
| 1622 |
\@endpbox\let\LT@LL@FM@cr\@tabularcr\else\advance\@tempdima |
| 1623 |
\extrarowheight\col@sep\tabcolsep\let\@startpbox\LT@startpbox |
| 1624 |
\let\LT@LL@FM@cr\@arraycr\fi\setbox\@arstrutbox\hbox{\vrule |
| 1625 |
\@height\arraystretch\@tempdima\@depth\arraystretch\dp\strutbox |
| 1626 |
\@width\z@}\let\@sharp##\let\protect\relax |
| 1627 |
\begingroup\@mkpream{#2}% |
| 1628 |
%<*tagging> |
| 1629 |
\tbl_count_table_cols: |
| 1630 |
%</tagging> |
| 1631 |
\xdef\LT@bchunk{% |
| 1632 |
%<*tagging> |
| 1633 |
\tbl_inbetween_rows: |
| 1634 |
%</tagging> |
| 1635 |
\global\advance\c@LT@chunks\@ne\global\LT@rows\z@\setbox\z@\vbox |
| 1636 |
\bgroup\LT@setprevdepth\tabskip\LTleft\noexpand\halign to\hsize |
| 1637 |
\bgroup\tabskip\z@\@arstrut |
| 1638 |
%<*tagging> |
| 1639 |
\UseTaggingSocket{tbl/row/begin}\tbl_init_cell_data_for_row: |
| 1640 |
%</tagging> |
| 1641 |
\@preamble |
| 1642 |
\tabskip\LTright\cr}\endgroup |
| 1643 |
% \end{macrocode} |
| 1644 |
%Until this line it was just the code for |\LT@array| from package~|longtable|. |
| 1645 |
%The next line is new to |\LT@array|. Its purpose is the same as in |\@array| above. |
| 1646 |
% \begin{macrocode} |
| 1647 |
\UseHookWithArguments{tbl/init}{2}{}{#2} |
| 1648 |
% \end{macrocode} |
| 1649 |
%A few lines of the original definition again. |
| 1650 |
% \begin{macrocode} |
| 1651 |
\expandafter\LT@nofcols\LT@bchunk&\LT@nofcols\LT@make@row\m@th |
| 1652 |
\let\par\@empty\res@tsumline\everycr{\noalign{% |
| 1653 |
%<*tagging> |
| 1654 |
\@@_trace:n {--longtable-->~chunk~row:~ \the\LT@rows\space |
| 1655 |
row:~ \the\g_@@_row_int \space column:~ \the\g_@@_col_int} |
| 1656 |
\tbl_if_row_was_started:T {\UseTaggingSocket{tbl/row/end} |
| 1657 |
\tbl_inbetween_rows:}\int_compare:nNnT\LT@rows<\LTchunksize |
| 1658 |
{\tbl_gincr_row_count:} % Next is row about to start |
| 1659 |
%</tagging> |
| 1660 |
% \end{macrocode} |
| 1661 |
%And here is the last addition. |
| 1662 |
% \begin{macrocode} |
| 1663 |
\UseHook{tbl/row/end} |
| 1664 |
% \end{macrocode} |
| 1665 |
%From here on |\LT@array| is picked up again. |
| 1666 |
% \begin{macrocode} |
| 1667 |
}}\lineskip\z@\baselineskip\z@\LT@bchunk}}} |
| 1668 |
%<*tagging> |
| 1669 |
\ExplSyntaxOff |
| 1670 |
%<@@=> |
| 1671 |
%</tagging> |
| 1672 |
% \end{macrocode} |
| 1673 |
%\end{macro} |
| 1674 |
% |
| 1675 |
%When |longtable| splits a table, i.e., is doing what you loaded it for, modern |
| 1676 |
%versions of pdf\/\LaTeX\ complain about infinite glue shrinkage. This is due to |
| 1677 |
%a |\vss| in the definition of |\LT@output|. It's not an error and can be ignored, |
| 1678 |
%but it is annoying since it interrupts generating the output file. The author |
| 1679 |
%of |longtable| announced a fix in |\LT@output| in the next version of that |
| 1680 |
%package~\cite{infinite}. |
| 1681 |
% |
| 1682 |
%That's it! |
| 1683 |
% |
| 1684 |
%\section*{Acknowledgement} |
| 1685 |
%Thanks to Karl Berry for valuable comments regarding the consistency of the |
| 1686 |
%installation procedure of this version. Frank Mittelbach gave various useful |
| 1687 |
%suggestions for improving the input parsing as well as hints to make the package |
| 1688 |
%more \LaTeX-like. He also challenged me to make |fcolumn| compatible with |
| 1689 |
%|longtable|. Christian Hoff's request on column formatting triggered many |
| 1690 |
%happy hours of coding. |
| 1691 |
%\bibliographystyle{plain} |
| 1692 |
%\begin{thebibliography}{10} |
| 1693 |
%\itemsep0pt \parsep0pt \parskip0pt |
| 1694 |
%\bibitem{array} Frank Mittelbach and David Carlisle. A new implementation of |
| 1695 |
% \LaTeX's |tabular| and |array| environment: \url{www.ctan.org/pkg/array}. |
| 1696 |
%\bibitem{booktabs} Simon Fear and Danie Els, the |booktabs| package. Publication |
| 1697 |
% quality tables in \LaTeX: \url{www.ctan.org/pkg/booktabs}. |
| 1698 |
%\bibitem{dcolumn} David Carlisle, the |dcolumn| package: \url{www.ctan.org/pkg/dcolumn}. |
| 1699 |
%\bibitem{longtable} David Carlisle, the |longtable| package: \url{www.ctan.org/pkg/longtable}. |
| 1700 |
%\bibitem{supertabular} Theo Jurriens ^^A I checked with Theo that `Jurriens' is correct; not `Jurri\"ens' (EHTO). |
| 1701 |
% and Johannes Braams, the |supertabular| package, to be found at: \url{www.ctan.org/pkg/supertabular}. |
| 1702 |
%\bibitem{tagging} Ulrike Fischer, the |tagpdf| package: \url{www.ctan.org/pkg/tagpdf}. |
| 1703 |
%\bibitem{color} David Carlisle, the |color| package: \url{www.ctan.org/pkg/color}. |
| 1704 |
%\bibitem{CandTB} Donald Knuth, {\it Computers \& Typesetting/B, ``\TeX: the program,''\/} |
| 1705 |
% Addison-Wesley, Reading (1991). |
| 1706 |
%\bibitem{CandTA} Donald Knuth, {\it Computers \& Typesetting/A, ``The \TeX book,''\/} |
| 1707 |
% Addison-Wesley, Reading (1991). |
| 1708 |
%\bibitem{TAOCP1} Donald Knuth, {\it The Art of Computers Programming, volume~1, |
| 1709 |
% ``Fundamental Algorithms,''\/} Addison-Wesley, Reading (1997). |
| 1710 |
%\bibitem{RJ} William Shakespeare, Romeo and Juliet, a tragedy (1597). |
| 1711 |
%\bibitem{hook} Frank Mittelbach, ``\LaTeX's hook management'', |
| 1712 |
% \url{www.latex-project.org/help/documentation/lthooks-doc.pdf}. |
| 1713 |
%\bibitem{LTN43} \LaTeX-News 43: \url{www.latex-project.org/news/latex2e-news/ltnews43.pdf}. |
| 1714 |
%\bibitem{caption} Axel Sommerfeldt, the |caption| package: \url{www.ctan.org/pkg/caption}. |
| 1715 |
%\bibitem{infinite} See discussion at \url{https://github.com/latex3/latex2e/issues/1907}. |
| 1716 |
%\end{thebibliography} |
| 1717 |
%\Finale |
| 1718 |
\endinput |