summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex')
-rw-r--r--Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex326
1 files changed, 304 insertions, 22 deletions
diff --git a/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex b/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex
index 1419c90311d..b8b47f59285 100644
--- a/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex
+++ b/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex
@@ -1,9 +1,9 @@
-% ____________________________________________________________________________
+ % ____________________________________________________________________________
% | |
% | |
-% | spreadtab v0.1 |
+% | spreadtab v0.2 |
% | |
-% | November 3 2009 |
+% | January 24, 2010 |
% | |
% |___________________________________________________________________________|
%
@@ -30,8 +30,10 @@
\usepackage{lmodern}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{amsmath,amssymb}
+\usepackage{textcomp}
\usepackage{array}
-\usepackage{colortbl}
+\usepackage[table]{xcolor}
+\usepackage{arydshln}
\usepackage{tabularx}
\usepackage{xcolor}
\usepackage{listings}
@@ -39,15 +41,18 @@
\usepackage{xspace}
\usepackage[bottom]{footmisc}
\usepackage{spreadtab}
+\usepackage[protrusion=true,final,verbose=true,babel=true]{microtype}
\usepackage{fancyhdr}
\fancyhead[L]{}
\fancyhead[C]{\small\bfseries\ST}
- \fancyhead[R]{\scriptsize\slshape\leftmark}
- \fancyfoot[l]{\tiny\LaTeX'd by Christian \textsc{Tellechea}, \today.}
+ \fancyhead[R]{\scriptsize\slshape \leftmark}
+ \fancyfoot[l]{\tiny \LaTeX ed by Christian \textsc{Tellechea}, le \today.}
\fancyfoot[c]{}
\fancyfoot[r]{\thepage}
-\usepackage[english]{babel}
+\usepackage[frenchb]{babel}
+\frenchbsetup{StandardLists=true}
+\usepackage{enumitem}
\makeatletter
\definecolor{ST@bckgcolor}{rgb}{0.87,0.9,1}
\definecolor{ST@codebckgcolor}{rgb}{0.9,0.9,0.9}
@@ -64,19 +69,67 @@
captionpos=t,xleftmargin=1em,xrightmargin=1em,lineskip=0pt,%
numbersep=1em,classoffset=1,%
morekeywords={% les macros et commandes de spreadtab
- spreadtab,SThiderow,SThidecol,STsavecell,STautoround,STmessage,%
- STnumericfieldmarker,STtextcell,fact,ifeq,ifgt,iflt,numtofrshortdate,%
+ spreadtab,SThiderow,SThidecol,STsavecell,STautoround,STmessage,STsetdecimalsep,STtransposecar,STdebug,STdisplaytab,%
+ STnumericfieldmarker,STtextcell,STcopy,fact,ifeq,ifgt,iflt,numtofrshortdate,%
numtoengshortdate,numtofrlongdate,numtoenglongdate,numtofrmonth,%
numtoengmonth,numtofrday,numtoengday,sum,rand,randint,sumprod,%
frshortdatetonum,engshortdatetonum,englongdatetonum,frlongdatetonum},%
keywordstyle=\color{ST@keywordstc},classoffset=0}
+
+
+%%%%%%%%%%% environnement OOcalc
+\newcount\cntlin
+\newcount\cntcol
+
+\newtoks\t@b
+\long\def\ifremain@lines#1\\#2\@nil{%
+ \csname @\ifx\@empty#2\@empty second\else first\fi oftwo\endcsname}
+\long\def\subst@eol#1\\#2\@nil{\addtot@b{#1\\\cline{1-1}\hdashline}%
+ \ifremain@lines#2\\\@nil{\addtot@b&\subst@eol#2\@nil}{\addtot@b{#2\end{tabular}}}}
+\long\def\collect@body#1\end{\subst@eol#1\@nil\end}
+
+\newcommand\addtot@b[1]{\t@b\expandafter{\the\t@b#1}}
+\newcommand\edftot@b[1]{\edef\temp@{#1}\expandafter\addtot@b\expandafter{\temp@}}
+
+\newenvironment{OOocalc}[2][1.5cm]{% #1=largeur colonnes #2 = nombre de colonnes
+ \newcolumntype w{>{\centering\arraybackslash}m{#1}}%
+ \arrayrulewidth0.4pt\dashlinedash0.4pt\relax\dashlinegap3pt
+ \global\cntlin\m@ne\global\cntcol\z@
+ \tabfont
+ \tabcolsep0pt
+ \t@b{\begin{tabular}{%
+ |>{\cellcolor{tabheadcolor}%
+ \global\cntcol\z@\global\advance\cntlin\@ne
+ \centering\arraybackslash
+ \ifnum\cntlin>\z@\tableheadformat\number\cntlin\fi}
+ m{2em}|*{#2}{w:}}%
+ \hline
+ \rowcolor{tabheadcolor}}%
+ \loop
+ \ifnum\cntcol<#2
+ \advance\cntcol\@ne
+ \addtot@b{&\multicolumn{1}{>\centering m{#1}|}}%
+ \edftot@b{{\noexpand\tableheadformat\@Alph\cntcol}}%
+ \repeat
+ \addtot@b{\\\hline&}%
+ \collect@body}{\the\t@b}
\makeatother
-\newcommand\verbinline{\lstinline[breaklines=false,basicstyle=\normalsize\ttfamily]}
+% commandes de personnalisation de OOcalc
+\newcommand*\tabfont{\fontfamily{phv}\selectfont\footnotesize}% police du tableau (helvetica ici)
+\newcommand*\tableheadformat{\bfseries}% police des en-tĂȘtes du tableau (en gras)
+\colorlet{tabheadcolor}{gray!40}% couleur de font des en-tĂȘtes du tableau
+\colorlet{palepink}{pink!80}
+\colorlet{lightpink}{pink!30}
+\colorlet{palegreen}{green!60}
+\colorlet{lightgreen}{green!30}
+\newcommand\CC[1]{\cellcolor{#1}}
+
+\newcommand\verbinline[1][]{\lstinline[breaklines=false,basicstyle=\normalsize\ttfamily,#1]}
\newcommand\ST{\textsf{spreadtab}\xspace}
\newcommand\falseverb[1]{\texttt{\detokenize{#1}}}
-\usepackage[a4paper,bookmarks=true,bookmarksopen=true,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,pdfauthor={Christian TELLECHEA},pdftitle={spreadtab},pdfsubject={Spreadtab provides spreadsheet features for LaTeX table environments},pdfkeywords={spreadtab},pdfcreator={LaTeX}]{hyperref}
+\usepackage[bookmarks=true,bookmarksopen=true,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,pdfauthor={Christian TELLECHEA},pdftitle={spreadtab},pdfsubject={Spreadtab provides spreadsheet features for LaTeX table environments},pdfkeywords={spreadtab},pdfcreator={LaTeX}]{hyperref}
\begin{document}
\parindent0pt\pagestyle{fancy}
@@ -111,7 +164,7 @@
\end{titlepage}
\tableofcontents\newpage
-\parskip\medskipamount
+\parskip\medskipamount This manual is a translation of the french manual. I apologize for my poor english but I did my best\footnote{Any help to improve this translation is welcome!}, and I hope that the following is comprehensible!
\section{Introduction}
\subsection{Presentation}
This package allows us to construct tables in a manner similar to a spreadsheet. The cells of a table have row and column indices and these can be used in formulas to generate values in other cells.
@@ -140,14 +193,12 @@ after the work of \ST, we get a display as if we had written:
\end{lstlisting}
Although having features resembling those of a spreadsheet with \LaTeX{} is appreciable, the 3 stages described above take time, and above all, \verb-fp- is slow in its calculations. The \ST environment leads to \emph{much slower compilation} than with a classical table.
-Moreover, \ST \emph{cannot stand in for a spreadsheet program}. Indeed, it has very few features, and it does not provide visual assistance. This point may cause difficulty\footnote{I certify that, with the use, this discomfort tends to disappear (if you do not work with huge tables, of course).} for big or complex tables. The syntax of \ST is also another difficulty. In fact, the advantage of this package is that it makes possible to write \emph{in the \LaTeX{} code} tables invloving calculation when these tables are usually exported\footnote{I mention the main two exportation programs: \href{http://calc2latex.sourceforge.net/}{\texttt{\textbf{cacl2latex}}} for `calc' (Open Office), and \href{http://www.ctan.org/tex-archive/support/excel2latex/}{\texttt{\textbf{excel2latex}}} for `excel' (Microsoft Office).} from a spreadsheet program to \LaTeX{} code. Consequently, it becomes possible to avoid the disadvantages of the exportation programs: fine tuning often necessary to obtain exactly what you want, exported tables containing the values only (formulas are lost when exportation is done), no compatibility with all types of environments, exportation must be started again if a single number or formulas is modified in the table.
+Moreover, \ST \emph{cannot stand in for a spreadsheet program}. Indeed, it has very few features, and it does not provide visual assistance. This point may cause difficulty\footnote{I certify that, with the use, this discomfort tends to disappear (if you do not work with huge tables, of course).} for big or complex tables. The syntax of \ST is also another difficulty. In fact, the advantage of this package is that it makes possible to write \emph{in the \LaTeX{} code} tables invloving calculation when these tables are usually exported\footnote{I mention the two main exportation programs: \href{http://calc2latex.sourceforge.net/}{\texttt{\textbf{cacl2latex}}} for `calc' (Open Office), and \href{http://www.ctan.org/tex-archive/support/excel2latex/}{\texttt{\textbf{excel2latex}}} for `excel' (Microsoft Office).} from a spreadsheet program to \LaTeX{} code. Consequently, it becomes possible to avoid the disadvantages of the exportation programs: fine tuning often necessary to obtain exactly what you want, exported tables containing the values only (formulas are lost when exportation is done), no compatibility with all types of environments, exportation must be started again if a single number or formulas is modified in the table.
\subsection{Motivation}
A few months before I started to write this package, Derek \textsc{O'Connor} had pointed out that nothing was available in the world of \LaTeX{} packages to imitate --~even a little~-- the behaviour of spreadsheet programs. I found the challenge interesting and I started writing in this package which is only a good programming exercise.
-Indeed, the main algorithm contained in \ST that determines the order in which the cells must be calculated is quite general and not specific to \LaTeX. Other \LaTeX{} oriented algorithms analyze cells and formulas to find references to other cells. The exercise is interesting because for programming, \TeX{} does not provide anything resembling a pointer, useful to build linked lists of cells to calculate. Nothing is available either to attach to a `variable' `chils fields' which you can choose the type.
-
-The road was long before reaching this first version and I especially want to thank Christophe \textsc{Casseau} for his early interest and for the suggestions he made, and more recently Derek \textsc{O'Connor} for his advice and for the constructive discussions we have had. I also thank Huu Dien Khue~\textsc{Le} for the Vietnamese translation of this manual.
+The road was long before reaching this version and I especially want to thank Christophe \textsc{Casseau} for his early interest and for the suggestions he made, and more recently Derek \textsc{O'Connor} for his advice and for the constructive discussions we have had. I also thank Huu Dien Khue~\textsc{Le} for the Vietnamese translation of this manual.
\section{Basic features}
A table is a rectangular array of cells which may be viewed as a set cells arranged in horizontal rows or vertical columns.
@@ -158,8 +209,12 @@ A table cell is identified by the pair \falseverb{<colref><rowref>}\footnote{No
\item \verb|<colref>| is a letter from \falseverb a to \falseverb z, and \falseverb a is the first column on the left: it is limited to 26 columns, which should be sufficient for the majority of cases; the letter can be upper or lowercase;
\item \verb|<rowref>| is a positive integer representing row number. The row number 1 is the top row.
\end{itemize}
-Here are examples of absolutes references: \falseverb{b4} or \falseverb{C1} or \falseverb{d13}.
-
+Here are examples of absolutes references: \falseverb{b4} or \falseverb{C1} or \falseverb{d13}. Locations of cells appear clearly in the spreadsheet-like table below:
+\begin{center}
+\begin{OOocalc}[6em]{5}
+&&&&\\&&&&\\&&&&\\&&&&\\&&&&\\
+\end{OOocalc}
+\end{center}
This example calculates the sum each row and each column and then calculates the grand total:\par\nobreak
\begin{minipage}{0.75\linewidth}
\begin{lstlisting}
@@ -288,17 +343,128 @@ value 1 : :={50} & value 2 : :={29} & average : \textbf{:={(a1+b1)/2}}\\\hline
value 1 : :={50} & value 2 : :={29} & average : \textbf{:={(a1+b1)/2}}\\\hline
\end{spreadtab}
\end{center}
-If '\verb-:=-` has an empty argument like this '\verb-:={}-`, then the cell is understood as a text cell. It is a synonym of '\falseverb{@}`.
+If '\verb-:=-` is written in a cell with an empty argument like this '\verb-:={}-`, then the cell is understood as a text cell. In fact, '\verb-:={}-` behaves like '\verb-@-', but they are \emph{not} equivalent: '\verb-:={}-` allows the cell to receive a formula from an other with \verbinline-\STcopy- (see next chapter) while it is impossible with '\verb-@-'.
+
+\subsection{Copy a formula}
+To avoid having to copy formulas into adjacent cells, the \ST package provides the \verbinline-\STcopy- command.
+
+This command must be written in a cell with this syntax:
+\begin{center}
+\verbinline-\STcopy{>-$x$\verbinline-,v-$y$\verbinline-}{formula}-
+\end{center}
+where $x$ and $y$ are positive numbers that represent horizontal and vertical offsets relative to the cell where the command is. With the cell containing the command (the source cell), these offsets define a range of cells which will receive the \verb-<formule> -\footnote{The copy can not be done to cells located on the right and below the cell is located in the macro.}. The command \verbinline-\STcopy- must \emph{not} be in a cell where there is a numeric field marker "\verb-:=-".
+
+Here is how the copy is made: it starts from the cell where the command \verbinline-\STcopy- is. For the other cells, all the coordinates in the formula are modified taking into account the offsets from the source cell. For example, if the source cell contains the formula \verb-a1+b2+c3-, and the taget cell is located 2 columns rightwards and 5 rows below then, this formula becomes: \verb-c6+d7+e8-. The formula can also contain relative references but, since they are relative, they are not modified.
+
+Preceded by "\verb-!-", a coordinate in a formula is not modified when the formula is copied. For example, if the source cell contains \verb-a!1+!b2+!c!3- and the target cell is located 2 columns rightwards and 5 rows below then, this formula becomes: \verb-c1+b7+c3-. The feature is compatible with relative coordinates. Let's suppose a cell contains this formula: \verb|[-1,!-1]+[!-1,1]+[!1,!2]|. As usualy, let's say that this formula is copied to the cell located 2 columns rightwards and 5 rows below: this formula becomes: \verb|[-1,-6]+[-3,1]+[-1,-3]|.
+
+The "\verb-!-" char is the expansion of the control sequence \verbinline-\STtransposecar-. It may be changed to any other with \verbinline-\renewcommand\STtransposecar-\verb-{<char>}-. The "\verb-!-" char, used by default, keeps its 13 catcode and remains active if the \verb-babel- package is loaded with the \verb-frenchb- option.
+
+In "\verbinline-\STcopy{>-$x$\verbinline-,v-$y$\verbinline-}{formula}-", if $x$ is omitted, the copie is made to the cells rightwards, up to the right edge of the table. With $y$, it is the same: if this number is omitted, the copy is done to the cells below until the bottom of the table is reached. If $x$ or $y$ are equal to 0, the copy is limited to the column or row of the source cell. Instead of writing \verb-v0- ou \verb->0-, it is possible to write \verb-v- ou \verb->-.
+
+Here are some examples:
+\begin{tabular}{cl}\hline
+\verb-{>3,v1}- & copy to 3 columns rightwards and 1 row below\\
+\verb-{>3}- & copy to 3 cells on the right\\
+\verb-{v1}- & copy to the cell below\\
+\verb-{>}- & copy rightwards up to the right edge\\
+\verb-{v}- & copy below\\
+\verb-{v,>}- & copy to the right and below until the end of the table\\\hline
+\end{tabular}
+
+It is easy to generate the multiplication table from 1 to 10:
+
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|c|*{10}{c}|}}
+\hline
+@$\times$ & 1 & \STcopy{>}{b1+1} & & & & & & & & \\\hline
+1 & \STcopy{>,v}{!a2*b!1} & & & & & & & & & \\
+\STcopy{v}{a2+1} & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|c|*{10}{c}|}}
+\hline
+@$\times$ & 1 & \STcopy{>}{b1+1} & & & & & & & & \\\hline
+1 & \STcopy{>,v}{!a2*b!1} & & & & & & & & & \\
+\STcopy{v}{a2+1} & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\
+ & & & & & & & & & & \\\hline
+\end{spreadtab}
+\end{center}
+
+If the numeric field of a target cell is not empty, it is not replaced and the copy is not done for this cell.
+
+If 2 or more \verbinline-\STcopy- command in several source cells have the same taget cell, then, the formula this latter receive is the one contained in the last \verbinline-\STcopy- command when the table is read from top left to botton right. In the spreadsheet-like example below, the \verbinline-\STcopy- in the pink cell \falseverb{B1} has its target range partially covered by the one of the green cell \falseverb{C3}.
+\begin{center}
+\begin{OOocalc}[2.3cm]{6}
+1 &\CC{palepink}\ttfamily\textbackslash STcopy \{v,>\}\{!a1+1\} &\CC{lightpink} &\CC{lightpink} &\CC{lightpink} &\CC{lightpink} \\
+2 &\CC{lightpink} &\CC{lightpink} &\CC{lightpink} &\CC{lightpink} &\CC{lightpink} ~\par~ \\
+3 &\CC{lightpink} &\CC{palegreen}\ttfamily\textbackslash STcopy \{>2,v1\}\{!a3*10\}&\CC{lightgreen} &\CC{lightgreen} &\CC{lightpink} \\
+4 &\CC{lightpink} &\CC{lightgreen} &\CC{lightgreen} &\CC{lightgreen} &\CC{lightpink}~\par~ \\
+5 &\CC{lightpink} &\CC{lightpink} &\CC{lightpink} &\CC{lightpink} &\CC{lightpink}~\par~ \\
+\end{OOocalc}
+\end{center}
+Here is this example, treated by \ST below. In this table, the cell \verb-b5- (numeric field alone) and the cell \verb-c5- (text field + numeric field) stay un changed since their numeric field are not empty:
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*6{c|}}}\hline
+1 &\STcopy{v,>}{!a1+1} & & & & \\\hline
+2 & & & & & \\\hline
+3 & & \STcopy{>2,v1}{!a3*10} & & & \\\hline
+4 & & & & & \\\hline
+5 & -1 & a:={0}b & & & \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*6{c|}}}\hline
+1 &\STcopy{v,>}{!a1+1} & & & & \\\hline
+2 & & & & & \\\hline
+3 & & \STcopy{>2,v1}{!a3*10} & & & \\\hline
+4 & & & & & \\\hline
+5 & -1 & a:={0}b & & & \\\hline
+\end{spreadtab}
+\end{center}
+As mentioned in the last chapter, you can also copy a formula in a text cell containing an empty numeric field (that is to say a cell containing ``\verb-:={}-''). In this case, the formula is copied inside the brackets. On the other side, a cell containing text ``\verb-@-'' can not receive a formula when copying is not done and the cell remains purely textual.
+
+Example :
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*6{c|}}}\hline
+1 & 2 & 3 & 4 & 5 & 6 \\\hline
+X\STcopy{>}{a1+1}Y & @XY & X:={}Y & \textbf{:={}} & & \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*6{c|}}}\hline
+1 & 2 & 3 & 4 & 5 & 6 \\\hline
+X\STcopy{>}{a1+1}Y & @XY & X:={}Y & \textbf{:={}} & & \\\hline
+\end{spreadtab}
+\end{center}
\section{Features for formatting the table}
\subsection{End of lines and horizontal rules}
-\ST recognizes the usual line breaks and horizontal rules \verb|\\| and \verb|\hline|. Also, it may use the optional argument in line break: \verb-\\[<dimension>]-.
+\ST recognizes the usual line breaks and horizontal rules \verb|\\| and \verb|\hline|. It is also possible to specify the optional argument in line break: \verb-\\[<dimension>]-.
For horizontal rule, it is possible to use:\par\nobreak
\begin{itemize}
\item \verb-\hline-;
\item \verb=\cline{x-y}= where \falseverb x and \falseverb y define the start and the end of the rule;
\item \verb=\hhline{<type>}= where \verb=<type>= is the type of rule (read the manual of the \href{http://www.ctan.org/tex-archive/macros/latex/required/tools/}{\texttt{\textbf{hhline}}} package).
+ \item any command of the \href{http://www.ctan.org/tex-archive/macros/latex/contrib/booktabs/}{\texttt{\textbf{booktabs}}} package: \verb-\toprule-, \verb-\midrule-, \verb-\bottomrule-, \verb-\cmidrule-, \verb-\addlinespace-, \verb-\morecmidrule- and \verb-\specialrule-. All the arguments of these macros, optional or mandatory are taken into account;
+ \item \verbinline-\noalign- and its mandatory argument can be written after \verb-\\-.
\end{itemize}
Example:
\begin{lstlisting}
@@ -465,6 +631,66 @@ In this example, floating point numbers are rounded to 6 digits:\par\nobreak
\end{spreadtab}
\end{center}
+\subsection{Decimal seprarator}
+The \verb-fp- return its results with the decimal point separator. After the job of \verb-fp-, \ST can change this decimal separator: everything happens as if the results returned by \verb-fp- were taking this into account. The command \verbinline-\STsetdecimalsep- take a mandatory argument which is the char used as decimal separator:
+\begin{center}
+\verbinline-\STsetdecimalsep-\verb-{<char}-
+\end{center}
+For exemple, french users should write this in the preamble of the document:
+\begin{center}
+\verbinline-\STsetdecimalsep{,}-
+\end{center}
+For numeric field located in math mode, the comma is considered as a math punctuation, which explains why it is followed by a space. To pevent this behaviour, it can be written inside brackets:
+
+\begin{minipage}{0.65\linewidth}
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+3,14 is not displayed like $3,14$.\par
+3,14 is displayed like $3{,}14$
+\end{lstlisting}
+\end{minipage}\hfill
+\begin{minipage}{0.35\linewidth}
+3,14 is not displayed like $3,14$.\par
+3,14 is displayed like $3{,}14$
+\end{minipage}%
+
+When cells are in math mode, you can\footnote{It is preferable to use the \texttt{numprint} package to format the results. You can also change the math code of the comma: \texttt{\textbackslash mathcode`,="013B\textbackslash relax}. This trick puts the comma in the class 0 of the ordinary signs while its naturally class is 6 (punctuation signs).} use this feature and ask \ST to replace the decimal point by a comma inside braces with the command \verbinline-\STsetdecimalsep{{,}}-. In these tables where each cell is in math mode, the space after the commas are neutralized in the second table:
+
+\begin{minipage}{0.65\linewidth}
+\begin{lstlisting}
+\STsetdecimalsep{,}
+\begin{spreadtab}{{tabular}{|*3{>{$}r<{$}}|}}\hline
+@x & @y & @\text{Average}\\\hline
+5 & -4 & (a2+b2)/2\\
+-6.1 & -8 & (a3+b3)/2\\
+9.85 & 3.7 & (a4+b4)/2\\\hline
+\end{spreadtab}\par\smallskip
+\STsetdecimalsep{{,}}
+\begin{spreadtab}{{tabular}{|*3{>{$}r<{$}}|}}\hline
+@x & @y & @\text{Average}\\\hline
+5 & -4 & (a2+b2)/2\\
+-6.1 & -8 & (a3+b3)/2\\
+9.85 & 3.7 & (a4+b4)/2\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.35\linewidth}
+\centering
+\STsetdecimalsep{,}
+\begin{spreadtab}{{tabular}{|*3{>{$}r<{$}}|}}\hline
+@x & @y & @\text{Average}\\\hline
+5 & -4 & (a2+b2)/2\\
+-6.1 & -8 & (a3+b3)/2\\
+9.85 & 3.7 & (a4+b4)/2\\\hline
+\end{spreadtab}\par\smallskip
+\STsetdecimalsep{{,}}
+\begin{spreadtab}{{tabular}{|*3{>{$}r<{$}}|}}\hline
+@x & @y & @\text{Average}\\\hline
+5 & -4 & (a2+b2)/2\\
+-6.1 & -8 & (a3+b3)/2\\
+9.85 & 3.7 & (a4+b4)/2\\\hline
+\end{spreadtab}
+\end{minipage}
+
\section{Macro-functions}
The \falseverb{fp} package provides a limited set of operations and functions. If these are not sufficient then \ST allows the advanced programmer to write macros using the operations and functions of \falseverb{fp}. This section presents the macro-functions currently available\footnote{Many others should be written soon and be available in future versions of the package.}. There will be more details on how to program macro functions in the next version of this manual.
@@ -846,10 +1072,65 @@ For the second step, cells are evaluated from top to bottom, left to right: at l
In the following (lines 5 to 8), there is only one cell per line which means that when \ST tries to evaluate the cell, either it contains a number or dependant cells are already calculated.
+\subsection{Debug mode}
+To ease the use of \ST, a debug mode is available. It is activated when the command \verbinline-\STdebug- is written in the optional argument of the \verbinline-spreadtab- environment. This command changes the behavior of \ST which, instead of displaying the final table, displays one (or more) table(s) containing debugging informations. This display is done just after \ST has read all the cells, and no calculating formula has yet taken place. There are as many tables as commands \verbinline-\STdebug-, provided that their argument is different. Only 3 arguments are possible:
+\begin{itemize}
+ \item \verbinline-\STdebug{formula}-: displays all the numeric fields and the ends of lines;
+ \item \verbinline-\STdebug{text}-: displays all the textual fields;
+ \item \verbinline-\STdebug{code}-: displays the internal code of the cells. Indeed, \ST assigns a code to every cell when it reads the table. Here are the possible values of this code:
+ \begin{enumerate}[label=\small\textbullet]
+ \item $-1$ if the cell is merged with \verbinline-\multicolumn-;
+ \item 0 if the cell is a text cell or is empty;
+ \item 1 if the numeric field of the cell contains a formula which will be computed later;
+ \item 2 if the numeric field of the cell contains a number.
+ \end{enumerate}
+\end{itemize}
+
+When the ``debug mode'' is activated, the final table is not displayed.
+
+Here is a table which will be used for the next example:
+
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|r|r|}}\hline
+@$x$ &@$y$ & @$x+y$\\\hline\hline
+22 & 54 & \STcopy{v3}{a2+b2} \\
+43 & 65 & \\
+49 & 37 & \\\hline
+$Sx=:={a2+a3+a4}$ & $Sy=:={b2+b3+b4}$ & $Sx+Sy=:={}$\\\hline
+\multicolumn2{|r|}{$Sy-Sx=:={b5-a5}$} & @\multicolumn1c{}\\\cline{1-2}
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|r|r|}}\hline
+@$x$ &@$y$ & @$x+y$\\\hline\hline
+22 & 54 & \STcopy{v3}{a2+b2} \\
+43 & 65 & \\
+49 & 37 & \\\hline
+$Sx=:={a2+a3+a4}$ & $Sy=:={b2+b3+b4}$ & $Sx+Sy=:={}$\\\hline
+\multicolumn2{|r|}{$Sy-Sx=:={b5-a5}$} & @\multicolumn1c{}\\\cline{1-2}
+\end{spreadtab}
+\end{center}
+Let's ask \ST to shows the 3 possible debugging tables for table above. To do this, just change the line 1 in the code above to:
+
+\hfill\verbinline[basicstyle=\ttfamily\small]-\begin{spreadtab}[\STdebug{text}\STdebug{formula}\STdebug{code}]{{tabular}{|rr|r|}}\hline-\hfill\kern0pt
+\begin{center}
+\begin{spreadtab}[\STdebug{text}\STdebug{formula}\STdebug{code}]{{tabular}{|rr|r|}}\hline
+@$x$ &@$y$ & @$x+y$\\\hline\hline
+22 & 54 & \STcopy{v3}{a2+b2} \\
+43 & 65 & \\
+49 & 37 & \\\hline
+$Sx=:={a2+a3+a4}$ & $Sy=:={b2+b3+b4}$ & $Sx+Sy=:={}$\\\hline
+\multicolumn2{|r|}{$Sy-Sx=:={b5-a5}$} & @\multicolumn1c{}\\\cline{1-2}
+\end{spreadtab}
+\end{center}
+These 3 debugging tables may help to better understand what happens behind the scene when \ST works. We can observe that all cells with a numeric field (see table 2) have an internal code of 1 or 2 (see table 3) and an associated numeric field marker ``\verb-:=-'' in table 1. This marker represents the location where will be inserted (by substitution) the result of the numeric field. So from the contents of text fields in table 1 and once calculated the numeric fields, by a simple substitution, the cells are reconstituted to give those of the final table.
+
+In the debugging tables, cells containing the coordinates are grayed if the package \href{http://www.ctan.org/tex-archive/macros/latex/contrib/colortbl/}{\texttt{\textbf{colortbl}}} has been loaded, they are left white otherwise.
+
\section{Examples}
In the examples of this section, the numbers entered by the user are in \textcolor{black}{red} and the calculated numbers are in \textcolor{black}{black}
-In these tables, lots of tricks (struts, \verbinline-\multicolumn- commands) and packages (including the numprint package and its columns 'N`, which aligns the decimal points) were used to obtain a satisfactory result. The code is sometimes cumbersome and difficult to read, but these tables are not basic but well-groomed examples!
+In these tables, lots of tricks (struts, \verbinline-\multicolumn- commands) and packages (including the numprint package and its columns 'N`, which aligns the decimal points) were used to obtain a satisfactory result. The code is sometimes cumbersome and difficult to read, but these tables are not basic but well-groomed examples! For readability, the command \verbinline-\STcopy- is not used.
\subsection{The Pascal's triangle again!}
\begin{lstlisting}
@@ -1047,7 +1328,8 @@ Each number is the sum of two numbers located below it.
&\multicolumn{2}{|K}{:={[-1,1]+[1,1]}}&\multicolumn{2}{|K}{:={[-1,1]+[1,1]}}&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&\\\hline
\multicolumn{2}{|K}{\color{red}:={-5}}&\multicolumn{2}{|K}{\color{red}:={3}}&\multicolumn{2}{|K}{\color{red}:={-2}}&\multicolumn{2}{|K|}{\color{red}:={-3}}\\\hline
\end{spreadtab}
-\end{center}\medskip
+\end{center}
+\medskip
\parskip0pt
\begin{center}
$\star$\par