summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/calctab/README27
-rw-r--r--Master/texmf-dist/doc/latex/calctab/calctab_manual.pdfbin430027 -> 470403 bytes
-rw-r--r--Master/texmf-dist/doc/latex/calctab/calctab_manual.tex450
-rw-r--r--Master/texmf-dist/tex/latex/calctab/calctab.sty559
4 files changed, 766 insertions, 270 deletions
diff --git a/Master/texmf-dist/doc/latex/calctab/README b/Master/texmf-dist/doc/latex/calctab/README
index ef4decb138d..03c5f9946b0 100644
--- a/Master/texmf-dist/doc/latex/calctab/README
+++ b/Master/texmf-dist/doc/latex/calctab/README
@@ -1,20 +1,27 @@
-calctab package - Autocalc table environment
-experimental version 0.5 2009/02/20
+calctab package - A language for numeric tables
+version 0.6 2009/03/28
-The calctab package help the user to typeset a kind of economic table such as invoices, expense notes and liquidation, or other tabular material with a values column.
-The code compute sum and percentage with floating point numeric method (with fltpoint package by Eckhart Guthoehrlein) and formatting table action.
+1 - Introduction
+The calctab package helps the user to typeset a kind of economic table such as invoices, expense notes and liquidation, or other tabular material with a values columns.
+The code computes sum and percentage with floating point numeric method (with the fltpoint package by Eckhart Guthoehrlein) and builds the render table task.
+Economics items may be are independent values or not like sums and percentage on previous values. The language must be expressive concerning together data and its relationships.
-A standard tabular environment works well but force the user to write in a generic LaTeX language without a conceptual relation among the economic items. In addition a lot of formatting command takes the same relevance of the document main data.
+2 - Calctab and xcalctab environments
+The calctab environment allow you to typesetting a table with only one values column beside a label and a description columns.
+In the xcalctab environment the values of two columns are multiplied and the result is printed in a third column.
+Please read the calctab user manual for more information and example.
-So, the priority is to add a new language element.
+3 - Language
+A standard tabular environment works well but force the user to think in a generic LaTeX language without a conceptual relation among the items. In addition a lot of formatting commands takes the same relevance of the main data.
-Economics items may be are independent values or not like sums and percentage on previous values. The language must be expressive concerning together data and its relations.
+4 - Feedback and language enhancements
+This version waiting for the user help and feedback and somehow a powerful implemented language to adjust all the view property such as row numbering, label type, coloring, etc.
+Finally, I hope in a new infrastructure design which allow to building table with an object oriented language (ool).
-This experimental version waiting for the user help and feedback and somehow a powerful implemented language to adjust all the view property such as row numbering, label operation, coloring, etc.
+5 - Package license
+This program can be redistributed and/or modified under the terms of the LaTeX Project Public License Distributed from CTAN archives in directory macros/latex/base/lppl.txt; either version 1 of the License, or any later version.
Happy TeXing!
Copyright (C) 2009 Roberto Giacomelli -- giaconet at tin dot it
-This program can be redistributed and/or modified under the terms of the LaTeX Project Public License Distributed from CTAN archives in directory macros/latex/base/lppl.txt; either version 1 of the License, or any later version.
-
diff --git a/Master/texmf-dist/doc/latex/calctab/calctab_manual.pdf b/Master/texmf-dist/doc/latex/calctab/calctab_manual.pdf
index a76f2f1b304..28897a1323a 100644
--- a/Master/texmf-dist/doc/latex/calctab/calctab_manual.pdf
+++ b/Master/texmf-dist/doc/latex/calctab/calctab_manual.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/calctab/calctab_manual.tex b/Master/texmf-dist/doc/latex/calctab/calctab_manual.tex
index 2a816b9ff3f..054afcb4277 100644
--- a/Master/texmf-dist/doc/latex/calctab/calctab_manual.tex
+++ b/Master/texmf-dist/doc/latex/calctab/calctab_manual.tex
@@ -2,10 +2,10 @@
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
-\usepackage[left=32mm,
- right=45mm,
- top=32mm,
- bottom=28mm]{geometry}
+\usepackage[ left=32mm,
+ right=45mm,
+ top=32mm,
+ bottom=28mm]{geometry}
\usepackage[english]{babel}
@@ -14,6 +14,13 @@
\usepackage{microtype}
\usepackage{url}
\usepackage{fancyvrb}
+\usepackage{caption}
+\usepackage[ pdfauthor={Roberto Giacomelli},
+ pdfsubject={Calctab package user manual},
+ pdfkeywords={table, invoice, expense note, report},
+ pdftitle={Calctab user manual},
+ colorlinks,
+ linkcolor=blue]{hyperref}
% set the Verbatim environment
\fvset{numbers=left,numbersep=7pt}
@@ -27,130 +34,146 @@
\newcommand{\env}[1]{\textsf{#1}}
\newcommand{\cmd}[1]{\texttt{\char`\\#1}}
\newcommand{\meta}[1]{\ensuremath{\langle}\emph{#1}\ensuremath{\rangle}}
-\newcommand{\graffe}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
-\newcommand{\quadre}[1]{\texttt{[}\meta{#1}\texttt{]}}
+\newcommand{\curlyp}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
+\newcommand{\squarep}[1]{\texttt{[}\meta{#1}\texttt{]}}
\author{Roberto Giacomelli\\e-mail: \texttt{giaconet at tin dot it}}
-\date{2009/02/20}
-\title{\ct{} package\\Experimental version\\0.5}
+\date{2009/03/28}
+\title{\ct{} package\\version 0.6}
\begin{document}
\maketitle
\bigskip
-\hspace*{238pt}\begin{minipage}{125pt}
-\em
-``The table compute the sum\\
+\hspace*{238pt}\begin{minipage}{125pt}\em
+``The table computes the sum\\
not because is useful,\\
but because the result\\
-is not an user essential data.''
+is not an user essential data''
\end{minipage}
-\bigskip
+\vfill
\begin{center}
-\begin{minipage}{96mm}%.8\textwidth
+\begin{minipage}{112mm}%.8\textwidth
\tableofcontents
\end{minipage}
\end{center}
-
-
-\bigskip
+\vfill
+\newpage
+%
+%
+%
\section{Introduction}
-The \pkg{calctab} package help the user to typeset a kind of economic table such as invoices, expense notes and liquidation, or other tabular material with a values column.
+The \pkg{calctab} package helps user to typeset a kind of economic table such as invoices, expence notes and liquidation, or other tabular material with numeric columns.
-A normal \env{tabular} environment works well but force the user to write in a generic \LaTeX{} language without a conceptual relation among the economic items. In addition a lot of formatting command takes the same relevance of the document main data.
-
-So, the priority is to add a new language element.
-
-Economics items may be are independent values or not like sums and percentage on previous values. The language must be expressive concerning together data and its relations.
-
-\section{ToDo}
-I don't know if in the future this package will merge into another or became under further development. I hope in user discussion on the language issues and implementation too.
+A normal \env{tabular} environment works well but force user to \emph{think} in a generic \LaTeX{} language to reference the object of his work and without a conceptual relation among these. In addition a lot of formatting commands takes the same relevance of the main user data.
-The code have a good level of stability, nevertheless the package is considered experimental because some essential tasks are in \emph{ToDo} status as result in the following list:
-
-\begin{itemize}
- \item write in good english the package documentation;
- \item internationalization of the table fixed description string;
- \item internationalization of the currency unit;
- \item inner commands language development;
- \item language development to manage the table view;
- \item \dots
-\end{itemize}
-
-The enthusiasm raised during GuITmeeting2008 in Pisa (Italy)\footnote{For information please visit the site \url{www.guit.sssup.it/guitmeeting/2008/2008.it.php}} by the talk \emph{``Una tabella che fa calcoli''} and the tip by Norbert Preining (Vienna University of Technology) to upload on CTAN the code in experimental section, finally persuade me to publish it.
-
-Thanks GuITmeeting2008 people, thanks Norbert.
+Economic items maybe are independent values or not like sums and percentages on previous values. The language must be expressive concerning together data and its relations. So, the priority is to add a new language element.
+%
+%
+%
\section{User manual}
-In this section will be explain the use of the environment \pkg{calctab}, first through several examples and later showing its formal syntax.
+In this section will be explain the use of the two \ct{} environments \env{calctab} and \env{xcalctab}, first through several examples and then showing its formal syntax.
-\subsection{\pkg{calctab} by examples}
-\subsubsection{Simple table}
-Well, starting with a simple case, consider a list of three entries with a final sum as showed in the next table:
+%
+%
+\subsection{\env{calctab} and \env{xcalctab} by examples}
+%
+\subsubsection{A simple table}
+Well, starting with a simple case, consider a list of three entries, a 10\% tax apply on it, and the final sum as showed in the next table:
\begin{calctab}
- \amount{First cost}{12500,9}
- \amount{Second cost}{8560,03}
- \amount{Third cost}{9200,45}
- \add{Final sum}
+ \amount{First cost}{12500,9}
+ \amount{Second cost}{8560,03}
+ \amount{Third cost}{9200,45}
+ \perc{Tax}{10}
+ \add{Total cost}
\end{calctab}
-\bigskip
+The user can typesetting the example table with the followed code (obviously, the directive \verb=\usepackage{calctab}= must be present in the document preamble).
-To mark items as independent value we can use the \verb=\amount= command, which needs two mandatory arguments: an item description text and its economic consistency.
-
-In the last row, the \verb=\add= command have care to execute the sum of the previous amount, thus only a description text needs as input.
-
-So, the user can typesetting the table with the \LaTeX{} source code show next. Obviously, the directive \verb=\usepackage{calctab}= must be present in the document preamble.
+{\color{blue}
+\begin{Verbatim}[numbers=none]
+% in the document preamble
+\usepackage{calctab}
+\end{Verbatim}
+}
\begin{Verbatim}
+% in the document body
\begin{calctab}
- \amount{First cost}{12500,9}
- \amount{Second cost}{8560,03}
- \amount{Third cost}{9200,45}
- \add{Final sum}
+ \amount{First cost}{12500,9}
+ \amount{Second cost}{8560,03}
+ \amount{Third cost}{9200,45}
+ \perc{Tax}{10}
+ \add{Total cost}
\end{calctab}
\end{Verbatim}
-The behaviour of the inner commands is based on these rules:
+The behaviour of the inner commands is based on these main rules:
\begin{itemize}
\item Each command typeset one table row;
- \item the sequence of commands produce the sequence of the table row;
- \item \verb=\add= command sum all previous values (with exception to \verb=\add= values so).
+ \item the sequence of commands produce the sequence of the table rows;
+ \item the \verb=\perc= and the \verb=\add= commands computes all previous values (with exception to the \verb=\add= row);
+ \item optional command argument provides a relation row language to select item or groups of items.
\end{itemize}
-The environment manages all the formatting elements of table as colored rows, rules, description entry row. The command execute calculation in floating point algorithm and adds description text (a list of uppercase letter to explicate the rows computed).
-Also commands execute formatting task as numeric values printing, font family selection and more.
+An independent value is not only a numeric data but also it's defined by a description text. This concept is directly express by the \verb=\amount= command which needs two mandatory arguments: the \emph{description text} and the item \emph{economic consistency}.
-Potentially all of these \emph{visual} property could be adjust by the \pkg{calctab} user.
+No more different is a percentage object structure with its description text and a numeric value this time not an absolute number but a factor multiply by one hundred calculate on some previous data, and still we can easy express this with the \verb=\perc= command.
-\subsubsection{Percentage}
+Finally, we encountered a sum that only needs a description text. The \pkg{calctab} language provides the \verb=\add= command to cover this concept.
-Now we discuss the last inner command of the environment \pkg{calctab} named \verb=\perc= to compute a percentage.
+These three commands are available in an environment called \env{calctab} that represents the comprehensive structure of a table.
-In this second example we have only three items: an independent value, an its percentage, and the sum of all.
+The code implementation of the inner commands computes the numeric results with the floating point algorithm rounded it with a max of two decimal digit (currently the results are truncated at this fixed precision).
+The number of the commands mandatory argument can be negative.
-\begin{calctab}
- \amount{Building costruction}{560000}
- \perc{Tax}{10}
- \add{Total}
-\end{calctab}
+The \env{calctab} environment manages all the table format elements such as the rows color, the rules, the columns header description text, etc.
+Furthermore, the code executes the data numeric formatting, the font family selection and more.
-The \LaTeX{} code to produce the table is show here:
+For example, to the rows description text the \verb=\add= and \verb=\perc= commands adds a list of uppercase alphabetical character to explicate the computed rows.
+
+Potentially all of these \emph{visual} property could be adjust by the \pkg{calctab} user.
+
+%
+\subsubsection{Quantity and price columns}
+The \pkg{calctab} package provides another environment called \env{xcalctab} where the \env{x} character suggests a multiply operation and an extension of the base \env{calctab} too.
+The inner commands are the same already discussed except the \verb=\amount= command that accepts the description test and two numbers indeed only one.
+
+The final table will appears with three columns typesetting with the two numeric arguments and their product. The next table clarify this structure:
+
+\begin{xcalctab}
+ \amount{Newspapers}{3}{1,30}
+ \amount{Coloured pencils}{12}{6,00}
+ \amount{Maths exercise book}{6}{2,50}
+ \amount{Compass}{1}{9,90}
+ \amount{Ruler}{1}{5,90}
+ \amount{Protractor}{1}{6,80}
+ \perc{Deduction}{-5}
+ \add{Total}
+\end{xcalctab}
\begin{Verbatim}
-\begin{calctab}
- \amount{Building costruction}{560000}
- \perc{Tax}{10}
+\begin{xcalctab}
+ \amount{Newspapers}{3}{1,30}
+ \amount{Coloured pencils}{12}{6,00}
+ \amount{Maths exercise book}{6}{2,50}
+ \amount{Compass}{1}{9,90}
+ \amount{Ruler}{1}{5,90}
+ \amount{Protractor}{1}{6,80}
+ \perc{Deduction}{-5}
\add{Total}
-\end{calctab}
+\end{xcalctab}
\end{Verbatim}
-The number of the second argument of \verb=\perc= command is interpreted as percentage value so not in absolute mode. This number may be negative with a max of two decimal digit (currently number are truncated at this point).
-
+The help text A+B+C+D+$\cdots$+\meta{LAST}, will be shorted when the items are more than \emph{five} elements, in A+B+$\cdots$+\meta{LAST}. The abbreviation condition is true only if the items in the subgroup are a consecutive sequence.
+%
+%
+%
\subsubsection{Items relations}
If more complex tables require \emph{relational} information between rows is necessary to assign to it a names and recall these identifier in a list. This simply way can be achieved with the command optional argument.
@@ -169,55 +192,96 @@ For example, we want to apply a different discount on each expense or on each gr
\add{Grand total}
\end{calctab}
-The next \LaTeX{} code show rows relation by name:
+The next \LaTeX{} code explains language support to the rows relation by naming :
\begin{Verbatim}
\begin{calctab}
- \amount[id=dinner]{Five dinner}{146}
+ \amount[id=dinner] {Five dinner}{146}
\amount[id=breakfast]{Five breakfast}{35}
- \perc[dinner]{Discount}{-8}
+ \perc[dinner] {Discount}{-8}
\perc[breakfast]{Discount}{-4}
\add{Grand total}
\end{calctab}
\end{Verbatim}
-\subsubsection{Sums in table}
-In the table of the last example we will add a subtotal as the sum of discounts (and a short table description paragraph too):
+\subsubsection{Subtotals}
+To the table of the last example we will add a subtotal as the sum of the discounts row.
\begin{calctab}[Hotel bill:\\
Period from 12 october 2008 to 18 october 2008 (room 456)]
- \amount[id=dinner] {Five dinner} {146}
- \amount[id=breakfast] {Five breakfast}{35}
- \perc[id=dis8,dinner] {Discount} {-8}
- \perc[id=dis4,breakfast]{Discount} {-4}
- \add[dis8,dis4]{Total of discount}
- \add{Grand total}
+ \amount[id=dinner] {Five dinner} {29,2 * 5}
+ \amount[id=breakfast] {Five breakfast}{ 7 * 5}
+ \perc[id=dis8,dinner] {Discount} { -8}
+ \perc[id=dis4,breakfast]{Discount} { -4}
+ \add[dis8,dis4] {Total of discount}
+ \add {Grand total}
\end{calctab}
\bigskip
-The table's \LaTeX{} code is this:
\begin{Verbatim}
\begin{calctab}[Hotel bill:\\
Period from 12 october 2008 to 18 october 2008 (room 456)]
- \amount[id=dinner] {Five dinner} {146}
- \amount[id=breakfast] {Five breakfast}{35}
- \perc[id=dis8,dinner] {Discount} {-8}
- \perc[id=dis4,breakfast]{Discount} {-4}
- \add[dis8,dis4]{Total of discount}
- \add{Grand total}
+ \amount[id=dinner] {Five dinner} {29,2 * 5}
+ \amount[id=breakfast] {Five breakfast}{ 7 * 5}
+ \perc[id=dis8,dinner] {Discount} { -8}
+ \perc[id=dis4,breakfast]{Discount} { -4}
+ \add[dis8,dis4] {Total of discount}
+ \add {Grand total}
\end{calctab}
\end{Verbatim}
-As the reader can be notice, \emph{table description} is typeset as a paragraph having the same (variable) table width.
+As the reader can be notice, the optional \emph{table description} is typeset as a paragraph having the same (variable) table width.
+
+%
+%
+%
+\subsubsection{An arithmetic argument}
+The last example silently uses a feature of the \cmd{amount} command (only for \env{calctab} and not for \env{xcalctab}) available from the package version 0.6. The numeric argument can optionally be a binary math expression. The parse algorithm is very simple and the only syntax allowed are show in Tab.~\ref{tabOper} where \meta{a} and \meta{b} are two decimal numbers.
+
+\begin{table}
+\centering
+\caption{\env{calctab} \cmd{amount} command optional binary operation}
+\label{tabOper}
+\begin{tabular}{lrr}\toprule
+ Floating point & \multicolumn1c{Symbolic} & Numeric \\
+ operation & \multicolumn1c{description} & example \\\midrule
+% \emph{Addition} & \meta{a} $+$ \meta{b} & $15{,}20 + 41$\\
+ \emph{Addition} & $-$\meta{a} $+$ \meta{b} & $-15{,}20 + 41$\\
+ \emph{Subtraction} & \meta{a} $-$ \meta{b} & $15{,}20 - 41$\\
+ \emph{Subtraction} & $-$\meta{a} $-$ \meta{b} & $-15{,}20 - 41$\\
+ \emph{Multiplication} & \meta{a} $\cdot$ \meta{b} & $15{,}20 \cdot 41$\\
+ \emph{Multiplication} & $-$\meta{a} $\cdot$ $-$\meta{b} & $-15{,}20 \cdot -41$\\
+ \emph{Division} & \meta{a} $/$ \meta{b} & $15{,}20 / 41$\\
+ \emph{Division} & $-$\meta{a} $/$ \meta{b} & $-15{,}20 / 41$\\\bottomrule
+\end{tabular}
+\end{table}
+
+Sometimes the applied round off number must be show in the table. This is possible because the code report the input user operation. Here is an example.
-\subsubsection{Sum of the sum}
+\begin{calctab}
+ \amount{A rounded cost}{4506-6}
+ \amount{Positive rounded cost}{3598,30+1,70}
+ \add{Total (rounded)}
+\end{calctab}
+
+\begin{Verbatim}
+\begin{calctab}
+ \amount{A rounded cost}{4506-6}
+ \amount{Positive rounded cost}{3598,30+1,70}
+ \add{Total (rounded)}
+\end{calctab}
+\end{Verbatim}
+
+
+\subsubsection{Sum of the sums}
+In this table a 20\% deduction amount must be apply on the total of the first three values. A solution is to assign a name for each rows and write its list in optional argument of \cmd{perc} command. Nevertheless, this sum is just computed in previus row, thus we can assign a name only to this table row \texttt{\cmd{add}[id=total]\{Total amount of the design task\}}, and later recall the result and then apply percentage on it with the line \texttt{\cmd{perc}[total]\{Deduction\}\{-20\}}.
\begin{calctab}[Plant project Fee Note:\\
Italian restaurant and pizzeria ``La Margherita'']
\amount{Design of the air conditioned plant}{5400}
\amount{Design of the electric plant and video surveillance}{8000}
- \perc{General expense}{8,55}
+ \perc{General expence}{8,55}
\add[id=total]{Total amount of the design task}
\perc{Tax}{2}
\perc{VAT}{20}
@@ -225,15 +289,14 @@ As the reader can be notice, \emph{table description} is typeset as a paragraph
\add{Total}
\end{calctab}
-In this table a 20\% deduction amount must be apply on the total of the first three values. A solution is to assign a name for each rows and write its list in optional argument of \cmd{perc} command. Nevertheless, this sum is just computed in previus row, thus we can assign a name only to this table row \texttt{\cmd{add}[id=total]\{Total amount of the design task\}}, and later recall the result and then apply percentage on it with the line \texttt{\cmd{perc}[total]\{Deduction\}\{-20\}}.
-The complete code is show next:
+The complete code is showed here:
\begin{Verbatim}
\begin{calctab}[Plant project Fee Note:\\
Italian restaurant and pizzeria ``La Margherita'']
\amount{Design of the air conditioned plant}{5400}
\amount{Design of the electric plant and video surveillance}{8000}
- \perc{General expense}{8,55}
+ \perc{General expence}{8,55}
\add[id=total]{Total amount of design task}
\perc{Tax}{2}
\perc{TVA}{20}
@@ -243,12 +306,10 @@ The complete code is show next:
\end{Verbatim}
\subsubsection{Interval rows selection}
-In some particular list of independent values the idea of interval selection is simply a consecutive group selection. So we only need to specify the first and the last element of the series.
-If the first element is no explicit information its default is the element one, and similary, the last element of whole dataset became the default if a limit is no available.
+In an independent values list the idea of interval selection is simply an identification of consecutive elements. So we only need to specify the first and the last group delimiters rows of the series.
+If the first element is not an explicit information the element one becames default and, similary, the last element of whole dataset becames the upper limit if this is not available.
-The \ct{} commands \cmd{perc} and \cmd{add} support an interval selection with \texttt{from} and \texttt{until} keys that referenced row name.
-
-For example in this follow table the first five items and the last four are two separated group.
+The \ct{} commands \cmd{perc} and \cmd{add} supports an interval selection with \texttt{from} and \texttt{until} keys that referenced row name. For example in this follow table the first five items and the last four are two separated groups.
\begin{calctab}[The interval selection table]
\amount{One} {100000000}
@@ -256,6 +317,7 @@ For example in this follow table the first five items and the last four are two
\amount{Three} {3000000}
\amount{Four} {400000}
\amount[id=five]{Five}{50000}
+ \inrule
\amount[id=six]{Six} {6000}
\amount{Seven} {700}
\amount{Eight} {80}
@@ -265,8 +327,6 @@ For example in this follow table the first five items and the last four are two
\add{As well as total}
\end{calctab}
-The code needs to render this demo table is explain here:
-
\begin{Verbatim}
\begin{calctab}[The interval selection table]
\amount {One}{100000000}
@@ -274,6 +334,7 @@ The code needs to render this demo table is explain here:
\amount {Three}{3000000}
\amount {Four}{400000}
\amount[id=five]{Five}{50000}
+ \inrule
\amount[id=six] {Six}{6000}
\amount {Seven}{700}
\amount {Eight}{80}
@@ -284,65 +345,120 @@ The code needs to render this demo table is explain here:
\end{calctab}
\end{Verbatim}
-Is possible to combine the keys \texttt{until} and \texttt{from} in the same optional argument to select a whole inner interval, and a row name list too.
-In case of selection overlap, a package warning will be throws at compile time.
+An inner rule is adding \emph{manually} with the command \cmd{inrule} (that just sounds \emph{inner rule}).
-\subsection{Environment formal syntax}
+Is possible to combine the key \texttt{until} with the key \texttt{from} in the same optional argument to select a whole inner interval, and a row name list too.
+In case of a selection overlap, a package warning will be throws at compile time.
-The environment syntax will be described follow:
+\subsection{Environments formal syntax}
+\subsubsection{\env{calctab} syntax}
+The \env{calctab} environment syntax will be described in succession:
\medskip
\noindent\fbox{
\parbox{220pt}{
- \noindent\cmd{begin}\texttt{\{calctab\}}\quadre{description paragraph}\smallskip
+ \noindent\cmd{begin}\texttt{\{calctab\}}\squarep{description paragraph}\smallskip
\hspace*{5mm}\meta{calctab commands list}\smallskip
\noindent\cmd{end}\texttt{\{calctab\}}
}
+}\medskip
+
+The \meta{calctab commands list} is a sequence of the internal commands \cmd{amount}, \cmd{perc}, \cmd{add} and \cmd{inrule}.\medskip
+
+\noindent\fbox{\cmd{amount}\squarep{key-value list}\curlyp{description}\curlyp{value}}\medskip
+
+\meta{key-value list} $=$ \texttt{id=}\meta{rowID};\medskip
+
+\meta{description} $=$ Text line;\medskip
+
+\meta{value} $=$ \meta{decimal value} or \meta{basic binary operation}.\medskip
+
+\noindent\fbox{\cmd{perc}\squarep{key-value list}\curlyp{description}\curlyp{percentage}}\medskip
+
+\meta{key-value list} $=$ \texttt{id=}\meta{rowID}\texttt{,} \texttt{from=}\meta{rowID}\texttt{,} \texttt{until=}\meta{rowID}\texttt{,} \meta{rowID~list};\medskip
+
+\meta{description} $=$ Text line;\medskip
+
+\meta{value} $=$ \meta{percentage decimal value}.\medskip
+
+\noindent\fbox{\cmd{add}\squarep{key-value list}\curlyp{description}}\medskip
+
+\meta{key-value list} $=$ \texttt{id=}\meta{rowID}\texttt{,} \texttt{from=}\meta{rowID}\texttt{,} \texttt{until=}\meta{rowID}\texttt{,} \meta{rowID~list};\medskip
+
+\meta{description} $=$ Text line.\medskip
+
+\noindent\fbox{\cmd{inrule}}\medskip
+
+
+\subsubsection{\env{xcalctab} syntax}
+The \pkg{xcalctab} environment syntax will be described in the next paragraph:
+
+\medskip
+\noindent\fbox{
+ \parbox{220pt}{
+ \noindent\cmd{begin}\texttt{\{xcalctab\}}\squarep{description paragraph}\smallskip
+
+ \hspace*{5mm}\meta{xcalctab commands list}\smallskip
+
+ \noindent\cmd{end}\texttt{\{xcalctab\}}
+ }
}
\medskip
-where \meta{calctab commands list} is a sequence of the internal commands:\medskip
+The \meta{xcalctab commands list} is a sequence of the internal commands \cmd{amount}, \cmd{perc}, \cmd{add} and \cmd{inrule}.\medskip
+\noindent\fbox{\cmd{amount}\squarep{key-value list}\curlyp{description}\curlyp{value1}\curlyp{value2}}\medskip
-\noindent\fbox{\cmd{amount}\texttt{[id=}\meta{rowID}\texttt{]}\graffe{descr}\graffe{value}}\medskip
+\meta{key-value list} $=$ \texttt{id=}\meta{rowID};\medskip
-\noindent\fbox{\cmd{perc}\texttt{[id=}\meta{rowID}\texttt{,from=}\meta{rowID}\texttt{,until=}\meta{rowID}\texttt{,}\meta{rowID~list}\texttt{]}\graffe{descr}\graffe{percentage}}\medskip
+\meta{description} $=$ Text line;\medskip
-\noindent\fbox{\cmd{add}\texttt{[id=}\meta{rowID}\texttt{,from=}\meta{rowID}\texttt{,until=}\meta{rowID}\texttt{,}\meta{rowID~list}\texttt{]}\graffe{descr}}
+\meta{value1} $=$ \meta{decimal value};\medskip
-\medskip
-Please note that the \pkg{calctab} environment is based on the standard \LaTeX{} \env{tabular} environment, so you can manage \pkg{calctab} as a float object all-surrounding it with a \pkg{table} environment.
+\meta{value2} $=$ \meta{decimal value}.\medskip
+
+\noindent\fbox{\cmd{perc}\squarep{key-value list}\curlyp{description}\curlyp{percentage}}\medskip
+
+\meta{key-value list} $=$ \texttt{id=}\meta{rowID}\texttt{,} \texttt{from=}\meta{rowID}\texttt{,}
+\texttt{until=}\meta{rowID}\texttt{,} \meta{rowID~list};\medskip
-\subsection{Appearance commands (at the moment)}
+\meta{description} $=$ Text line;\medskip
+
+\meta{value} $=$ \meta{percentage decimal value}.\medskip
+
+\noindent\fbox{\cmd{add}\squarep{key-value list}\curlyp{description}}\medskip
+
+\meta{key-value list} $=$ \texttt{id=}\meta{rowID}\texttt{,} \texttt{from=}\meta{rowID}\texttt{,} \texttt{until=}\meta{rowID}\texttt{,} \meta{rowID~list};\medskip
+
+\meta{description} $=$ Text line.\medskip
+
+\noindent\fbox{\cmd{inrule}}\medskip
+
+Please note that the \pkg{calctab} and \pkg{xcalctab} environments are based on the standard \LaTeX{} \env{tabular} environment, so you can manage your table as a float object all-surrounding it with a \pkg{table} environment.
+
+\subsection{The table appearance commands (at the moment)}
The first row of the table typeset by \pkg{calctab} environment contains a pair of texts. The title of description column, that can be modify by the user with the command \cmd{ctdescription}, and the title of economic column that describe currency, set by the command \cmd{ctcurrency}. Default values are ``\texttt{Items description}'' and \cmd{euro}.
These command save the argument in defined internal macro, in the same way of the common \cmd{title} and \cmd{author} command of the \pkg{article} class. Insert these commands before the \pkg{calctab} environment to change it.
\bigskip
-\noindent\fbox{\cmd{ctcurrency}\graffe{user text}}
+\noindent\fbox{\cmd{ctcurrency}\curlyp{user text}}
\smallskip
-\noindent\fbox{\cmd{ctdescription}\graffe{user text}}
+\noindent\fbox{\cmd{ctdescription}\curlyp{user text}}
\bigskip
-An example show explicit assignment of the description text and currency unit:
+A table example show explicit assignment of the description text and currency unit after this commands:
+\begin{Verbatim}
\ctdescription{Your bill, thanks a lot.}
\ctcurrency{USD}
+\end{Verbatim}
-\begin{calctab}
- \amount[id=dinner]{Five dinner}{146}
- \amount[id=breakfast]{Five breakfast}{35}
- \perc[dinner]{Discount}{-8}
- \perc[breakfast]{Discount}{-4}
- \add{Grand total}
-\end{calctab}
-
-\begin{Verbatim}
\ctdescription{Your bill, thanks a lot.}
\ctcurrency{USD}
@@ -353,14 +469,22 @@ An example show explicit assignment of the description text and currency unit:
\perc[breakfast]{Discount}{-4}
\add{Grand total}
\end{calctab}
-\end{Verbatim}
-The default english text in percentage row can be change in the same way with the command \cmd{ctontranslation}.
+The default english text in percentage row can be changed in the same way with the command \cmd{ctontranslation}
\bigskip
-\noindent\fbox{\cmd{ctontranslation}\graffe{on traslation}}
+\noindent\fbox{\cmd{ctontranslation}\curlyp{on traslation}}
+\bigskip
-\subsection{Table width}
+and the headers of the two \env{xcalctab} numeric columns can be setting with
+
+\bigskip
+\noindent\fbox{\cmd{ctheaderone}\curlyp{first col text header}}
+\noindent\fbox{\cmd{ctheadertwo}\curlyp{second col text header}}
+%
+%
+%
+\subsection{Increment the table width}
The width of the \ct{} table can be adjust via a standard \LaTeX{} length called \cmd{ctsep} (default value is 8mm). The horizontal space will be add to the central column of the table. The next line is an example:
\medskip
@@ -371,6 +495,20 @@ The language efficacy is particularly important for the \LaTeX{} user. The \ct{}
So one \emph{model} of structured data, can have more and more presentation \emph{view}. For example, a text with tabular structure can became a report or a graphic plot image.
+\section{ToDo}
+A big work remain to do until the release 1.0 version: a language design and implementation too of a new user interface that make easy modify the view paramenter of the table such as the type of label row (number, letter and so on), or to define the description text in the header column.
+
+
+This list report tasks:
+
+\begin{itemize}
+ \item write in good english the package documentation;
+ \item internationalization of the fixed text in table and the currency unit;
+ \item data input and inner commands language development;
+ \item new infrastructure to manage the table view property;
+ \item \dots
+\end{itemize}
+
\section{Package License}
This work may be distributed and/or modified under the
conditions of the \LaTeX{} Project Public License, either version 1.3
@@ -380,14 +518,46 @@ The latest version of this license is in
and version 1.3 or later is part of all distributions of \LaTeX{}
version 2005/12/01 or later.
-\section{Thanks}
-Thanks a lot to Professor Enrico Gregorio for help me to resolve some code problem: balance the table description paragraph width to the table variable width, save in a tokens registry the material of table so as over the implicit group barrier of tabular cell, and solve consequent \verb=\expandafter= \emph{jungle}.
+
+\section{Thanks and acknowledgments}
+
+The enthusiasm raised during GuIT\emph{meeting}2008 in Pisa (Italy)\footnote{For information please visit the site \url{www.guit.sssup.it/guitmeeting/2008/2008.it.php}} by the talk \emph{``Una tabella che fa calcoli''} and the tip suggest me by Norbert Preining (Vienna University of Technology) to upload on CTAN the code in experimental section, finally persuade me to publish this work.
+
+Thanks GuIT\emph{meeting}2008 people, thanks Norbert.
+
+Thanks a lot to Professor Enrico Gregorio for help me to resolve some code problem: balance the table description paragraph width to the table variable width, save in a tokens registry the material of table so as over the implicit group barrier of the tabular cells, and solve consequent \verb=\expandafter= \emph{jungle}.
Thanks a lot to the authors of packages used by \pkg{calctab}.
And finally, thanks to my family.
Every comment are welcome as well as any language discussion, so don't esitate to send to the author an e-mail message with your opinion, suggestion or desiderata. Thank you.
+
+
+\section{Change history}
+
+\begin{tabular}{lcp{257pt}}\toprule
+ Number & Date & Improvement description\\\midrule
+ 0.5 & 2009/02/23 & first \ct{} CTAN release\\\midrule
+ 0.6.1 & 2009/03/03 & New \cmd{inrule} command to manual draw a rule among
+ the table rows\\
+ 0.6.2 & 2009/03/03 & Fixed bug: the absense of a rule after an add row\\
+ 0.6.3 & 2009/03/05 & New \env{xcalctab} environment (extended environment
+ with the ``quantity'' and ``price'' columns)\\
+ 0.6.4 & 2009/03/10 & New feature: automatic short of the description
+ string (A+B+C+$\cdots$) if it's long than more five items\\
+ 0.6.5 & 2009/03/10 & Substituted the standard \LaTeX{} command \cmd{Alph}
+ with \cmd{AlphAlph} by Heiko Oberdiek to eliminate the 26 rows limit in
+ label column\\
+ 0.6.6 & 2009/03/12 & New feature for \cmd{amount} command: basic binary
+ operation with two numbers thanks to \pkg{xstring} package\\
+ 0.6.7 & 2009/03/12 & Some minor internal code adjustments\\\bottomrule
+\end{tabular}
+
+
+
+
+
\end{document}
diff --git a/Master/texmf-dist/tex/latex/calctab/calctab.sty b/Master/texmf-dist/tex/latex/calctab/calctab.sty
index 229ce5cd65f..12109f18540 100644
--- a/Master/texmf-dist/tex/latex/calctab/calctab.sty
+++ b/Master/texmf-dist/tex/latex/calctab/calctab.sty
@@ -1,82 +1,89 @@
-%% calctab.sty
-%% Copyright (C) 2009 Roberto Giacomelli <giaconet at tin dot it>
+% calctab.sty
%
-% This work may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either version 1.3
-% of this license or (at your option) any later version.
-% The latest version of this license is in
-% http://www.latex-project.org/lppl.txt
-% and version 1.3 or later is part of all distributions of LaTeX
-% version 2005/12/01 or later.
+% Version: 0.6
+% Date: 2009_03_20
+%
+% Copyright (C) 2009 Roberto Giacomelli <giaconet at tin dot it>
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3 of this license or any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt and version 1.3
+% or later is part of all distributions of LaTeX version
+% 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Roberto Giacomelli
%
-% This work consists of the files calctab.sty, calctab_manual.pdf
-% and README.txt
-%
-% Please make attention to this important note:
-% This package is experimetal: the language syntax can be change.
+% This work consists of these files:
+% calctab.sty, calctab_manual.pdf and README
%
-% version 0.5
-% date: 2009_02_20
-%
-% History of 0.5 version
-% 1 - single row key definition without a fltpoint registry
-% 2 - add a package warning if the keys generate an override
-% 3 - new feature: id key for \add command
-% 4 - Fixed bug in single row key definition
-% 5 - add warning or error internal command, at the end of the listing code
-% 6 - new feature: interval keys 'from' and 'until' in opt arg of the \perc and \add command
-% complete by warning feature.
+% Please make attention to this important notice:
+% The language syntax can be change.
%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{calctab}[2009/02/20 v0.5 Autocalc table environment]
+\ProvidesPackage{calctab}[2009/03/23 v0.6 Autocalc table environments]
%
% ''library'' package for the table's visual property
+\RequirePackage{alphalph}
\RequirePackage{booktabs}
\RequirePackage{eurosym}
\RequirePackage[table]{xcolor}
-\RequirePackage{numprint}
+\RequirePackage{numprint}[2008/02/17]
%
% ''library'' package for algorithms and language implementation
\RequirePackage{xkeyval}
\RequirePackage{ifthen}
\RequirePackage{fltpoint}
+\RequirePackage{xstring}
+%
%
% length to tuning distance of central column of calctab table
% 8 mm is the default value
-\newlength{\ctsep}\setlength{\ctsep}{0.8cm}
+\newlength{\ctsep}\setlength{\ctsep}{8mm}
%
-% main row counter of the table
+% main counter of the table rows
\newcounter{ct@RowIndex}
%
-% loop simple counter
+% simple loop counter
\newcounter{ct@i}
+\newcounter{ct@k}
+%
+% macrokey definition commands
+\newcommand{\ct@makemacrokey}[1]{\expandafter\def\csname #1\endcsname##1{%
+ \expandafter\def\csname ct@#1\endcsname{##1}}}
%
-% macrokey definition command
-\newcommand{\makemacrokey}[1]{\expandafter\def\csname #1\endcsname##1{%
- \expandafter\def\csname @@#1\endcsname{##1}}}
+% apparence text commands definition and default assignments
+\ct@makemacrokey{ctcurrency}\ctcurrency{\euro}
+\ct@makemacrokey{ctdescription}\ctdescription{Items description}
+\ct@makemacrokey{ctontraslation}\ctontraslation{on}
+\ct@makemacrokey{ctheaderone}\ctheaderone{Q.ty}
+\ct@makemacrokey{ctheadertwo}\ctheadertwo{Price}
+
%
-% apparence command definition and default assignment
-\makemacrokey{ctcurrency}\ctcurrency{\euro}
-\makemacrokey{ctdescription}\ctdescription{Items description}
-\makemacrokey{ctontraslation}\ctontraslation{on}
+% boolean to control numeric loop: if ct@Globflag is true then
+% all row values are computed
+\newboolean{ct@Globflag}\setboolean{ct@Globflag}{true}
%
-% new boolean to control numeric loop, if ctGlobflag is true sum all row values
-\newboolean{ctGlobflag}\setboolean{ctGlobflag}{true}
+% new boolean to control behavior of the \inrule command
+\newboolean{ct@ifinrule}\setboolean{ct@ifinrule}{false}
+%
+% new boolean to control rule after an \add row
+\newboolean{ct@ifruleafteradd}\setboolean{ct@ifruleafteradd}{false}
%
% control flag of the from, until keys
% this flag is false if from and/or unil keys is/are not specified
\newboolean{ct@fromctrl}\setboolean{ct@fromctrl}{false}
\newboolean{ct@untilctrl}\setboolean{ct@untilctrl}{false}
%
-% definition of ordinary key
-% the ordinary keys is useful for assign a name to table row
-% note the use of different families
%
%
+% definitions of the ordinary keys
+% the ordinary keys is useful for to assign a name to row
+% note the use of different families
+%
\define@key{ctfamId}{id}{%
% save in ctreg@<idname> its row number
\expandafter\edef\csname ctreg@#1\endcsname{\thect@RowIndex}
@@ -90,13 +97,14 @@
\setboolean{ctflag\csname ctreg@#1\endcsname}{true}
}
% global flag is false if a key is specifed
- \setboolean{ctGlobflag}{false}
+ \setboolean{ct@Globflag}{false}
}%
}%
%
+%
% the id key for \add command
\define@key{ctfamAddid}{id}{%
- \ifthenelse{\boolean{ctGlobflag}}{%
+ \ifthenelse{\boolean{ct@Globflag}}{%
\expandafter\edef\csname ctref@#1\endcsname{\thect@RowIndex}
\define@key{ctfamLabel}{#1}[]{% set all row flag on true
\setcounter{ct@i}{1}
@@ -108,7 +116,7 @@
}
\stepcounter{ct@i}
}% end whiledo
- \setboolean{ctGlobflag}{false}
+ \setboolean{ct@Globflag}{false}
}
}{% else clause
\expandafter\edef\csname ctref@#1\endcsname{\ctref@temp}
@@ -117,7 +125,8 @@
\n@xt
}
}
-}
+}%
+%
%
% definition of ``interval'' keys
\define@key{ctfamLabel}{from}{%
@@ -127,103 +136,369 @@
\def\ct@fromrow{\csname ctreg@#1\endcsname}
\ifthenelse{\ct@fromrow=1}{\PackageWarning{calctab}{\ct@notusefulwarning{from}}}{}
\setboolean{ct@fromctrl}{true}
- \setboolean{ctGlobflag}{false}
+ \setboolean{ct@Globflag}{false}
}
-}
+}%
+%
%
\define@key{ctfamLabel}{until}{%
\@ifundefined{ctreg@#1}
- {\PackageError{calctab}{\ct@keynotexisterr{#1}}}
- {%
+ {\PackageError{calctab}{\ct@keynotexisterr{#1}}}{%
\def\ct@untilrow{\csname ctreg@#1\endcsname}
\ifthenelse{\ct@untilrow=\thect@RowIndex}{\PackageWarning{calctab}{\ct@notusefulwarning{until}}}{}
\setboolean{ct@untilctrl}{true}
- \setboolean{ctGlobflag}{false}
+ \setboolean{ct@Globflag}{false}
}
-}
+}%
%
-% table box allocation
-\newsavebox{\ctTabBox}
+% allocation of the table box
+\newsavebox{\ct@TabBox}
%
-% set standard decimal position
+% set standard decimal position (numprint package)
\nprounddigits{2}
%
+% internal \amount command control flag
+\newboolean{ct@isoperation}
%
-% main environment: definition
%
-\newenvironment{calctab}[1][]{%
+% main computation loop
+\newcommand\ct@Loop{%
+ \fpRegSet{ct@Sum}{0}
+ \setcounter{ct@i}{1}
+ \setcounter{ct@k}{0}
+ \edef\ct@labelreg{}% for the text labels row sequence (A+B+...)
+ \edef\ct@labeltemp{}%
+ \def\ct@plustext{}% '+' char
+ \whiledo{\not\(\value{ct@i}>\value{ct@RowIndex}\)}{%
+ \ifthenelse{\(\boolean{ctflag\thect@i}\OR\boolean{ct@Globflag}\)}{%
+ \fpRegAdd{ct@Sum}{ctRowValue\thect@i}%
+ \stepcounter{ct@k}
+ \ifthenelse{\value{ct@k}<3}{%
+ \edef\ct@labelreg{\ct@labelreg\ct@plustext\AlphAlph{\value{ct@i}}}
+ }{% else clause
+ \ifthenelse{\value{ct@k}>5}{%
+ \edef\ct@labeltemp{\ct@plustext$\, \cdots\,$\ct@plustext\AlphAlph{\value{ct@i}}}
+ }{%else clause
+ \edef\ct@labeltemp{\ct@labeltemp\ct@plustext\AlphAlph{\value{ct@i}}}
+ }
+ }
+ \setboolean{ctflag\thect@i}{false}% reset the row flag status
+ \def\ct@plustext{+}
+ }{%else clause: reset internal loop variables
+ \edef\ct@labelreg{\ct@labelreg\ct@labeltemp}
+ \setcounter{ct@k}{0}%
+ \edef\ct@labeltemp{}%
+ }%
+ \stepcounter{ct@i}%
+ }%
+ \edef\ct@labelreg{\ct@labelreg\ct@labeltemp}
+ \setboolean{ct@Globflag}{true}% reset the global flag status
+}%
+%
+%
+%
+%
+% calctab environment: definition code
+%
+\newenvironment{calctab}[1][]{%#1 is the optinal table's paragraph description
%set font family
\sffamily
%
-%set the token register (TeX primitive command resolve the tabular grouping problem)
-\toks255={\rowcolors{1}{gray!15}{}\begin{tabular}{clr}\midrule&\@@ctdescription & \@@ctcurrency \\\midrule}
+%set the token register (TeX primitive token register resolve the tabular grouping problem)
+\toks255={\rowcolors{1}{gray!15}{}\begin{tabular}{clr}\midrule&\ct@ctdescription & \ct@ctcurrency \\\midrule}
%
% reset main counter to starting value
\setcounter{ct@RowIndex}{0}
%
-% save paragraph table header to use it
-% in the environment end code
+% save paragraph table header to use it in the environment end code
\newcommand{\ct@FirstPar}[1]{#1}
%
% internal command definition
-\newcommand\ctLoop{%
- \fpRegSet{ctSum}{0}
- \setcounter{ct@i}{1}
- \edef\ctlabelreg{}% for text of labels row
- \edef\ctplustext{}% '+' char
- \whiledo{\not\(\value{ct@i}>\value{ct@RowIndex}\)}{%
- \ifthenelse{\(\boolean{ctflag\thect@i}\OR\boolean{ctGlobflag}\)}{%
- \fpRegAdd{ctSum}{ctRowValue\thect@i}%
- \setboolean{ctflag\thect@i}{false}% reset the row flag status
- \edef\ctlabelreg{\ctlabelreg\ctplustext\Alph{ct@i}}
- \edef\ctplustext{+}
- }{}%else clause denied
- \stepcounter{ct@i}%
- }%
- \setboolean{ctGlobflag}{true}% reset the global flag status
-}%
+%
%
% from until keys internal command
\newcommand{\ct@intervalloop}{%
- \ifthenelse{\(\boolean{ct@fromctrl}\OR\boolean{ct@untilctrl}\)}
- {
- \ifthenelse{\boolean{ct@fromctrl}}{\setboolean{ct@fromctrl}{false}}{\def\ct@fromrow{1}}
- \ifthenelse{\boolean{ct@untilctrl}}{\setboolean{ct@untilctrl}{false}}{\def\ct@untilrow{\thect@RowIndex}}
- \ifthenelse{\number\ct@fromrow<\number\ct@untilrow}
- {% canonical interval from until
- \ct@setintervalflag{\ct@fromrow}{\ct@untilrow}}
- {% negative interval 1 -> until plus from -> last row
- \ct@setintervalflag{1}{\ct@untilrow}
- \ct@setintervalflag{\ct@fromrow}{\thect@RowIndex}
- }% else clause denied
- }{}
+ \ifthenelse{\(\boolean{ct@fromctrl}\OR\boolean{ct@untilctrl}\)}{%
+ \ifthenelse{\boolean{ct@fromctrl}}{\setboolean{ct@fromctrl}{false}}{\def\ct@fromrow{1}}
+ \ifthenelse{\boolean{ct@untilctrl}}{\setboolean{ct@untilctrl}{false}}{\def\ct@untilrow{\thect@RowIndex}}
+ \ifthenelse{\number\ct@fromrow<\number\ct@untilrow}{% canonical interval from until
+ \ct@setintervalflag{\ct@fromrow}{\ct@untilrow}
+ }{% negative interval 1 -> until plus from -> last row
+ \ct@setintervalflag{1}{\ct@untilrow}
+ \ct@setintervalflag{\ct@fromrow}{\thect@RowIndex}
+ }
+ }{}% else clause denied
}
%
% internal command to set true the flags row in an interval
-\newcommand{\ct@setintervalflag}[2]{
+\newcommand{\ct@setintervalflag}[2]{%
% #1 arg -> start row value
% #2 arg -> finish row value
\setcounter{ct@i}{##1}
- \whiledo{\not\(\value{ct@i}>\number##2\)}{
- \ifthenelse{\boolean{ctflag\thect@i}}{
+ \whiledo{\not\(\value{ct@i}>\number##2\)}{%
+ \ifthenelse{\boolean{ctflag\thect@i}}{%
\PackageWarning{calctab}{\ct@overridingkeyerr{from or until}}
- }{
+ }{%
\setboolean{ctflag\thect@i}{true}
}
\stepcounter{ct@i}
}
+}%
+%
+%
+% #1 -> operator sign * / + -
+% #2 -> text for sign operation ($\, \times \,$)
+\newcommand{\ct@operator}[2]{%
+ \StrBefore{\ct@arg}{##1}[\ct@before]
+ \StrBehind{\ct@arg}{##1}[\ct@after]
+ \fpRegSet{ct@one}{\ct@before}
+ \fpRegMul{ct@one}{ct@unit}
+ \fpRegSet{ct@two}{\ct@after}
+ \fpRegCopy{ctRowValue\thect@RowIndex}{ct@one}
+ \IfStrEq{##1}{*}{\fpRegMul{ctRowValue\thect@RowIndex}{ct@two}}{}
+ \IfStrEq{##1}{/}{\fpRegDiv{ctRowValue\thect@RowIndex}{ct@two}}{}
+ \IfStrEq{##1}{+}{\fpRegAdd{ctRowValue\thect@RowIndex}{ct@two}}{}
+ \IfStrEq{##1}{-}{\fpRegSub{ctRowValue\thect@RowIndex}{ct@two}}{}
+ \fpRegRound{ctRowValue\thect@RowIndex}{-2}
+ \fpRegGet{ct@one}{\ct@before}
+ \fpRegGet{ct@two}{\ct@after}
+ \toks255=\expandafter{\the\toks255(}
+ \edef\ct@result{\noexpand\numprint{\ct@before}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@result ##2}
+ \edef\ct@result{\noexpand\numprint{\ct@after}}
+ \toks255=\expandafter\expandafter\expandafter{%
+ \expandafter\the\expandafter\toks255\ct@result)\rule{\ctsep}{0pt}}
}
%
-\newcommand\amount[3][]{%
+%
+%
+%
+% interface inner command: \amount
+\newcommand\amount[3][]{%#1->opt arg #2->descr #3->amount
\stepcounter{ct@RowIndex}
\newboolean{ctflag\thect@RowIndex}%definition of bool flag for each row
\setboolean{ctflag\thect@RowIndex}{false}%initial value of ctflag<n>
\setkeys{ctfamId}{##1}%
- \fpRegSet{ctRowValue\thect@RowIndex}{##3}
%append the tabular entry to the token register
- \toks255=\expandafter{\the\toks255\Alph{ct@RowIndex}&##2\rule{\ctsep}{0pt}&\numprint{##3}\\}
+ \ifthenelse{\boolean{ct@ifinrule}}{%
+ \ifthenelse{\boolean{ct@ifruleafteradd}}{
+ \toks255=\expandafter{\the\toks255\midrule}
+ \setboolean{ct@ifruleafteradd}{false}
+ }{}
+ }{%
+ \setboolean{ct@ifruleafteradd}{false}
+ }
+ %
+ \toks255=\expandafter{\the\toks255\AlphAlph{\value{ct@RowIndex}}&##2 }
+ % elementary ``parse'' of the #3 argument
+ \fpRegSet{ct@unit}{1}
+ % elimination of the space char
+ \StrDel{##3}{ }[\ct@arg]
+ \IfBeginWith{\ct@arg}{-}{\setboolean{ct@isoperation}{true}}{\setboolean{ct@isoperation}{false}}
+ \ifthenelse{\boolean{ct@isoperation}}{%
+ \fpRegSet{ct@unit}{-1}
+ \StrBehind{\ct@arg}{-}[\ct@argt]
+ \def\ct@arg{\ct@argt}
+ }{}
+ \IfBeginWith{\ct@arg}{+}{\setboolean{ct@isoperation}{true}}{\setboolean{ct@isoperation}{false}}
+ \ifthenelse{\boolean{ct@isoperation}}{%
+ \StrBehind{\ct@arg}{+}[\ct@argt]
+ \def\ct@arg{\ct@argt}
+ }{}
+ %
+ \IfSubStr{\ct@arg}{*}{\setboolean{ct@isoperation}{true}}{\setboolean{ct@isoperation}{false}}
+ \ifthenelse{\boolean{ct@isoperation}}{% true
+ \ct@operator{*}{$\, \times \,$}
+ }{% false
+ \IfSubStr{\ct@arg}{/}{\setboolean{ct@isoperation}{true}}{\setboolean{ct@isoperation}{false}}
+ \ifthenelse{\boolean{ct@isoperation}}{%
+ \ct@operator{/}{$\, / \,$}
+ }{%
+ \IfSubStr{\ct@arg}{-}{\setboolean{ct@isoperation}{true}}{\setboolean{ct@isoperation}{false}}
+ \ifthenelse{\boolean{ct@isoperation}}{%
+ \ct@operator{-}{$\, - \,$}
+ }{%
+ \IfSubStr{\ct@arg}{+}{\setboolean{ct@isoperation}{true}}{\setboolean{ct@isoperation}{false}}
+ \ifthenelse{\boolean{ct@isoperation}}{%
+ \ct@operator{+}{$\, + \,$}
+ }{%
+ \fpRegSet{ctRowValue\thect@RowIndex}{\ct@arg}
+ }
+ }
+ }
+ }
+ \fpRegGet{ctRowValue\thect@RowIndex}{\ct@tempnumber}
+ \toks255=\expandafter{\the\toks255&}
+ \edef\ct@result{\noexpand\numprint{\ct@tempnumber}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@result\\}
+ \setboolean{ct@ifinrule}{true}
+}%
+%
+%
+%
+\newcommand\perc[3][]{%
+ \stepcounter{ct@RowIndex}% another new row
+ \newboolean{ctflag\thect@RowIndex}% definition of bool flag for each row
+ \setboolean{ctflag\thect@RowIndex}{false}% initial value of ctflag<n>
+ % user id label task
+ \setkeys*{ctfamLabel}{##1}
+ \setrmkeys{ctfamId}
+ % 'from' and 'until' keys process
+ \ct@intervalloop
+ %
+ \addtocounter{ct@RowIndex}{-1}\ct@Loop\stepcounter{ct@RowIndex}
+ \fpDiv{\tempPerc}{##3}{100}%
+ \fpRegSet{tempreg}{\tempPerc}
+ \fpRegMul{ct@Sum}{tempreg}
+ \fpRegRound{ct@Sum}{-2}% approx to the second digit
+ \fpRegGet{ct@Sum}{\ct@tempnum}
+ \fpRegSet{ctRowValue\thect@RowIndex}{\ct@tempnum}
+ %
+ \ifthenelse{\boolean{ct@ifinrule}}{
+ \ifthenelse{\boolean{ct@ifruleafteradd}}{%
+ \toks255=\expandafter{\the\toks255\midrule}
+ \setboolean{ct@ifruleafteradd}{false}
+ }{}
+ }{
+ \setboolean{ct@ifruleafteradd}{false}
+ }
+ %
+ \toks255=\expandafter{\the\toks255\AlphAlph{\value{ct@RowIndex}}&##2 (\numprint{##3}\% \ct@ctontraslation{} }
+ \edef\ct@num{\noexpand\ct@labelreg)\noexpand\rule{\ctsep}{0pt}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num&}
+ \edef\ct@num{\noexpand\numprint{\ct@tempnum}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num\\}
+ \setboolean{ct@ifinrule}{true}
+}
+%
+\newcommand\add[2][]{%
+ \def\ctref@temp{##1}% save id list
+ \setkeys*{ctfamLabel}{##1}
+ \setrmkeys{ctfamAddid}
+ % 'from' and 'until' keys processing
+ \ct@intervalloop
+ %
+ \ifthenelse{\boolean{ct@ifinrule}}{\toks255=\expandafter{\the\toks255\midrule}}{}
+ \ct@Loop\fpRegGet{ct@Sum}{\ct@tempnum}
+ \toks255=\expandafter{\the\toks255\rowcolor{gray!15}&\bfseries##2 (}
+ \edef\ct@num{\noexpand\ct@labelreg)\noexpand\rule{\ctsep}{0pt}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num&\bfseries}
+ \edef\ct@num{\noexpand\numprint{\ct@tempnum}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num\\}
+ \setboolean{ct@ifinrule}{true}
+ \setboolean{ct@ifruleafteradd}{true}
+}
+%
+\newcommand\inrule{%
+ \ifthenelse{\boolean{ct@ifinrule}}{%
+ \toks255=\expandafter{\the\toks255\midrule}
+ }{
+ \PackageWarning{calctab}{\ct@inrulewarning}
+ }
+ \setboolean{ct@ifinrule}{false}
}%
%
+%
+%
+}{% calctab environment closing code
+ \begin{center}
+ \begin{lrbox}{\ct@TabBox}
+ \the\toks255\bottomrule
+ \end{tabular}
+ \end{lrbox}
+ \sffamily
+ \parbox{\wd\ct@TabBox}{
+ \ct@FirstPar\par\smallskip\par
+ \usebox{\ct@TabBox}}
+ \end{center}
+}
+%
+%
+%
+% xcalctab environment section definition
+%
+\newenvironment{xcalctab}[1][]{%
+%set font family
+\sffamily
+%
+% set the token register (TeX primitive command resolve the tabular grouping problem)
+\toks255={\rowcolors{1}{gray!15}{}%
+\begin{tabular}{cl*{3}{r}}\midrule&\ct@ctdescription &\ct@ctheaderone&\ct@ctheadertwo& \ct@ctcurrency \\\midrule}
+%
+% reset main counter to starting value
+\setcounter{ct@RowIndex}{0}
+%
+% save paragraph table header to use it in the environment end code
+\newcommand{\ct@FirstPar}[1]{#1}
+%
+% internal command definition
+%
+%
+%
+% from until keys internal command
+\newcommand{\ct@intervalloop}{%
+ \ifthenelse{\(\boolean{ct@fromctrl}\OR\boolean{ct@untilctrl}\)}{%
+ \ifthenelse{\boolean{ct@fromctrl}}{\setboolean{ct@fromctrl}{false}}{\def\ct@fromrow{1}}
+ \ifthenelse{\boolean{ct@untilctrl}}{\setboolean{ct@untilctrl}{false}}{\def\ct@untilrow{\thect@RowIndex}}
+ \ifthenelse{\number\ct@fromrow<\number\ct@untilrow}{% canonical interval from until
+ \ct@setintervalflag{\ct@fromrow}{\ct@untilrow}
+ }{% negative interval 1 -> until plus from -> last row
+ \ct@setintervalflag{1}{\ct@untilrow}
+ \ct@setintervalflag{\ct@fromrow}{\thect@RowIndex}
+ }
+ }{}% else clause denied
+}
+%
+% internal command to set true the flags row in an interval
+\newcommand{\ct@setintervalflag}[2]{%
+ % #1 arg -> start row value
+ % #2 arg -> finish row value
+ \setcounter{ct@i}{##1}
+ \whiledo{\not\(\value{ct@i}>\number##2\)}{%
+ \ifthenelse{\boolean{ctflag\thect@i}}{%
+ \PackageWarning{calctab}{\ct@overridingkeyerr{from or until}}
+ }{% else clause
+ \setboolean{ctflag\thect@i}{true}
+ }
+ \stepcounter{ct@i}
+ }
+}%
+%
+%
+%
+\newcommand\amount[4][]{%#1 ->opt #2->descr #3->qta #4->price
+ \stepcounter{ct@RowIndex}
+ \newboolean{ctflag\thect@RowIndex}%definition of bool flag for each row
+ \setboolean{ctflag\thect@RowIndex}{false}%initial value of ctflag<n>
+ \setkeys{ctfamId}{##1}%
+ % fp computation
+ \fpRegSet{ctRowValue\thect@RowIndex}{##3}% first number
+ \fpRegSet{ct@two}{##4}% second number
+ \fpRegMul{ctRowValue\thect@RowIndex}{ct@two}
+ \fpRegRound{ctRowValue\thect@RowIndex}{-2}
+ %
+ % now, we must control the ``rule'' case
+ \ifthenelse{\boolean{ct@ifinrule}}{
+ \ifthenelse{\boolean{ct@ifruleafteradd}}{%
+ \toks255=\expandafter{\the\toks255\midrule}
+ \setboolean{ct@ifruleafteradd}{false}
+ }{}
+ }{
+ \setboolean{ct@ifruleafteradd}{false}
+ }%
+ %
+ %
+ % append the tabular entry to the token register
+ \toks255=\expandafter{\the\toks255\AlphAlph{\value{ct@RowIndex}}&##2\rule{\ctsep}{0pt}&\numprint{##3}&\numprint{##4}&}
+ \fpRegGet{ctRowValue\thect@RowIndex}{\ct@tempnum}
+ \edef\ct@num{\noexpand\numprint{\ct@tempnum}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num\\}
+ % rule regolation
+ \setboolean{ct@ifinrule}{true}
+}%
+%
+%
+%
\newcommand\perc[3][]{%
\stepcounter{ct@RowIndex}% another new row
\newboolean{ctflag\thect@RowIndex}% definition of bool flag for each row
@@ -234,18 +509,29 @@
% 'from' and 'until' keys process
\ct@intervalloop
%
- \addtocounter{ct@RowIndex}{-1}\ctLoop\stepcounter{ct@RowIndex}
+ \addtocounter{ct@RowIndex}{-1}\ct@Loop\stepcounter{ct@RowIndex}
\fpDiv{\tempPerc}{##3}{100}%
\fpRegSet{tempreg}{\tempPerc}
- \fpRegMul{ctSum}{tempreg}
- \fpRegRound{ctSum}{-2}% approx to the second digit
- \fpRegGet{ctSum}{\atempnumber}
- \fpRegSet{ctRowValue\thect@RowIndex}{\atempnumber}
- \toks255=\expandafter{\the\toks255\Alph{ct@RowIndex}&##2 (\numprint{##3}\% \@@ctontraslation{} }
- \edef\ctnum{\noexpand\ctlabelreg)\noexpand\rule{\ctsep}{0pt}}
- \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ctnum&}
- \edef\ctnum{\noexpand\numprint{\atempnumber}}
- \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ctnum\\}
+ \fpRegMul{ct@Sum}{tempreg}
+ \fpRegRound{ct@Sum}{-2}% approx to the second digit
+ \fpRegGet{ct@Sum}{\ct@tempnum}
+ \fpRegSet{ctRowValue\thect@RowIndex}{\ct@tempnum}
+ %
+ \ifthenelse{\boolean{ct@ifinrule}}{%
+ \ifthenelse{\boolean{ct@ifruleafteradd}}{%
+ \toks255=\expandafter{\the\toks255\midrule}
+ \setboolean{ct@ifruleafteradd}{false}
+ }{}%
+ }{% else clause
+ \setboolean{ct@ifruleafteradd}{false}
+ }%
+ %
+ \toks255=\expandafter{\the\toks255\AlphAlph{\value{ct@RowIndex}}&##2 (\numprint{##3}\% \ct@ctontraslation{} }
+ \edef\ct@num{\noexpand\ct@labelreg)\noexpand\rule{\ctsep}{0pt}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num&&&}
+ \edef\ct@num{\noexpand\numprint{\ct@tempnum}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num\\}
+ \setboolean{ct@ifinrule}{true}
}
%
\newcommand\add[2][]{%
@@ -255,24 +541,40 @@
% 'from' and 'until' keys process
\ct@intervalloop
%
- \ctLoop\fpRegGet{ctSum}{\atempnumber}
- \toks255=\expandafter{\the\toks255\midrule\rowcolor{gray!15}&\bfseries##2 (}
- \edef\ctnum{\noexpand\ctlabelreg)\noexpand\rule{\ctsep}{0pt}}
- \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ctnum&\bfseries}
- \edef\ctnum{\noexpand\numprint{\atempnumber}}
- \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ctnum\\}
+ \ifthenelse{\boolean{ct@ifinrule}}{\toks255=\expandafter{\the\toks255\midrule}}{}
+ \ct@Loop\fpRegGet{ct@Sum}{\ct@tempnum}
+ \toks255=\expandafter{\the\toks255\rowcolor{gray!15}&\bfseries##2 (}
+ \edef\ct@num{\noexpand\ct@labelreg)}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num&&&\bfseries}
+ \edef\ct@num{\noexpand\numprint{\ct@tempnum}}
+ \toks255=\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks255\ct@num\\}
+ % rule case analisys flag setup
+ \setboolean{ct@ifinrule}{true}
+ \setboolean{ct@ifruleafteradd}{true}
+}
+%
+% this command remain internal!
+\newcommand\inrule{%
+ \ifthenelse{\boolean{ct@ifinrule}}{%
+ \toks255=\expandafter{\the\toks255\midrule}
+ }{
+ \PackageWarning{calctab}{\ct@inrulewarning}
+ }
+ \setboolean{ct@ifinrule}{false}
}%
%
+%
+%
}{% calctab environment closing code
\begin{center}
- \begin{lrbox}{\ctTabBox}
+ \begin{lrbox}{\ct@TabBox}
\the\toks255\bottomrule
\end{tabular}
\end{lrbox}
\sffamily
- \parbox{\wd\ctTabBox}{
+ \parbox{\wd\ct@TabBox}{
\ct@FirstPar\par\smallskip\par
- \usebox{\ctTabBox}}
+ \usebox{\ct@TabBox}}
\end{center}
}
%
@@ -280,12 +582,29 @@
% package warning and error macro definition part code
%
% the user has defined a key that not exist
-\newcommand{\ct@keynotexisterr}[1]{The key #1 not exist}
+\newcommand{\ct@keynotexisterr}[1]{The key '#1' not exist}
%
% in the id list command optional argument, a key is been specifed more then one time
-\newcommand{\ct@overridingkeyerr}[1]{The #1 key is just specifed in optional arg sequence.\MessageBreak
-Overriding ignored}
+\newcommand{\ct@overridingkeyerr}[1]{The '#1' key is just specifed in a previous optional arg sequence.\MessageBreak
+Overlap ignored}
+%
+\newcommand{\ct@notusefulwarning}[1]{The key '#1' is not influential on computation}
+\newcommand{\ct@inrulewarning}[1]{A rule cannot be draw at this point. Command ignored}
+%
+%
+%
+% Version 0.6 Changes history
+%
+% 0.6.1 - 2009_03_03 - New \inrule command to draw a rule among the table rows
+% 0.6.2 - 2009_03_03 - Fixed bug: the absense of a rule after an add row
+% 0.6.3 - 2009_03_05 - New xcalctab environment (extended environment with the 'quantity' and 'price' columns)
+% 0.6.4 - 2009_03_10 - New feature: automatic trunked of the description string (A+B+C+...) if it is long than more five items
+% 0.6.5 - 2009_03_10 - Substituted the standard LaTeX command \Alph with \AlphAlph by Oberdiek to eliminate the 26 rows limit
+% 0.6.6 - 2009_03_12 - New feature for \amount command: basic binary operation with two numbers thanks to xstring package
+%
+% 0.6.7 - 2009_03_xx - New command \calc for basic operation with two numbers.
+% 0.6.8 - 2009_03_xx - Minor internal adjustments
+%
%
-\newcommand{\ct@notusefulwarning}[1]{The key '#1' is non influential on calc}
%
-% end of file calctab.sty \ No newline at end of file
+% end of file calctab.sty