summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fcolumn/fcolumn.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/fcolumn/fcolumn.dtx')
-rw-r--r--macros/latex/contrib/fcolumn/fcolumn.dtx438
1 files changed, 336 insertions, 102 deletions
diff --git a/macros/latex/contrib/fcolumn/fcolumn.dtx b/macros/latex/contrib/fcolumn/fcolumn.dtx
index 5dcef07b61..41bee63cf1 100644
--- a/macros/latex/contrib/fcolumn/fcolumn.dtx
+++ b/macros/latex/contrib/fcolumn/fcolumn.dtx
@@ -1,5 +1,5 @@
% \iffalse meta-comment
-% Copyright (C) 2015--2019 by Edgar Olthof
+% Copyright (C) 2015--2021 by Edgar Olthof
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
@@ -14,11 +14,12 @@
% \fi
% \iffalse
%<package>\ProvidesPackage{fcolumn}
-%<package> [2019/04/24 v1.2 Automatic Currency Package (EHTO)]
+%<package> [2021/01/14 v1.3 Automatic Currency Package (EHTO)]
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\RequirePackage{array}[v2.4k]
%<*driver>
\documentclass{ltxdoc}
+\usepackage{longtable}
\usepackage{fcolumn}
\usepackage{booktabs}
\usepackage[tableposition=top,aboveskip=0pt]{caption}
@@ -30,15 +31,16 @@ indention=0pt,labelsep=colon,justification=raggedright}
\usepackage{url}
\usepackage[hyperfootnotes=false,hidelinks]{hyperref}
\usepackage{eurosym}
+\usepackage{color}
\EnableCrossrefs
\CodelineIndex
-\RecordChanges
\begin{document}
\DocInput{fcolumn.dtx}
\end{document}
%</driver>
% \fi
-% \CheckSum{1078}
+% \RecordChanges
+% \CheckSum{1287}
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -64,24 +66,32 @@ indention=0pt,labelsep=colon,justification=raggedright}
% counts and resetting of column counter done in a nicer way.}
% \changes{v1.1.1}{2015/09/27}{Installation procedure changed from .ins-in-.dtx to separate
% .ins and .dtx after discussion with Karl Berry as well as some minor code improvements.}
-% \changes{v1.1.2}{2015/09/29}{Some inconsistencies between explanatory text
-% and actual code removed.}
+% \changes{v1.1.2}{2015/09/29}{Some inconsistencies between explanatory text and actual
+% code removed.}
% \changes{v1.2}{2019/03/06}{Input parsing changed after comment from Frank
% Mittelbach. He (Frank) also gave various suggestions for improving robustness
% or user friendlyness of this package. This version is only backwards compatible
% when zero decimal digits were and are specified as modifier.}
+% \changes{v1.3}{2021/01/03}{Christian Hoff requested the possibility to provide extra formatting
+% information to a column, e.g., colouring. That was implemented by having an extra parameter
+% to the generic F-column. The current solution is not very robust, as font and/or size change
+% in math environment are very tricky, but providing colour information works, see the example
+% in the main text. This version is now compatible with package longtable. Version~1.3 is
+% backwards compatible to~1.2: it only adds functionality.}
% \GetFileInfo{fcolumn.sty}
-% \DoNotIndex{\@arstrut,\@arstrutbox,\@depth,\@firstampfalse,\@firstamptrue,\@gobble,\@halignto}
-% \DoNotIndex{\@height,\@mkpream,\@ne,\@nextchar,\@preamble,\@sharp,\@tempdima,\@tempswafalse}
-% \DoNotIndex{\@tempswatrue,\@\temptokena,\@tfor,\@whilesw,\@width,\advance,\arraystretch,\baselineskip}
-% \DoNotIndex{\begingroup,\bgroup,\count,\count@,\cr,\csname,\def,\divide,\do,\dp,\edef,\egroup}
-% \DoNotIndex{\else,\endcsname,\endgroup,\expandafter,\extrarowheight,\fi,\gdef,\halignto,\hbox}
-% \DoNotIndex{\hfil,\ht,\if,\if@firstamp,\if@tempswa,\ifcase,\lineskip,\loop,\m@ne,\m@th,\message}
-% \DoNotIndex{\multiply,\or,\par,\prepnext@tok,\protect,\repeat,\setbox,\space,\string,\strutbox}
-% \DoNotIndex{\tabskip,\tabularnewline,\the,\the@toks,\thr@@,\tw@,\unhbox,\vbox,\vcenter,\vrule}
+% \DoNotIndex{\@@endpbox,\@@startpbox,\@acol,\@arstrut,\@arstrutbox,\@classiv,\@classz,\@depth}
+% \DoNotIndex{\@firstampfalse,\@firstamptrue,\@gobble,\@halignto,\@height,\@mkpream,\@ne,\@nextchar}
+% \DoNotIndex{\@preamble,\@sharp,\@tempdima,\@tempswafalse,\@tempswatrue,\@\temptokena,\@tfor}
+% \DoNotIndex{\@whilesw,\@width,\advance,\arraystretch,\baselineskip,\begingroup,\bgroup,\count}
+% \DoNotIndex{\count@,\cr,\csname,\def,\divide,\do,\dp,\edef,\egroup,\hfil,\hline,\ht,\if,\if@firstamp}
+% \DoNotIndex{\if@tempswa,\ifcase,\kill,\lineskip,\LT@@hl,\LT@@tabarray,\LT@bchunk,\LT@caption,\LT@endpbox}
+% \DoNotIndex{\LT@hline,\LT@kill,\LT@LL@FM@cr,\LT@make@row,\LT@mcol,\LT@no@pgbk,\LT@nofcols,\LT@rows}
+% \DoNotIndex{\LT@setprevdepth,\LT@startpbox,\LT@tabularcr,\LTleft,\LTright,\loop,\m@ne,\m@th,\message}
+% \DoNotIndex{\multiply,\or,\par,\prepnext@tok,\protect,\refstepcounter,\repeat,\setbox,\space,\string}
+% \DoNotIndex{\strutbox,\tabskip,\tabularnewline,\the,\the@toks,\thr@@,\tw@,\unhbox,\vbox,\vcenter,\vrule}
% \DoNotIndex{\vskip,\vtop,\wd,\xdef,\z@,\z@skip}
-% \title{The \textsf{fcolumn} package\thanks{This file has version
-% number \fileversion, last revised \filedate.}}
+% \title{The \textsf{fcolumn} package\thanks{This file has version number \fileversion, last
+% revised \filedate.}}
% \author{Edgar Olthof\\
% \texttt{edgar <dot> olthof <at> inter <dot> nl <dot> net}}
% \date{Printed \today}
@@ -98,16 +108,16 @@ indention=0pt,labelsep=colon,justification=raggedright}
% The package |fcolumn| provides the macros for an extra tabular specifier
% that makes creating financial tables easy. The column specifier |f|
% itself is rather simple; it is the predefined version of a generic
-% column |F|. The generic version expects three arguments: 1)~grouping
+% column |F|. The generic version expects four arguments: 1)~grouping
% character of the integer part on output, 2)~decimal mark used on output,
-% and 3)~compact additional information on input/output characteristics,
-% see below.
+% 3)~compact additional information on input/output characteristics, and
+% 4)~anything, but primarily used for providing formatting information, see below.
%
% The f-column in the current version of the package is defined for the
-% continental European standard: |\newcolumntype{f}{F{.}{,}{3,2}}|. This
+% continental European standard: |\newcolumntype{f}{F{.}{,}{3,2}{}}|. This
% means that a number like 12345,67 will be typeset as $12{.}345{,}67$.
% People in the Anglo-saxon world would rather code
-% |\newcolumntype{f}{F{,}{.}{3,2}}| for the same input, yielding
+% |\newcolumntype{f}{F{,}{.}{3,2}{}}| for the same input, yielding
% $12{,}345{.}67$ as output for the number given above. The default
% value for |#3| is |3,2|, indicating
% that grouping of the integer part is by three digits, that a comma is
@@ -116,7 +126,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
% If however, in your country or company grouping is done with a thinspace every
% four digits, that the separator in the source should be the character |p|,
% and there are three digits after the decimal mark---that happens to be a
-% |\cdot|---, then simply specify |\newcolumntype{f}{F{\,}{\cdot}{4p3}}| in
+% |\cdot|---, then simply specify |\newcolumntype{f}{F{\,}{\cdot}{4p3}{}}| in
% that case. The input could be 12345p678 then, yielding $1{\,}2345{\cdot}678$
% as output.
%
@@ -125,6 +135,11 @@ indention=0pt,labelsep=colon,justification=raggedright}
% mark) you have to explicitly specify |x,0|. If you want no grouping
% character, specify |0,x|.
%
+% As the fourth parameter you can insert anything just before the typesetting
+% of an amount in a column takes place. Its purpose is to add additional
+% formatting information, e.g., |\color{red}| to have the contents of a column
+% coloured red, but it can be misused, so use with care. And it can't do all!
+%
% This package requires and loads the |array| package~\cite{array}. To
% show where and how the |F|-column is used, let's look at some typical
% financial information as shown in Table~\ref{tab:ex1}
@@ -138,7 +153,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
% \midrule
% house & 200000 & equity capital& 50000 \\
% bank account & -603,23 & mortgage & 150000 \\
-% savings & 28000 & & \\
+% savings & 28000 \\
% cash & 145,85 & profit & 27542,62 \\
% \sumline
% \bottomrule
@@ -146,7 +161,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
% \end{table}
% and how this is entered in \LaTeX\ (Table~\ref{tab:ex2}).
% \begin{table}[htb]
-% \caption{Verbatim version of Example Table.}
+% \caption{Verbatim version of Example Table~\ref{tab:ex1}.}
% \label{tab:ex2}
% \begin{verbatim}
%\begin{table}[htb]
@@ -159,7 +174,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
%\midrule
%house & 200000 & equity capital& 50000 \\
%bank account & -603,23 & mortgage & 150000 \\
-%savings & 28000 & & \\
+%savings & 28000 \\
%cash & 145,85 & profit & 27542,62 \\
%\sumline
%\bottomrule
@@ -176,17 +191,143 @@ indention=0pt,labelsep=colon,justification=raggedright}
%
% This package is heavily inspired by the |dcolumn| package by
% David Carlisle~\cite{dcolumn}, some constructions are more or less
-% copied from that package. Version~1.2 (this version) uses a few ideas
-% from, and incorporates quite some suggestions by, Frank Mittelbach.
+% copied from that package. Version~1.3 (this version) incorporates the idea
+% of Christian Hoff of providing additional (formatting) information per column.
+% A rather contrived example is given in Table~\ref{tab:ex3}, combining colour and fonts.
+% \newcolumntype{q}[1]{F{.}{,}{3,2}{#1}}
+% \begin{table}[htb]
+% \caption{Example Table with column formatting.}
+% \label{tab:ex3}
+% \begin{tabular}{@{}lq{\color{red}\mathsf,{}\mathbf}lq{\color{green}}@{}}
+% \multicolumn4c{\bfseries Balance sheet}\\
+% \toprule
+% properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\
+% \midrule
+% house & 200000 & equity capital& 50000 \\
+% bank account & -603,23 & mortgage & 150000 \\
+% savings & 28000 \\
+% cash & 145,85 & profit & 27542,62 \\
+% \sumline
+% \bottomrule
+% \end{tabular}
+% \end{table}
+% How this is entered in \LaTeX\ is shown in Table~\ref{tab:ex4}.
+% \begin{table}[htb]
+% \caption{Almost verbatim version of Example Table~\ref{tab:ex3}.}
+% \label{tab:ex4}
+% \begin{verbatim}
+%\newcolumntype{q}[1]{F{.}{,}{3,2}{#1}}
+%\begin{table}[htb]
+%\caption{Example Table with column formatting.}
+%\label{tab:ex3}
+%\begin{tabular}{@{}lq{\color{red}\mathsf,{}\mathbf}lq{\color{green}}@{}}
+%\multicolumn4c{\bfseries Balance sheet}\\
+%...
+%...(same financial contents as in Table 1)
+%...
+%\end{tabular}
+%\end{table}
+% \end{verbatim}
+% \end{table}
+% The font changing commands like |\mathsf| and |\mathbf| act on an argument, hence require
+% braces, but these are already provided internally for this purpose. For that reason this
+% type of commands must be given last, without braces (and if you don't specify a font
+% changing command, these extra internal braces are just redundant). The argument to
+% the new columntype may consist of two parts,
+% separated by a comma. In that case, the part to the left of the comma is applied to the
+% whole column and the right part is applied in addition to the result. The example in
+% Table~\ref{tab:ex3} shows this: the bold font is only used in the |\sumline| and the
+% effect of |\mathsf| is annulled by the brace pair before |\mathbf|. You may even change
+% the colour for the |\sumline|, e.g., blue by ``|,{}\color{blue}\mathbf|'', since colour
+% settings do not require braces and the last setting overrides a previous one. If you want
+% bold font for the whole column, leave out the comma (and the |\mathsf{}|).
+%
+% Note that changes in font size, e.g., ``|\huge|'' in ``|\huge\color{red}\mathbf|''
+% as parameter to column type |q| are ignored by \LaTeX, since the formatting
+% information is used in math environment, which has its own way of handling this.
+% This isn't bad, as size changes in one column, without overall changes to the
+% table look terrible. If you want something huge, make a |\huge| table.
+%
+% This package now also works with |longtable|~\cite{longtable}, provided
+% |longtable| is loaded before |fcolumn|; it checks for that. For a change,
+% the raw formatting of the multipage table is shown first, in Table~\ref{tab:ex5}.
+% For more information on how to handle |\endhead| and related commands, see the
+% documentation of |longtable|~\cite{longtable}.
+% \begin{table}[htb]
+% \caption{Almost verbatim version of Example Table~\ref{tab:ex6}.}
+% \label{tab:ex5}
+% \begin{verbatim}
+%\begin{longtable}[l]{@{}lflf@{}}
+%\caption{\label{tab:ex6}Table showing compatibility of fcolumn and
+% longtable.}\\
+%\multicolumn4c{\bfseries Balance sheet}\\
+%\toprule
+%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\
+%\midrule
+%\endfirsthead
+%\caption[]{\textit{(continued from previous page)\/}}\\
+%\midrule
+%properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\
+%\midrule
+%\endhead
+%\midrule
+%\multicolumn4{r@{}}{\textit{(Table continues on next page)\/}}\\
+%\endfoot
+%\bottomrule
+%\endlastfoot
+%...
+%...(somewhat altered financial contents as in Table 1)
+%...
+%\end{longtable}
+% \end{verbatim}
+% \end{table}
%
+% \noindent And here is the result (it's ugly, but it had to be that long to
+% demonstrate the page break). Not shown here are the new |fcolumn|
+% formatting possibilities (like new fonts and/or colours), but it has been
+% checked they do work in combination with |longtable|.
+% \begin{longtable}[l]{@{}lflf@{}}
+% \caption{\label{tab:ex6}Table showing compatibility of fcolumn and
+% longtable.}\\
+% \multicolumn4c{\bfseries Balance sheet}\\
+% \toprule
+% properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\
+% \midrule
+% \endfirsthead
+% \caption[]{\textit{(continued from previous page)\/}}\\
+% \midrule
+% properties & \leeg{31 dec 2014} & debts & \leeg{31 dec 2014}\\
+% \midrule
+% \endhead
+% \midrule
+% \multicolumn4{r@{}}{\textit{(Table continues on next page)\/}}\\
+% \endfoot
+% \bottomrule
+% \endlastfoot
+% house & 200000 & equity capital& 50000 \\
+% bank account & -603,23 & mortgage & 150000 \\
+% savings 1 & 2800 \\
+% savings 2 & 2800 \\
+% savings 3 & 2800 \\
+% savings 4 & 2800 \\
+% savings 5 & 2800 \\
+% savings 6 & 2800 \\
+% savings 7 & 2800 \\
+% savings 8 & 2800 \\
+% savings 9 & 2800 \\
+% savings 10 & 2800 \\
+% cash & 145,85 & profit & 27542,62 \\
+% \sumline
+% \end{longtable}
+
% \section{Commands}
% The user only needs to know six commands or constructions. These six are given here.
% \begin{macro}{F}
% In the tabular the column specifier |F| can be given with arguments, or
-% the predefined version~|f|, where the three arguments of |F| are |{.}|,
-% |{,}|, and |{3,2}|. If you want |g| to be your own definition like the
+% the predefined version~|f|, where the four arguments of |F| are |{.}|,
+% |{,}|, |{3,2}|, and |{}|. If you want |g| to be your own definition like the
% curious one given in Section~\ref{intro}, then specify
-% |\newcolumntype{g}{F{\,}{\cdot}{4p3}}| prior to using |g| in a tabular.
+% |\newcolumntype{g}{F{\,}{\cdot}{4p3}{}}| prior to using |g| in a tabular.
%
% Entries in an F-column are, from that moment on, treated as numbers unless
% explicitly escaped by |\leeg|, see below. The numbers are typeset
@@ -196,7 +337,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
% character is the dot, except when the dot is specified as input decimal
% mark; in that case the comma is acting as input grouping character. With
% this convention the continental Europe and Anglo-saxon part of the world
-% is served.
+% is served. And using input grouping markers is optional.
% \end{macro}
% \begin{macro}{\sumline}
% The numbers in an |F|-column are typeset as a financial amount, but the real
@@ -207,7 +348,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
% \item It generates a rule with width calculated in the first item;
% \item It checks the columns that are supposed to balance whether or not they
% actually do. If so, nothing happens. If not, a |\PackageWarning| is given
-% that column $i$ and $j$ do not balance, where $i$ and $j$ are the relevant
+% that column~$i$ and~$j$ do not balance, where $i$ and $j$ are the relevant
% columns. This is only done if the total number of |F|-columns is even,
% e.g., if there are six |F|-columns, then~1 is checked against~4, 2 against~5,
% and 3 against~6. If the number of |F|-columns is odd then anything could be
@@ -217,18 +358,21 @@ indention=0pt,labelsep=colon,justification=raggedright}
% By default the vertical separation between the rule and the total is
% 2\thinspace pt, but this can be changed by the optional argument to
% |\sumline|. Give, e.g., |\sumline[10pt]|, in case you want this spacing
-% to be 10\thinspace pt.
+% to be 10\thinspace pt. And you may even give two options, like in
+% |\sumline[10pt][5pt]|, in which the second option is the extra space below
+% the summary row. In fact that second option is the option to |\\| that is
+% implicit in |\sumline|.
% \end{macro}
% \begin{macro}{\resetsumline}
% Suppose you want to typeset one tabular with the profit-and-loss of many
% projects individually. The layout of those tabulars is the same and it
% were nice if all columns were aligned. This can be done by making it one
% big tabular with a fresh start for each project. The macro
-% |\resetsumlines| is used for that: it resets all totals and all column
-% widths, see for example Table~\ref{tab:ex3}.
+% |\resetsumline| is used for that: it resets all totals and all column
+% widths, see for example Table~\ref{tab:ex7}.
% \begin{table}[htb]
% \caption{Example: multiple projects.}
-% \label{tab:ex3}
+% \label{tab:ex7}
% \begin{tabular}{@{}lfflff@{}}
% \multicolumn6c{\bfseries Project~1}\\
% \toprule
@@ -256,10 +400,10 @@ indention=0pt,labelsep=colon,justification=raggedright}
% Note that the rules in the first and third |F|-columns of project~1 cover
% $1{.}200{,}00$ whereas in project~2 those rules are narrower since they
% only cover $430{,}00$; still the columns are aligned. The verbatim way
-% of setting up Table~\ref{tab:ex3} is given in Table~\ref{tab:ex4}.
+% of setting up Table~\ref{tab:ex7} is given in Table~\ref{tab:ex6}.
% \begin{table}[htb]
-% \caption{Verbatim version of Table~\ref{tab:ex3}.}
-% \label{tab:ex4}
+% \caption{Verbatim version of Table~\ref{tab:ex7}.}
+% \label{tab:ex8}
% \begin{verbatim}
%\begin{table}[htb]
%\caption{Example: multiple projects.}
@@ -317,7 +461,9 @@ indention=0pt,labelsep=colon,justification=raggedright}
% even other ways. By default (for aesthetic reasons) |fcolumn| typesets
% it with a minus~sign, but strict accounting prescibes that the number
% should be put between parentheses. The latter can be accomplished by
-% setting |\strict@ccountingtrue|.
+% setting |\strict@ccountingtrue|. But since this contains a non-letter,
+% it is also possible to invoke |fcolumn| with the option |strict|, i.e.,
+% |\usepackage[strict]{fcolumn}|, which sets this flag.
% \end{macro}
% \StopEventually{\PrintChanges\PrintIndex}
% \section{The macros}
@@ -339,8 +485,8 @@ indention=0pt,labelsep=colon,justification=raggedright}
% column type |f| does not use private macros (no~|@|), so overriding its
% definition is easy for a user.
% \begin{macrocode}
-\newcolumntype{F}[3]{>{\b@fi{#1}{#2}{#3}}r<{\e@fi}}
-\newcolumntype{f}{F{.}{,}{3,2}}
+\newcolumntype{F}[4]{>{\b@fi{#1}{#2}{#3}{#4}}r<{\e@fi}}
+\newcolumntype{f}{F{.}{,}{3,2}{}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -374,21 +520,25 @@ indention=0pt,labelsep=colon,justification=raggedright}
% \end{macrocode}
% Actually |\geldm@cro| is only a wrapper around |\g@ldm@cro|.
% \begin{macrocode}
-\def\geldm@cro#1#2{\withs@pfalse
+\def\geldm@cro#1#2{\withs@pfalse
\afterassignment\g@ldm@cro\count@#1\relax{#2}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\g@ldm@cro}
-% This macro starts by looking at the sign of |#2|: if it is negative, it prints
+% After setting the environment for formatting, this macro starts by looking
+% at the sign of |#2|: if it is negative, it prints
% the correct indicator (a parenthesis or a minus sign), assigns the absolute value
% of~|#2| to |\count2| and goes on. Note that |\geldm@cro| and therefore |\g@ldm@cro|
% are always used within |$|s, so it is really a minus sign that is printed, not a hyphen.
% All calculations are done with |\count0|, |\count1|, etc.\ i.e., without |F|-column-specific
% \meta{count}s because it is all done locally. Leaving the tabular environment will
-% restore their values.
+% restore their values. This is also true for the effect of |\FCform@t|, so that formatting
+% information is local to this column. The reason for inserting the opening brace between
+% |\FCform@t| and |\ifnum| (and the accompanying closing brace after |\fi|) is to facilitate
+% the possible use of |\mathbf| or any other font changing command as the last item in |\FCform@t|.
% \begin{macrocode}
-\def\g@ldm@cro#1\relax#2{\ifnum#2<0 \ifstrict@ccounting (\else -\fi
- \count2=-#2 \else\count2=#2
+\def\g@ldm@cro#1\relax#2{\FCform@t{\ifnum#2<0 \ifstrict@ccounting (\else
+ -\fi \count2=-#2 \else\count2=#2
\fi
% \end{macrocode}
% Calculate the entire currency units: this is the result of $x/a$ as integer
@@ -450,7 +600,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
\rlap{)~!}\else\rlap{~!}\fi\else\ifstrict@ccounting
\rlap{\phantom{)}~!}\else\rlap{~!}\fi\fi
\else \ifnum#2<0 \ifstrict@ccounting\rlap{)}\fi\fi
-\fi}
+\fi}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\g@ldens}
@@ -470,7 +620,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
% about 100 times the current world economy~\cite{world_economy}. Yet
% another method is to used Heiko Oberdiek's package |bigintcalc|:
% then only memory restrictions apply. This, however, requires a major
-% rewrite of |fcolumn|. For now, version~1.2 sticks to the moderate amounts.
+% rewrite of |fcolumn|. For now, version~1.3 sticks to the moderate amounts.
%
% There is no straightforward interpretation of |#1| being zero or
% negative, therefore this is used as an indicator that no grouping
@@ -551,7 +701,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
% First it checks whether there is a risk of overflow in this step. If
% $A$ and $B$ are two \TeX-registers and $B$ is to be added to $A$,
% overflow will not occur if one is (or both are) zero or if $A$ and~$B$
-% have different signs. Otherwise, be careful. Note that \TeX\ does not
+% have different signs. Otherwise, be careful. Note that \TeX\ does not
% check for overflow when performing an |\advance| (done in section~1238
% of Ref.~\cite{CandTB}), in contrast to |\multiply|, see section~105.
% \begin{macrocode}
@@ -568,13 +718,13 @@ indention=0pt,labelsep=colon,justification=raggedright}
\global\advance\csname FCtot@\romannumeral\FCsc@l\endcsname by \count0
\ifx\FCs@gn\m@ne
% \end{macrocode}
-% They had the same sign: risk of overflow. Record the sign
+% They had the same sign: risk of overflow. Record the sign
% of |\count0| (and of the original total of this column; they were
-% the same) in |\FCs@gn|. Table~\ref{tab:ex5}
+% the same) in |\FCs@gn|. Table~\ref{tab:ex9}
% \begin{table}[htb]
-% \def\PackageError#1#2#3{\PackageWarning{#1}{#2}}
+% \def\PackageError#1#2#3{\PackageWarning{#1}{#2: #3}}
% \caption{Examples on overflow.}
-% \label{tab:ex5}
+% \label{tab:ex9}
% \begin{tabular}{@{}lfff@{}}
% \multicolumn4c{\bfseries Projects}\\
% \toprule
@@ -605,7 +755,9 @@ indention=0pt,labelsep=colon,justification=raggedright}
\ifnum\count0<0
\let\FCs@gn=\m@ne
\PackageError{fcolumn}{Register overflow}{Overflow occurred
- in fcolumn \number\FCsc@l. Check your table.}%
+ in fcolumn \number\FCsc@l. You can press <enter> now and I'll
+ proceed,\MessageBreak but check your table. The offending entry is
+ indicated with an exclamation\MessageBreak mark in the output.}%
\else\let\FCs@gn=\@ne
\fi
\fi
@@ -618,29 +770,34 @@ indention=0pt,labelsep=colon,justification=raggedright}
\fi\unhbox0}
% \end{macrocode}
% \end{macro}
+%
+% The \meta{count}s |\FC@l| captures the part to the left of the decimal
+% mark, |\FC@r| that to the right.
+% \begin{macrocode}
+\newcount\FC@l \newcount\FC@r
+% \end{macrocode}
+% Some auxiliary definitions for capturing compacted information.
+% \begin{macrocode}
+\def\setucc@de#1#2\relax{\uccode`\~=`#1 }
+\def\assignform@t#1,#2,#3\end{\def\FCform@t{#1}\def\FCform@tt{#1#2}}
+% \end{macrocode}
% \def\<#1>{\leavevmode\hbox{$\langle$#1\/$\rangle$}}
% \begin{macro}{\b@fi}
% The macro |\b@fi| provides the beginning of the financial column. It
-% will be inserted in the column to capture the number entered by the user
+% will be inserted in the column to capture the number entered by the user.
% The separator and decimal mark are within a math environment, so you
% can indeed specify |\,| instead of |\thinspace|, but there is an extra
% brace around, so it doesn't affect the spacing between the digits
% (trick copied from |dcolumn|, Ref.~\cite{dcolumn}).
-%
-% The \meta{count}s |\FC@l| captures the part to the left of the decimal
-% marker, |\FC@r| that to the right.
% \begin{macrocode}
-\newcount\FC@l \newcount\FC@r
-\def\FC@chklist{}
-\def\setucc@de#1#2\relax{\uccode`\~=`#1 }
-\def\b@fi#1#2#3{%
+\def\b@fi#1#2#3#4{%
% \end{macrocode}
% An intermediate macro |\sep@xt| to extract the first character
% of |#1|, which in most cases will be the only character.
% \begin{macrocode}
\def\sep@xt##1##2\end{\def\sep@rator{{##1}}}%
\sep@xt#1\end\def\decim@lmark{{#2}}%
-\def\sp@l{#3}\global\advance\FCsc@l by \@ne
+\def\sp@l{#3}\assignform@t#4,,\end \global\advance\FCsc@l by \@ne
\global\FC@l=0 \global\FC@r=1
% \end{macrocode}
% The value specified by the user is then captured by |\FC@l| and
@@ -651,23 +808,23 @@ indention=0pt,labelsep=colon,justification=raggedright}
% There are four parts to an |F|-column entry, all parts optional,
% making 16 combinations. The sequence is
% (in the Backus--Naur notation of Ref.~\cite{CandTA}):
-% \<sign> \<integer constant> \<decimal marker>
+% \<sign> \<integer constant> \<decimal mark>
% \<integer constant>. Here \<sign> is a plus or minus character with
% category code~12, \<integer constant> is a sequence of zero
-% or more (decimal) \<digit>s, and \<decimal marker> is the middel
+% or more (decimal) \<digit>s, and \<decimal mark> is the middel
% part of |#3|, i.e., the comma in |3,2| or the period in |3.2|.
-% If the \<decimal marker> is absent with no space characters between
+% If the \<decimal mark> is absent with no space characters between
% the two \<integer constant> terms, these merge, making four redundant
-% entries. One of the
-% combinations is \<empty>, a sequence of exactly zero non-space tokens:
-% this is the only combination that doesn't put anything in an |F|-column.
+% entries. One of the combinations is \<empty>, a sequence of exactly
+% zero non-space tokens: this is the only combination that doesn't put
+% anything in an |F|-column---and was the most difficult part to handle.
%
% The minus sign must be captured separately, because in an entry like
% |-0,07| the 7~cents are negative, but this cannot be seen from the
-% integer part, since $-0$ is $0$ in \TeX\ (in fact in most computer
-% languages, but not in~MIX~\cite{TAOCP1}), so |\ifnum-0<0| yields false.
-% |\FCs@gn| is a general purpose flag. Its first use is to capture
-% the sign.
+% part to the left of the decimal mark, since $-0$ is~$0$ in \TeX\ (in
+% fact in most computer languages, but not in~MIX~\cite{TAOCP1}), so
+% |\ifnum-0<0| yields |false|. |\FCs@gn| is a general purpose flag. Its
+% first use is to capture the sign.
% \begin{macrocode}
\let\FCs@gn=\@ne\relax \setbox0\hbox\bgroup$%
% \end{macrocode}
@@ -726,7 +883,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
\ifnum\count@=\mathcode`- \expandafter\global\FC@l=\the\FC@l
\else \expandafter\global\FC@r=\the\FC@r\fi}%
% \end{macrocode}
-% The signs are relatively simply: record the sign, restore |\mathcode|s if
+% The signs are relatively simple: record the sign, restore |\mathcode|s if
% needed (it should be: a minus sign between digits screws up everything),
% and start scanning the number.
% \begin{macrocode}
@@ -744,7 +901,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
\mathcode`-="8000 \mathcode`+=\mathcode`- \mathcode`.=\mathcode`-
% \end{macrocode}
% These three remain active until the |$| in |\e@fi| is encountered.
-% The following ones will, in the general case, have their activeness
+% The following ones will, except in the \<empty> case, have their activeness
% turned off at some time.
% \begin{macrocode}
\def\actdecm@rk##1##2\relax{\ifx##1.\relax \mathcode`,=\mathcode`-
@@ -765,21 +922,24 @@ indention=0pt,labelsep=colon,justification=raggedright}
% globally to a negative value. This doesn't harm, because it didn't
% contain relevant information anyway. Outside the group, the sign
% of |\FC@r| can then be tested. This is a slight misuse of this
-% |\count|, but now it's documented.
-%
-% If there was no decimal sign or if there was a decimal sign but no
-% decimal part, |\FC@r| will still be~1, which doesn't parse well with
-% |\secd@xt|, so a zero is appended.
+% |\count|, but now it's documented. In effect, |\FC@r| can only be~|-1|,
+% |1|, or at least~|10|, so the comparison |\ifnum\FC@r>0| does not mis~0.
% \begin{macrocode}
\def\e@fi{\ifnum\mathcode`\0=\mathcode`- \global\FC@r=\m@ne\fi$\egroup
\ifnum\FC@r>0
- \ifnum\FC@r<10 \multiply\FC@r by 10 \fi
% \end{macrocode}
-% Next is a loop for bringing the decimal part in the correct way to the
+% If there was no decimal mark or if there was a decimal mark but no
+% decimal part, |\FC@r| will still be~1, which doesn't parse well with
+% |\secd@xt|, so a zero is appended, i.e., yielding~|10|.
+% \begin{macrocode}
+ \ifnum\FC@r<10 \FC@r=10 \fi
+% \end{macrocode}
+% Next is a loop for bringing the decimal part in the correct way to
% the integer part. The loop is performed the number of decimal
% digits to be printed (the~2 in |3,2| of the default setting). This also
-% means that if you specified more decimal digits than this, the excess
-% digit(s) will not be handled and a |\PackageWarning| will be given.
+% means that if you provided more decimal digits than this, the excess
+% digit(s) will not be handled and a |\PackageWarning| will be given,
+% showing these excess digits. This is truncation, not rounding!
% \begin{macrocode}
\def\i@ts##1##2{\count0=##2}
\afterassignment\i@ts\count@\sp@l
@@ -896,22 +1056,23 @@ indention=0pt,labelsep=colon,justification=raggedright}
\let\@@array=\@array
% \end{macrocode}
% \end{macro}
+% Much of the techniques here are repeated in |\LT@array|.
% \subsection{The sumline, close to a postamble}
% \begin{macro}{\@mksumline}
% The construction of the sumline is much easier than that of the preamble
% for several reasons. It may be safely assumed that the preamble specifier
% is grammatically correct because it has already been screened by |\@mkpream|.
-% Furthermore most entries will simply add nothing to |\s@ml@ne|, e.g., |@|, |!|,
+% Furthermore, most entries will simply add nothing to |\s@ml@ne|, e.g., |@|, |!|,
% and \verb+|+ can be fully ignored. Ampersands are only inserted by |c|, |l|, |r|,
% |p|, |m|, and |b|. So a specifier like |@{}lflf@{}| will yield the sumline
% |&\a&&\a\\|, (where |\a| is a macro that prints the desired result of the column,
-% see later). Had the specifier been \verb+l|f||@{ }l|f+, then the same sumline must
+% see below). Had the specifier been \verb+l|f||@{ }l|f+, then the same sumline must
% be constructed: all difficulties are already picked up and solved in the creation
% of the preamble.
%
% In reality the sumline must be constructed from the expanded form of the
% specifier, so |@{}lf@{}| will expand as
-% |@{}l>{\b@fi{.}{,}{3,2}}r<{\e@fi}@{}|. The rules for constructing the
+% |@{}l>{\b@fi{.}{,}{3,2}{}}r<{\e@fi}@{}|. The rules for constructing the
% sumline are now very simple:
% \begin{compactitem}[$\bullet$]
% \item add an ampersand when |c|, |l|, |r|, |p|, |m|, or |b| is found,
@@ -925,7 +1086,7 @@ indention=0pt,labelsep=colon,justification=raggedright}
% be written, but that is not necessary: |\@testpach| can do all the work,
% although much of it will be discarded. Here speed is sacrificed for space
% and this can be afforded because the creation of the sumline is done only
-% once per |\tabular|.
+% once per |\tabular| or |\longtable|.
%
% The start is copied from |\@mkpream|.
% \begin{macrocode}
@@ -939,12 +1100,9 @@ indention=0pt,labelsep=colon,justification=raggedright}
% \end{macrocode}
% Then |\@mkpream| is picked up again.
% \begin{macrocode}
-\@temptokena{#1}
-\@tempswatrue
+\@temptokena{#1}\@tempswatrue
\@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
-\count0\m@ne
-\let\the@toks\relax
-\prepnext@tok
+\count0\m@ne\let\the@toks\relax\prepnext@tok
% \end{macrocode}
% Next is the loop over all tokens in the expanded form of the specifier. The change
% with respect to |\@mkpream| is that the body of the loop is now only dealing
@@ -955,10 +1113,8 @@ indention=0pt,labelsep=colon,justification=raggedright}
\expandafter \@tfor \expandafter \@nextchar
\expandafter :\expandafter =\the\@temptokena \do
{\@testpach
- \ifcase \@chclass \@classfz
- \or \or \@classfii \or
- \or \or \or \or \or \or \or \@classfx \fi
- \@lastchclass\@chclass}%
+ \ifcase \@chclass \@classfz \or \or \@classfii \or \or \or \or \or
+ \or \or \or \@classfx \fi\@lastchclass\@chclass}%
% \end{macrocode}
% And the macro is finished by applying the |\aut@check| and appending the
% |\\| to the sumline. Note that the |\aut@check| is performed {\itshape
@@ -1006,7 +1162,8 @@ indention=0pt,labelsep=colon,justification=raggedright}
\edef\t@stn{\string\e@fi}
\ifx\t@stm\t@stn
% \end{macrocode}
-% If both tests yield |true| then add the macro to typeset everything.
+% If both tests yield |true|, i.e., we encountered a |<{\e@fi}| where we expect one to
+% find, then add the macro to typeset everything.
% \begin{macrocode}
\@addtosumline{\prr@sult}
% \end{macrocode}
@@ -1074,12 +1231,14 @@ indention=0pt,labelsep=colon,justification=raggedright}
\def\sumline{\@ifnextchar[\s@mline{\s@mline[2pt]}}
\def\s@mline[#1]{\global\s@mlinesep=#1 \s@ml@ne}
% \end{macrocode}
+% In the introduction it was stated that |\sumline| has two options, but in
+% reality that second option is the option to |\\| that is issued by |\s@ml@ne|.
% \end{macro}
% \begin{macro}{\prr@sult}
% The macro |\prr@sult| actually puts the information together. It starts
% like |\leeg|.
% \begin{macrocode}
-\def\prr@sult{$\egroup \let\e@fi=\relax
+\def\prr@sult{$\egroup \let\e@fi=\relax \let\FCform@t=\FCform@tt
% \end{macrocode}
% Then the information for the last line is computed. It is not sufficient
% to calculate the width of the result (in points) to use that as the width
@@ -1126,7 +1285,7 @@ FCtot@\romannumeral\FCsc@l\endcsname}$}%
% table but it doesn't increase the totals of that column by~3 (assuming
% |3,2| coding for the separations). But you won't cheat, won't you?
% It may affect the width, so be careful: don't insert the unabridged
-% version of Romeo and Julia here.
+% version of Romeo and Juliet~\cite{RJ} here.
% \end{macro}
% \begin{macro}{\res@tsumline}
% Since all changes to the totals and widths of the columns are global,
@@ -1168,6 +1327,7 @@ FCtot@\romannumeral\FCsc@l\endcsname}$}%
% If the list |\FC@chklist| is empty, the list for the automatic check is
% generated (which will remain empty if |\FCsc@l| is odd).
% \begin{macrocode}
+\def\FC@chklist{}
\def\aut@check{\ifx\@empty\FC@chklist\relax
\ifodd\FCsc@l\else
\count0=\@ne \count1=\FCsc@l
@@ -1217,12 +1377,84 @@ FCtot@\romannumeral\FCsc@l\endcsname}$}%
\def\checkfcolumns#1#2{\noalign{\xdef\FC@chklist{\FC@chklist #1,#2;}}}
% \end{macrocode}
% \end{macro}
+% \subsection{Support for package longtable}
+% Package |longtable| is used for tables that may span multiple pages. |fcolumn| and
+% |longtable| work together as long as |longtable| is loaded first, so that |fcolumn|
+% can adapt one definition of |longtable|. If |longtable| is not loaded, that definition
+% is just that: a definition. If |longtable| is loaded before |fcolumn|, it is a
+% redefinition, and it should be. For that reason the user is warned (not loading
+% |longtable| is not an error if you don't use it) if |fcolumn| is loaded without prior
+% loading of |longtable|.
+% \begin{macrocode}
+\ifx\longtable\@undefined
+ \PackageWarning{fcolumn}{fcolumn is loaded without longtable. That's
+ OK, but\MessageBreak if you want to load longtable as well, make sure
+ \MessageBreak it is done before loading fcolumn}
+\fi
+% \end{macrocode}
+% \begin{macro}{\LT@array}
+% And here is the only definition of |longtable| that needs to be adapted a bit, to make
+% |fcolumn| work with that package.
+% \begin{macrocode}
+\def\LT@array[#1]#2{%
+ \refstepcounter{table}\stepcounter{LT@tables}%
+ \if l#1 \LTleft\z@\LTright\fill
+ \else\if r#1 \LTleft\fill\LTright\z@
+ \else\if c#1 \LTleft\fill\LTright\fill
+ \fi\fi\fi
+ \let\LT@mcol\multicolumn\let\LT@@tabarray\@tabarray\let\LT@@hl\hline
+ \def\@tabarray{\let\hline\LT@@hl \LT@@tabarray}%
+ \let\\\LT@tabularcr\let\tabularnewline\\%
+ \def\newpage{\noalign{\break}}%
+ \def\pagebreak{\noalign{\ifnum`}=0\fi\@testopt{\LT@no@pgbk-}4}%
+ \def\nopagebreak{\noalign{\ifnum`}=0\fi\@testopt\LT@no@pgbk4}%
+ \let\hline\LT@hline\let\kill\LT@kill\let\caption\LT@caption
+ \@tempdima\ht\strutbox\let\@endpbox\LT@endpbox
+ \ifx\extrarowheight\@undefined
+ \let\@acol\@tabacol\let\@classz\@tabclassz\let\@classiv\@tabclassiv
+ \def\@startpbox{\vtop\LT@startpbox}\let\@@startpbox
+ \@startpbox\let\@@endpbox\@endpbox\let\LT@LL@FM@cr\@tabularcr
+ \else
+ \advance\@tempdima\extrarowheight \col@sep\tabcolsep
+ \let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr
+ \fi
+ \setbox\@arstrutbox\hbox{\vrule\@height\arraystretch\@tempdima
+ \@depth\arraystretch\dp\strutbox\@width\z@}%
+ \let\@sharp##\let\protect\relax
+ \begingroup
+ \@mkpream{#2}%
+ \xdef\LT@bchunk{%
+ \global\advance\c@LT@chunks\@ne\global\LT@rows\z@
+ \setbox\z@\vbox\bgroup\LT@setprevdepth\tabskip\LTleft
+ \noexpand\halign to\hsize\bgroup\tabskip\z@\@arstrut
+ \@preamble\tabskip\LTright\cr}%
+ \endgroup
+% \end{macrocode}
+% Until this line it was just the code for |\LT@array| from package |longtable|.
+% The five lines of the next chunk are new to |\LT@array|. Their
+% purpose is the same as in |\@array| above.
+% \begin{macrocode}
+ \begingroup
+ \@mksumline{#2}%
+ \endgroup
+ \res@tsumline
+ \everycr{\noalign{\global\FCsc@l=0 }}%
+% \end{macrocode}
+% From here on |\LT@array| is picked up again.
+% \begin{macrocode}
+ \expandafter\LT@nofcols\LT@bchunk&\LT@nofcols
+ \LT@make@row\m@th\let\par\@empty
+ \lineskip\z@\baselineskip\z@\LT@bchunk}
+% \end{macrocode}
+% \end{macro}
% That's it!
% \section*{Acknowledgement}
% Thanks to Karl Berry for valuable comments regarding the consistency of
% the installation procedure of this version. Frank Mittelbach gave
% various useful suggestions for improving the input parsing as well as
-% hints to make the package more \LaTeX-like.
+% hints to make the package more \LaTeX-like. He also challenged me to make |fcolumn|
+% compatible with |longtable|. Christian Hoff's request on column formatting triggered
+% many happy hours of coding.
% \bibliographystyle{plain}
% \begin{thebibliography}{9}
% \itemsep0pt
@@ -1232,10 +1464,12 @@ FCtot@\romannumeral\FCsc@l\endcsname}$}%
% A new implementation of \LaTeX's |tabular| and |array| environment.
% \bibitem{booktabs} Simon Fear. Publication quality tables in \LaTeX.
% \bibitem{dcolumn} David Carlisle. The |dcolumn| package.
+% \bibitem{longtable} David Carlisle. The |longtable| package.
% \bibitem{world_economy} According to the IMF \url{www.imf.org}.
% \bibitem{CandTB} Donald Knuth, Computers \& Typesetting/B, \TeX: the program.
% \bibitem{CandTA} Donald Knuth, Computers \& Typesetting/A, The \TeX book.
% \bibitem{TAOCP1} Donald Knuth, The Art of Computers Programming, volume~1.
+% \bibitem{RJ} William Shakespeare, Romeo and Juliet, a tragedy (1597).
% \end{thebibliography}
% \Finale
\endinput