summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/spreadtab
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/spreadtab
Initial commit
Diffstat (limited to 'macros/latex/contrib/spreadtab')
-rw-r--r--macros/latex/contrib/spreadtab/README34
-rw-r--r--macros/latex/contrib/spreadtab/spreadtab-en.pdfbin0 -> 578154 bytes
-rw-r--r--macros/latex/contrib/spreadtab/spreadtab-en.tex1668
-rw-r--r--macros/latex/contrib/spreadtab/spreadtab-fr.pdfbin0 -> 609980 bytes
-rw-r--r--macros/latex/contrib/spreadtab/spreadtab-fr.tex1668
-rw-r--r--macros/latex/contrib/spreadtab/spreadtab.sty2193
6 files changed, 5563 insertions, 0 deletions
diff --git a/macros/latex/contrib/spreadtab/README b/macros/latex/contrib/spreadtab/README
new file mode 100644
index 0000000000..2f7ffaf9f7
--- /dev/null
+++ b/macros/latex/contrib/spreadtab/README
@@ -0,0 +1,34 @@
+ L'extension
+ spreadtab
+
+ v0.5
+
+ 27 f\'evrier 2019
+
+Author : Christian Tellechea
+Email : unbonpetit@netc.fr (CT)
+ Commentaires, signalements de bugs et
+ suggestions bienvenus
+Licence : Released under the LaTeX Project Public License v1.3c or
+ later, see http://www.latex-project.org/lppl.txt
+
+----------------------------------------------------------------------
+ R\'esum\'é
+
+Cette extension met \`a disposition des fonctionnalit\'es de tableur
+dans les environnements tableaux de LaTeX.
+
+Les cellules d'un tableau ont des coordonn\'ees repr\'esentant leur
+ligne et colonne, et par cet interm\'ediaire, peuvent \^etre
+ins\'er\'ees dans des formules pour g\'en\'erer des valeurs dans
+d'autres cellules.
+
+----------------------------------------------------------------------
+ Abstract
+
+This package provides spreadsheet features for LaTeX table
+environments.
+
+The cells in a table have coordinates representing their row and
+column, and by this way can be inserted into formulas to generate
+values in other cells.
diff --git a/macros/latex/contrib/spreadtab/spreadtab-en.pdf b/macros/latex/contrib/spreadtab/spreadtab-en.pdf
new file mode 100644
index 0000000000..2c95a606f0
--- /dev/null
+++ b/macros/latex/contrib/spreadtab/spreadtab-en.pdf
Binary files differ
diff --git a/macros/latex/contrib/spreadtab/spreadtab-en.tex b/macros/latex/contrib/spreadtab/spreadtab-en.tex
new file mode 100644
index 0000000000..5618aa8b1f
--- /dev/null
+++ b/macros/latex/contrib/spreadtab/spreadtab-en.tex
@@ -0,0 +1,1668 @@
+% Manual of the "spreadtab" package
+\documentclass[english,a4paper,10pt]{article}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage[a4paper,margin=2.6cm]{geometry}
+\usepackage[table]{xcolor}
+\usepackage{amsmath,amssymb,textcomp,array,arydshln,tabularx,listings,numprint,xspace,fancyhdr,libertine,babel,enumitem,bxtexlogo}
+\bxtexlogoimport{*}
+\usepackage[xfp,fp]{spreadtab}\STusexfp
+\usepackage[italic]{mathastext}
+\usepackage[scaled=0.8]{luximono}
+\fancyhead[L]{}
+\fancyhead[C]{\small\bfseries\ST}
+\fancyhead[R]{\scriptsize\slshape \leftmark}
+\fancyfoot[l]{}
+\fancyfoot[c]{}
+\fancyfoot[r]{\thepage}
+\usepackage[bottom]{footmisc}
+\usepackage[protrusion=true,final,verbose=true,babel=true]{microtype}
+
+\makeatletter
+\definecolor{ST@bckgcolor}{rgb}{0.87,0.9,1}
+\definecolor{ST@codebckgcolor}{rgb}{0.9,0.9,0.9}
+\definecolor{ST@keywordstc}{rgb}{0.7,0,0}
+\definecolor{ST@keywordslatex}{rgb}{0,0,1}
+\definecolor{ST@arguments}{rgb}{0,0,0}
+\definecolor{ST@comments}{rgb}{0.5,0.5,0.5}
+\lstset{%
+ language=[AlLaTeX]TeX,float=hbp,basicstyle=\footnotesize\ttfamily,identifierstyle=\color{ST@arguments},%
+ keywordstyle=\color{ST@keywordslatex},commentstyle=\itshape\color{ST@comments},%
+ columns=fixed,tabsize=4,frame=single,extendedchars=false,%
+ showspaces=false,showstringspaces=false,numbers=left,numberstyle=\tiny\ttfamily,%
+ breaklines=true,breakindent=3em,backgroundcolor=\color{ST@bckgcolor},breakautoindent=true,%
+ captionpos=t,xleftmargin=1em,xrightmargin=1em,lineskip=0pt,%
+ numbersep=1em,classoffset=1,%
+ morekeywords={% les macros et commandes de spreadtab
+ spreadtab,endspreadtab,SThiderow,SThidecol,STsavecell,STautoround,STmessage,STsetdecimalsep,STtransposecar,STdebug,STdisplaytab,STsetdisplaymarks,%
+ STnumericfieldmarker,STprintnum,STtextcell,STcopy,STtag,STmakegtag,STeol,fact,id,ifeq,ifgt,iflt,numtofrshortdate,%
+ numtoengshortdate,numtofrlongdate,numtoenglongdate,numtofrmonth,%
+ numtoengmonth,numtofrday,numtoengday,sum,rand,randint,sumprod,%
+ frshortdatetonum,engshortdatetonum,englongdatetonum,frlongdatetonum,gcd,lcm,tag,cell,row,col,value},%
+ 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}
+
+\def\engdate{\expandafter\engdatei\STdate\@nil}
+\def\engdatei#1/#2/#3\@nil{\number#3\relax\space\ifcase #2 \or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi{} #1}
+\makeatother
+
+% 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{\STname}\xspace}
+\newcommand\xfp{\texttt{\bfseries xfp}\xspace}
+\newcommand\fp{\texttt{\bfseries fp}\xspace}
+\newcommand\falseverb[1]{\texttt{\detokenize{#1}}}
+
+\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}
+\begin{titlepage}
+ \null\par\vfill
+ \begin{center}
+ \begin{minipage}{0.75\linewidth}
+ \begin{center}
+ \Huge\bfseries \ST\par\vspace{5pt}
+ \small v\STver\par\vspace{25pt}
+ \normalsize User's manual
+ \end{center}
+ \end{minipage}
+ \end{center}
+ \vspace{1cm}
+ \begin{center}
+ Christian {\sc Tellechea}\par\small
+ \href{mailto:unbonpetit@netc.fr}{\texttt{\textbf{unbonpetit@netc.fr}}}\par\vspace{5pt}
+ \engdate
+ \end{center}
+ \vfill
+ \begin{center}
+ \begin{minipage}{0.8\linewidth}
+ \noindent\hrulefill\par
+ \hfill\textbf{\textit{Abstract}}\hfill{}\medskip\par\footnotesize
+ This package provides spreadsheet features for \LaTeX{} table environments.\par\medskip
+ The main feature allows the user to construct tables in a manner similar to a spreadsheet where cells are used in formulas to generate values in other cells. The package computes the formulas in the correct order and finally displays the table with the numeric results.\par
+ \hrulefill
+ \end{minipage}
+ \end{center}
+\vfill{}
+\end{titlepage}
+
+\tableofcontents\newpage
+\parskip\medskipamount
+\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. The package is loaded with the classic syntax in the preamble:
+\begin{center}
+\verb-\usepackage[<options>]{spreadtab}-
+\end{center}
+where the options "\verb|fp|" or "\verb|xfp|" select the calculation engine. If no option is specified, the engine will be \fp. If both options are specified, the active engine at the beginning of the document will be \xfp, but in this case, you can change the engine at any time by running \verbinline|\STusefp| or \verbinline|\STusexfp|. This documentation is compiled with the engine \xfp, unless examples where \fp engine is selected. As a general rule, the two calculation engines must give identical results, but
+\begin{itemize}
+ \item \fp is a fixed point calculation engine (18 digits before and 18 after) and therefore gives more digits after the decimal point than \xfp which performs floating point calculations with 16 significant digits; on the other hand, \xfp natively allows tests, manages infinity and \verb|NaN|, understands implicit multiplication by juxtaposition, etc.
+ \item differences exist between the two engines regarding the functions available both in terms of syntax and their existence. Indeed, the function \verb|max(...)| only admits \emph{two} numbers as arguments with \fp while \xfp accepts as many arguments as you want. Similarly, the exponential is obtained with \verb|e^x| or \verb|pow(x,e)| with \fp while the syntax with \xfp is \verb|exp(x)|. Moreover, the functions recognized by the two engines are not the same, as can be seen from their documentation: \verb|ceil| for example, only exists for \xfp. In general, we can consider \xfp to have more features than \fp;
+ \item the functions \verbinline|rand| and \verbinline|randint| are not available with the engine \xfp when compiling with an old version of \XeLaTeX{}.
+\end{itemize}
+
+The package requires \eTeX, \LaTeXe{} format and the \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\fp} or \href{https://ctan.org/pkg/xfp}{\xfp} packages, which performs arithmetic on cell values. Also, the \href{http://www.ctan.org/tex-archive/macros/latex/contrib/xstring/}{\texttt{\textbf{xstring}}} package is needed.\medskip
+
+The package is compatible with \emph{all} tabular environments, and assumes that `\verb=&=' is used to delimit columns and `\verb-\\-' to end lines (but see page~\pageref{STeol}). This compatibility requirement led me to program \ST so that it works independently of the table environment. Thus, reading the table, processing and calculating the formulas is done \emph{before} the environment table `sees' the body of the table.\medskip
+
+Consequently, \ST proceeds in 3 main stages before \verbinline=\begin{<table environment>}= sees the table:
+\begin{itemize}
+ \item first, it reads the body of the table, divides it in lines and cells, and in each cell, seeks a possible formula;
+ \item then, it computes the formulas in the cells, taking care for each to previously calculate all the dependent cells. The calculations are made by the package \fp or \xfp, provided that the formulas to be evaluated in the cells are compatible with the syntaxes of the macros \verb|\FPeval| of the package \fp or \verb|\fpeval| of the package \xfp\footnote{If you want to use the logical "AND" of \xfp "\texttt{\string&\string&}", it is \emph{mandatory} to put this operator between brackets in an array so that the tokens \texttt{\string&\string&} are not understood as column separators. In a cell of a table, we will write for example \texttt{a1>1 \string{\string&\string&\string} a1<10}.};
+ \item finally, it is necessary to rebuild the table, replacing each formula by its numerical calculated value and handing over to the environment name specified by the user.
+\end{itemize}
+The syntax in both the following is allowed (and equivalent), where \verb-<name>- is the name of any table environment available with \LaTeX{} or with a package:\par\nobreak
+\begin{minipage}{0.48\linewidth}
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+\begin{spreadtab}{{<name>}{<parameters>}}
+ table with formulas and numbers
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}\hfill or\hfill
+\begin{minipage}{0.48\linewidth}
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+\spreadtab{{<name>}{<parameters>}}
+ table with formulas and numbers
+\endspreadtab
+\end{lstlisting}
+\end{minipage}
+
+After the work of \ST, we get a display as if we had written:
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+\begin{<name>}{<parameters>}
+ table with numbers
+\end{<name>}
+\end{lstlisting}
+
+Although having features resembling those of a spreadsheet with \LaTeX{} is appreciable, the 3 stages described above take time. 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 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. However, the advantage of this package is that it makes it possible to write \emph{in the \LaTeX{} code} tables involving 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 formula 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 this package as a good programming exercise.
+
+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 Andrew \textsc{Parsloe} for proofreading the english translation of this manual.
+
+\section{Basic features}
+A table is a rectangular array of cells which may be viewed as a set of cells arranged in horizontal rows or vertical columns.
+
+\label{STeol}By default, \ST expects a `\verb-\\-' at the end of lines, which is usual in tables. This end of line marker can be changed via the \verbinline-\STeol{<macro>}- command. We can write for example \verbinline-\STeol{\tabularnewline}-. It is important to remember that the ends of lines to be inserted in the final table will always be `\verb-\\-' even if the end of line marker that \ST sees when it \emph{reads} the table is different.
+
+\subsection{Absolute references}
+A table cell is identified by the pair \falseverb{<colref><rowref>}\footnote{Note: this is the opposite to the standard matrix convention}, where:
+\begin{itemize}
+ \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}. 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 of each row and each column and then calculates the grand total:\par\nobreak
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{rr|r}}
+22 & 54 & a1+b1 \\
+43 & 65 & a2+b2 \\
+49 & 37 & a3+b3 \\
+\hline
+a1+a2+a3 & b1+b2+b3 & a4+b4
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.25\linewidth}
+\centering
+\begin{spreadtab}{{tabular}{rr|r}}
+22 & 54 & a1+b1 \\
+43 & 65 & a2+b2 \\
+49 & 37 & a3+b3 \\
+\hline
+a1+a2+a3 & b1+b2+b3 & a4+b4
+\end{spreadtab}
+\end{minipage}%
+
+For people familiar with maths, this other example calculates the first lines of Pascal's triangle:\par\nobreak
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{ccccc}}
+1 & & & & \\
+a1 & a1 & & & \\
+a2 & a2+b2 & b2 & & \\
+a3 & a3+b3 & b3+c3 & c3 & \\
+a2 & a4+b4 & b4+c4 & c4+d4 & d4
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.25\linewidth}
+\centering
+\begin{spreadtab}{{tabular}{ccccc}}
+1 & & & & \\
+a1 & a1 & & & \\
+a2 & a2+b2 & b2 & & \\
+a3 & a3+b3 & b3+c3 & c3 & \\
+a2 & a4+b4 & b4+c4 & c4+d4 & d4
+\end{spreadtab}
+\end{minipage}%
+
+\subsection{Relative references}
+To refer to a cell, it may be convenient to specify its position relative to where the formula is written. Thus, the relative coordinates of a cell are 2 relative numbers written using this syntax: \falseverb{[x,y]} where \falseverb x is the horizontal offset from the cell containing the formula and \falseverb y is the vertical offset. For example, \falseverb{[-2,3]} refers to the cell located 2 columns before (on the left) and 3 rows after (below) the cell where the formula is located.
+
+Here is the same table as above but the references are relatives and the \verbinline-matrix- environment of the \href{http://www.ctan.org/tex-archive/macros/latex/required/amslatex/math/}{\texttt{\textbf{amsmath}}} package is used:\par\nobreak
+\begin{minipage}{0.82\linewidth}
+\begin{lstlisting}
+$
+\begin{spreadtab}{{matrix}{}}
+1\\
+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]
+\end{spreadtab}
+$
+\end{lstlisting}
+\end{minipage}\hfill
+\begin{minipage}{0.15\linewidth}
+\centering
+$
+\begin{spreadtab}{{matrix}{}}
+1\\
+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]
+\end{spreadtab}
+$
+\end{minipage}%
+
+We note that relative references are more appropriate here, since only 2 different references are used: \falseverb{[0,-1]} which refers to the cell above and \falseverb{[-1,-1]} which refers to the cell located to the NW of the current cell.\medskip
+
+Absolute and relative references can be mixed in a formula.
+
+\subsection{Text cells}
+If you want to put only text in a cell, you must tell \ST that the cell should not be calculated. Simply place somewhere in the cell the character `\falseverb @' with its usual catcode 12. The cell will be ignored by \ST which will consider it as an inert cell impossible to reference\footnote{There is an exception, see page \pageref{datetonum}.} elsewhere in the table.
+
+Example:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|ccc|}}
+\hline
+@ values of $x$ & -5 & -1 & 4 \\
+@ $f(x)=2x$ & 2*[0,-1] & 2*[0,-1] & 2*[0,-1] \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|ccc|}}
+\hline
+@ values of $x$ & -5 & -1 & 4 \\
+@ $f(x)=2x$ & 2*[0,-1] & 2*[0,-1] & 2*[0,-1] \\\hline
+\end{spreadtab}
+\end{center}
+The control sequence \verbinline=\STtextcell= expands to the character `\falseverb @'. It is possible to redefine it; for example, after \verbinline-\renewcommand\STtextcell{`}-, a cell containing the char \verb=`= will be understood as a text cell.
+
+Moreover, if a cell is empty or filled with spaces, \ST will consider it as a text cell.
+
+\subsection{Mixed cells}
+In reality, each cell is composed of two fields. The first is a \emph{numeric field} containing the formula; the second is a \emph{text field}, ignored by the calc engine and not taken into account for calculations:
+\begin{itemize}
+ \item if nothing is specified in a cell, the entire cell is the number field, and the text field is empty (this was the case for all table cells of Pascal's triangle seen above);
+ \item if the cell contains the `\falseverb @' character, then the entire cell is the text field. The numeric field is empty and inaccessible;
+ \item if the cell contains the marker `\verb-:=-', then the following argument between braces is the numeric field, and everthing else is the text field. The cell has this structure:\par
+ \hfil\verb-<text field>:={numeric field}<end of text field>-\hfil\null\par
+ The marker `\verb-:=-' is the expansion of the control sequence \verbinline-\STnumericfieldmarker-. It is possible to redefine it, for example:\par\smallskip
+ {\centering\verbinline-\renewcommand\STnumericfieldmarker{\=}-\par\smallskip}
+ In this case, the expansion of the marker `\verb-\=-' would have no importance and would not be involved in the process. For \ST, it is only a token showing where the formula begins. This token is sought and recognized but is never expanded.
+\end{itemize}
+Once the \falseverb{numeric field} is computed, `\falseverb{:={numeric field}}' is replaced by the numeric value.
+
+Note that `\verb-:={numeric field}-' may be inside brackets, whatever be the level of nesting. For example, if a cell contains \verb-\textbf{:={a1+1}}- and if the numeric value of the cell \falseverb{a1} is 5, then finally, the cell will contain \verb-\textbf{6}-\medskip
+
+Here is a simple example:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|c|c||c|}}\hline
+value 1 : :={50} & value 2 : :={29} & average : \textbf{:={(a1+b1)/2}}\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|c|c||c|}}\hline
+value 1 : :={50} & value 2 : :={29} & average : \textbf{:={(a1+b1)/2}}\\\hline
+\end{spreadtab}
+\end{center}
+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 another with \verbinline-\STcopy- (see next section) 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-<formula>-\footnote{The copy can only be done to cells located on the right and below the cell containing 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 target 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 usual, 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-!-' character is the expansion of the control sequence \verbinline-\STtransposecar-. It may be changed to any other with \verbinline-\renewcommand\STtransposecar-\verb-{<char>}-. The `\verb-!-' character, 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 copy 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$ is equal to 0, the copy is limited to the column or row of the source cell. Instead of writing \verb-v0- or \verb->0-, it is possible to write \verb-v- or \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- commands in several source cells have the same target cell, then, the formula this latter receives is the one contained in the last \verbinline-\STcopy- command when the table is read from top left to bottom 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 unchanged since their numeric fields 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 to 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 hand, a cell containing text `\verb-@-' cannot receive a formula when copying 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{Decimal seprarator}
+The \fp and \xfp packages return results with the decimal point separator. After the job of calculation, \ST can change this decimal separator: everything happens as if the results returned by \fp or \xfp were taking this into account. The command \verbinline-\STsetdecimalsep- takes a mandatory argument which is the character used as decimal separator:
+\begin{center}
+\verbinline-\STsetdecimalsep-\verb-{<char>}-
+\end{center}
+For example, French users should write this in the preamble of the document:
+\begin{center}
+\verbinline-\STsetdecimalsep{,}-
+\end{center}
+For numeric fields 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 natural 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}
+
+\subsection{Number formatting and the \fp package}
+With \verb|fp| option, all calculations are made by the \verb-\FPeval- macro\footnote{This macro accepts infix or postfix notation. Consequently, both can be used to write formulas in a cell. For example the infix formula `\falseverb{a1+b1}' is equivalent to the postfix ones `\falseverb{a1 b1 add}' or `\falseverb{a1 b1 +}'.} of the \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\fp} package. This package provides all necessary arithmetical functions along with various scientific and trigonometric functions. Calculations are made with 18 decimal digits of precision, and \fp displays \emph{all} the decimals! Without taking precautions, you can end up with a lot of numbers in the decimal parts of some results. This section is compiled with \verbinline|\STusefp|.\STusefp
+
+The number of digits displayed can be controlled in various ways:
+\begin{itemize}
+ \item the \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} package can be used in order to properly display numbers;
+ \item \fp can round or truncate numbers with \verb-round(number,integer)- or \verb-trunc(number,integer)- but the syntax makes this tedious to write if this is needed for many cells;
+ \item \ST can round \emph{all} the numbers in the table with the macro \verbinline-\STautoround- whose argument is number of digits in the decimal part. If the argument is empty, no rounding is done. If the starred macro \verbinline-\STautoround*- is used, the decimal part is filled with 0 as necessary (only with \fp).
+\end{itemize}
+In this example, floating point numbers are rounded to 6 digits:\par\nobreak
+\begin{lstlisting}
+\STautoround{6}
+\begin{spreadtab}{{tabular}{|l|*7{>{\centering\arraybackslash}m{1.35cm}|}}}
+\hline
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline
+@$x^{-1}$& 1/b1 & 1/c1 & 1/d1 & 1/e1 & 1/f1 & 1/g1 & 1/h1\\\hline
+\end{spreadtab}\medskip
+
+\STautoround*{6}
+\begin{spreadtab}{{tabular}{|l|*7{>{\centering\arraybackslash}m{1.35cm}|}}}
+\hline
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline
+@$x^{-1}$& 1/b1 & 1/c1 & 1/d1 & 1/e1 & 1/f1 & 1/g1 & 1/h1\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\STautoround{6}
+\begin{spreadtab}{{tabular}{|l|*7{>{\centering\arraybackslash}m{1.35cm}|}}}
+\hline
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline
+@$x^{-1}$& 1/b1 & 1/c1 & 1/d1 & 1/e1 & 1/f1 & 1/g1 & 1/h1\\\hline
+\end{spreadtab}\medskip
+
+\STautoround*{6}
+\begin{spreadtab}{{tabular}{|l|*7{>{\centering\arraybackslash}m{1.35cm}|}}}
+\hline
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline
+@$x^{-1}$& 1/b1 & 1/c1 & 1/d1 & 1/e1 & 1/f1 & 1/g1 & 1/h1\\\hline
+\end{spreadtab}
+\end{center}
+
+All the numbers contained in the final table, either typed as is or coming from a calculation are processed by the macro\verbinline-\STprintnum-. By default, this macro has no effect on its argument and is defined this way:
+\begin{center}
+ \verbinline-\newcommand\STprintnum[1]{#1}-
+\end{center}
+It is possible to round all the numbers via the \verbinline-\numprint- command from the \verb-numprint- package. To achieve this, the \verbinline-\STprintnum- command must be redefined:\par\nobreak
+\begin{lstlisting}
+\renewcommand\STprintnum[1]{\numprint{#1}}
+\nprounddigits{6}
+\begin{spreadtab}{{tabular}{cccccccc}}
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 &7 \\\hline
+@$1/x$ &1/b1&1/c1&1/d1&1/e1&1/f1&1/g1&1/h1
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\renewcommand\STprintnum[1]{\numprint{#1}}
+\nprounddigits{6}
+\begin{spreadtab}{{tabular}{cccccccc}}
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 &7 \\\hline
+@$1/x$ &1/b1&1/c1&1/d1&1/e1&1/f1&1/g1&1/h1
+\end{spreadtab}
+\end{center}
+
+Here is another similar example where we test if the number to display is negative with the command \verbinline-\FPifneg- from the \fp package. If this happens, the number is displayed in red. The command \verbinline-\STautoround- was preferred to \verbinline-\nprounddigits- from the \verb-numprint- package because the latter adds unnecessary 0's.
+\begin{lstlisting}
+\STsetdecimalsep{.}
+\renewcommand\STprintnum[1]{\FPifneg{#1}\color{red}\fi\numprint{#1}}
+\STautoround{6}
+\begin{spreadtab}{{tabular}{cccccccc}}
+@$x$ & -1 & 2 & -3 & 4 & -5 & 6 & -7 \\\hline
+@$1/x$ &1/b1&1/c1&1/d1&1/e1&1/f1&1/g1&1/h1
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\STsetdecimalsep{.}
+\renewcommand\STprintnum[1]{\FPifneg{#1}\color{red}\fi\numprint{#1}}
+\STautoround{6}
+\begin{spreadtab}{{tabular}{cccccccc}}
+@$x$ & -1 & 2 & -3 & 4 & -5 & 6 & -7 \\\hline
+@$1/x$ &1/b1&1/c1&1/d1&1/e1&1/f1&1/g1&1/h1
+\end{spreadtab}
+\end{center}\STusexfp
+
+\subsection{End of lines and horizontal rules}
+\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 rules, 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}
+\begin{spreadtab}{{tabular}{*5c}}
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]\\[1em]
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\ \hline\hline
+[0,1] & [-1,1] & & & \\ \cline{2-4}
+1 & & & & \\ \hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{*5c}}
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]\\[1em]
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\ \hline\hline
+[0,1] & [-1,1] & & & \\ \cline{2-4}
+1 & & & & \\ \hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Hide a row or column}
+Sometimes, a column or a row is intended for intermediate calculations and does not need to be displayed in the final table. For this, \ST provides two control sequences \verbinline=\SThiderow= and \verbinline=\SThidecol= which, when placed in a cell, hide the row or column that contains the cell.
+
+An example:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|ccc|}}
+\hline
+@ values of $x$ & -1 & 0\SThidecol & 2 & 3 \\\hline
+@$f(x)=2x-1$ & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 \\
+@$g(x)=x-10$\SThiderow & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 \\
+@$h(x)=1-x$ & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|ccc|}}
+\hline
+@ values of $x$ & -1 & 0\SThidecol & 2 & 3 \\\hline
+@$f(x)=2x-1$ & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 \\
+@$g(x)=x-10$\SThiderow & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 \\
+@$h(x)=1-x$ & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] \\\hline
+\end{spreadtab}
+\end{center}
+The row containing $g(x)$ and column corresponding to the value 0 are hidden.
+
+Remember that the hidden rows and columns are \emph{invisible} to the tabular environment chosen by the user. Thus, only 4 columns have been defined (\falseverb{|r|ccc|}) and not 5 as seen by \ST.
+
+Just to see the difference, here is the table obtained when setting 5 columns in the preamble and not hiding any row or column:\par\nobreak
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|cccc|}}
+\hline
+@ values of $x$ & -1 & 0 & 2 & 3 \\\hline
+@$f(x)=2x-1$ & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 \\
+@$g(x)=x-10$ & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 \\
+@$h(x)=1-x$ & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] \\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Save the result of a cell}
+It may be necessary to save the numerical value of a cell to display it outside a formula or even outside the table. Here is how to do it:
+\begin{center}
+\verbinline-\STsavecell{<control sequence>}{<absolute reference>}-
+\end{center}
+With a \verbinline-\global\def-\footnote{The \texttt{\string\def} command does not check if the macro it defines already exists.}, this command globally saves in \falseverb{<control sequence>} the result of the formula contained in the cell \falseverb{<absolute reference>}.\medskip
+
+Only absolute references can be used since this command must be placed in the optional argument of the \verbinline-spreadtab- environment.
+
+Example:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}[\STsavecell\result{c1}]{{tabular}{|c|c|c|c|c|}}
+\hline
+10 & a1+10 & b1+10 & a1+b1+c1 & @cell c1 : \result\\\hline
+\end{spreadtab}
+\par\medskip
+Here is the cell c1 : \result
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}[\STsavecell\result{c1}]{{tabular}{|c|c|c|c|c|}}
+\hline
+10 & a1+10 & b1+10 & a1+b1+c1 & @cell c1 : \result\\\hline
+\end{spreadtab}
+\par\medskip
+Here is the cell c1 : \result
+\end{center}
+In order to save several cells, the command \verbinline-\STsavecell- can be put several times in the optionnal argument.
+
+Example:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}[\STsavecell\hhh{b3}\STsavecell\mmm{c3}\STsavecell\sss{d3}]{{tabular}{|rc|}}\hline
+@Speed (km/h) &\SThidecol&\SThidecol&\SThidecol& 35 \\
+@distance (km) & & & & 180\\\hline
+@Time (h min s) & trunc(e2/e1,0) & trunc(60*(e2/e1-b3),0) & trunc(3600*(e2/e1-b3)-60*c3,1) &@\hhh\ h \mmm\ min \sss\ s\\\hline
+\end{spreadtab}\par\medskip
+It lasts more than \hhh\ hours.
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}[\STsavecell\hhh{b3}\STsavecell\mmm{c3}\STsavecell\sss{d3}]{{tabular}{|rc|}}\hline
+@Speed (km/h) &\SThidecol&\SThidecol&\SThidecol& 35 \\
+@distance (km) & & & & 180\\\hline
+@Time (h min s) & trunc(e2/e1,0) & trunc(60*(e2/e1-b3),0) & trunc(3600*(e2/e1-b3)-60*c3,1) &@\hhh\ h \mmm\ min \sss\ s\\\hline
+\end{spreadtab}\par\medskip
+It lasts more than \hhh\ hours.
+\end{center}
+
+\subsection{Display the value of a cell}
+In order to display the numeric field of a cell in a textual field, we have seen that we could save this value in a control sequence and use this control sequence anywhere in the table. The process is somewhat tedious\ldots{} Indeed, \verbinline-\STsavecell- is not intended to be used in such a way. Its aim is to save the value of a numeric field for further use \emph{outside} the table.
+
+There is a simpler way to display the numeric field of a cell in a textual field using the syntax \verb-<<reference>>- which is replaced by the numeric field of the cell \verb-reference-, where the \verb-reference- can be absolute or relative. If the text between \verb-<<- and \verb->>- is not a reference, then \verb-<<text>>- is left as is. The \verb-reference- must not contain any space; for example, if you write \verb-<< a1>>-, \ST does not uderstand it as a reference because of the space before `\verb-a1-'.
+
+Example in a textual cell \verb-a3-:
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{lr}}
+@Sell price & 250 \\
+@Purchase price & 216 \\\hline
+@Profit (<<b1>>-<<b2>>) & b1-b2
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{lr}}
+@Sell price & 250 \\
+@Purchase price & 216 \\\hline
+@Profit (<<b1>>-<<b2>>) & b1-b2
+\end{spreadtab}
+\end{center}
+Example in the mixed cell \verb-c1-:
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|c|c||c|}}\hline
+23 & 32 & Average $= \frac{<<a1>>+<<b1>>}{2}= :={(a1+b1)/2}$\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|c|c||c|}}\hline
+23 & 32 & Average $= \frac{<<a1>>+<<b1>>}{2}= :={(a1+b1)/2}$\\\hline
+\end{spreadtab}
+\end{center}
+The characters used to delimit the reference are set to `\verb-<<-' and `\verb->>-' by default. They can be modified with the \verbinline-\STsetdisplaymarks- command whose arguments contain the left and right delimiters. For example, if you write \verbinline-\STsetdisplaymarks{|}{|}-, you will write \verb-|reference|- in order to display the content of the numeric field of the cell \verb-reference-.
+
+\subsection{The use of \ttfamily\textbackslash multicolumn}
+\ST is compatible with the syntax \verbinline=\multicolumn{<n>}{<type>}{<content>}= which merges \falseverb{<n>} cells in a unique cell whose type and content are specified in the arguments.
+
+Even when using \verbinline=\multicolumn=, \ST maintains some consistency in the references. In this table where \verbinline-\multicolumn- is used, the absolute references are displayed:\par\nobreak
+\begin{center}
+\ttfamily
+\begin{tabular}{|*7{c|}}\hline
+a1&b1&c1&d1&e1&f1&g1\\\hline
+a2&\multicolumn{2}{l|}{b2}&d2&e2&f2&g2\\\hline
+\multicolumn{3}{|l|}{a3}&d3&\multicolumn{2}{l|}{e3}&g3\\\hline
+\end{tabular}
+\end{center}
+Thus, whatever the number of merged cells, the next cell has a column number that takes into account the number of merged cells.\medskip
+
+In the last line, cells \falseverb{a3}, \falseverb{b3} and \falseverb{c3} are merged and consequently, the cells \falseverb{b3} and \falseverb{c3} \emph{do not exist} for \ST: it is not possible to refer to \falseverb{b3} or \falseverb{c3} anywhere in the table.\medskip
+
+In this example, every number in the top line is the product of the 2 numbers below:\par\nobreak
+\begin{lstlisting}
+\newcolumntype{K}[1]{@{}>{\centering\arraybackslash}p{#1cm}@{}}
+\begin{spreadtab}{{tabular}{*6{K{0.5}}}}
+\cline{2-5}
+&\multicolumn{2}{|K{1}|}{:={a2*c2}} & \multicolumn{2}{K{1}|}{:={c2*e2}} &\\\hline
+\multicolumn{2}{|K{1}}{:=8}&\multicolumn{2}{|K{1}}{:=7}&\multicolumn{2}{|K{1}|}{:=6}\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\newcolumntype{K}[1]{@{}>{\centering\arraybackslash}p{#1cm}@{}}
+\begin{spreadtab}{{tabular}{*6{K{0.5}}}}
+\cline{2-5}
+&\multicolumn{2}{|K{1}|}{:={a2*c2}} & \multicolumn{2}{K{1}|}{:={c2*e2}} &\\\hline
+\multicolumn{2}{|K{1}}{:=8}&\multicolumn{2}{|K{1}}{:=7}&\multicolumn{2}{|K{1}|}{:=6}\\\hline
+\end{spreadtab}
+\end{center}
+The marker `\falseverb{:=}' is necessary in every cell where the command \verbinline-\multicolumn- is written. Without it, \ST would consider that the whole cell (i.e. \verb-\multicolumn{2}{|c|}{<formula>}-) as the formula, which is impossible to calculate.
+
+\section{Macro-functions}
+The \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 \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.
+
+\subsection{Mathematical macro-functions}
+\subsubsection{Sum cells}
+The macro-function \verbinline=sum= sums one or several ranges of cells.
+
+It should be used like this: \verbinline=sum(<range 1>;<range 2>;...;<range n>)=, where a range of cells is:
+\begin{itemize}
+ \item either a single cell like \falseverb{a1} or \falseverb{[2,1]};
+ \item or a rectangular area bounded by the upper-left cell and lower-right with this syntax:\par{\centering\verb=<cell 1>:<cell 2>=\par}
+ Here are some examples of such areas: \falseverb{a2:d5}, \falseverb{[-1,-1]:[2,3]}, \falseverb{b4:[5,1]}.
+\end{itemize}
+In cell ranges, if a cell does not have a numeric field (empty cell or text cell or merged cell with \verbinline-\mutlicolumn-), it is seen as 0 by \verbinline-sum-.
+
+In the following table, the sum of the binomial coefficients of Pascal's triangle is calculated:\par\nobreak
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{*5c}}
+\multicolumn{5}{c}{sum: :={sum(a2:e6)}}\\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\
+[0,1] & [-1,1] & & & \\
+1 & & & &
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.25\linewidth}
+\centering
+\begin{spreadtab}{{tabular}{*5c}}
+\multicolumn{5}{c}{sum: :={sum(a2:e6)}}\\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\
+[0,1] & [-1,1] & & & \\
+1 & & & &
+\end{spreadtab}
+\end{minipage}%
+
+\subsubsection{The \texttt{fact} macro}
+The macro-function \verbinline=fact(<number>)= computes the factorial of its argument. With the engine \href{https://www.ctan.org/pkg/fp}{\fp}, the argument must be less than 19 to avoid overflows. The \falseverb{<number>} can also be a reference to a cell whose numeric field contains an integer.\medskip
+
+Here are the factorials from 0 to 8:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{*9c}}
+ 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 &8\\\hline
+fact(a1)&fact(b1)&fact(c1)&fact(d1)&fact(e1)&fact(f1)&fact(g1)&fact(h1)&fact(i1)
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{*9c}}
+ 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 &8\\\hline
+fact(a1)&fact(b1)&fact(c1)&fact(d1)&fact(e1)&fact(f1)&fact(g1)&fact(h1)&fact(i1)
+\end{spreadtab}
+\end{center}
+
+\subsubsection{The \texttt{sumprod} macro}
+The function \verbinline=sumprod= multiplies the corresponding elements of 2 or more rectangular ranges and then adds these products.
+
+It should be used like this: \verbinline{sumprod(<range 1>;<range 2>;...;<range n>)}. All the ranges must have the same dimensions.
+
+In this simple example, the average age of a group of children aged from 10 to 15 years old is calculated:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{r*6c}}
+@\Ages & 10 & 11 & 12 & 13 & 14 & 15\\
+@Number & 5 & 8 & 20 & 55 & 9 & 3\\\hline
+@Average&\multicolumn{6}{l}{:={sumprod(b1:g1;b2:g2)/sum(b2:g2)}}
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{r*6c}}
+@Ages & 10 & 11 & 12 & 13 & 14 & 15\\
+@Number & 5 & 8 & 20 & 55 & 9 & 3\\\hline
+@Average&\multicolumn{6}{l}{:={sumprod(b1:g1;b2:g2)/sum(b2:g2)}}
+\end{spreadtab}
+\end{center}
+If any cell in the ranges is empty, pure text or merged with \verbinline-\multicolumn-, its numeric field is replaced by 0.
+
+\subsubsection{Random numbers}
+The macro-functions \verbinline-randint- and \verbinline-rand- each returns a random number depending on its argument.
+
+\paragraph{Random numbers with \fp calc engine}
+With this engine, \verbinline-randind- and \verbinline-rand- are \emph{macro functions} of \ST that rely on the macro \verb|\FPrandom| of \fp.
+
+It should be noted that the seed initializing the random sequence depends on the date and the minute at which the compilation is done. Thus, the random sequence of numbers given by this function will change between two compilations made at different times. If random numbers need to be repeatable, the private macro \verb-\ST@seed- must be cancelled and a seed should be chosen for \fp. Here is the code to do this:\par\nobreak
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+\makeatletter
+\renewcommand\ST@seed{}% redefines the private macro
+\makeatother
+\FPseed=27% gives a seed (any integer) to fp.
+\end{lstlisting}
+The macro-function \verbinline-randint([<number1>,]<number2>)- returns a random \emph{integer} depending on its arguments: \verb=<number1>= is an optional integer with default value 0. The random integer returned is in the interval \verb=[<number1>;=\linebreak[2]\verb=<number2>]=.
+
+The macro-function \verbinline-rand()- returns a random number between 0 and 1.\par\nobreak
+\begin{lstlisting}
+\STautoround{6}
+\STusefp
+\begin{spreadtab}{{tabular}{|l|cccc|}}\hline
+@numbers in [0;1] &rand() &rand() &rand() &rand() \\
+@numbers in [-5;5] &randint(-5,5) &randint(-5,5) &randint(-5,5) &randint(-5,5)\\
+@numbers in [0;20] &randint(20) &randint(20) &randint(20) &randint(20) \\
+\hline
+\end{spreadtab}
+\STusexfp
+\end{lstlisting}
+\begin{center}
+\STautoround{6}
+\STusefp
+\begin{spreadtab}{{tabular}{|l|cccc|}}\hline
+@numbers in [0;1] &rand() &rand() &rand() &rand() \\
+@numbers in [-5;5] &randint(-5,5) &randint(-5,5) &randint(-5,5) &randint(-5,5)\\
+@numbers in [0;20] &randint(20) &randint(20) &randint(20) &randint(20) \\
+\hline
+\end{spreadtab}
+\STusexfp
+\end{center}
+
+\paragraph{Random numbers with \xfp engine}
+With this engine, \verbinline-randind- and \verbinline-rand- are functions recognized natively by \xfp. A warning will be issued if \XeLaTeX{} is used in an older version that does not implement pseudo-random number generation primitives; in this case, using the functions \verbinline-randind- and \verbinline-rand- will not be enabled and will throw compilation errors.
+
+As specified in the documentation of \href{http://mirrors.ctan.org/macros/latex/contrib/l3kernel/interface3.pdf}{\texttt{\textbf{\textbf{interface3}}}}, the function \verbinline|randint(<a>,<b>)| produces a random integer between the two arguments, but if \verb|<a>| is omitted, \verbinline|randint(<b>)| produces an integer between {\color{red}\bfseries1} and \verb|<b>| which is different from the \verbinline-randint- macro function of \ST used with \fp which produces an integer between {\color{red}\bfseries0} and \verb|<b>|.\STusexfp
+
+\begin{lstlisting}
+\STautoround{6}
+\STusexfp
+\begin{spreadtab}{{tabular}{|l|cccc|}}\hline
+@nombers in [0;1] &rand() &rand() &rand() &rand() \\
+@nombers in [-5;5] &randint(-5,5) &randint(-5,5) &randint(-5,5) &randint(-5,5)\\
+@nombers in [0;20] &randint(20) &randint(20) &randint(20) &randint(20) \\
+\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\STautoround{6}
+\STusexfp
+\begin{spreadtab}{{tabular}{|l|cccc|}}\hline
+@nombres dans [0;1] &rand() &rand() &rand() &rand() \\
+@nombres dans [-5;5] &randint(-5,5) &randint(-5,5) &randint(-5,5) &randint(-5,5)\\
+@nombres dans [1;20] &randint(20) &randint(20) &randint(20) &randint(20) \\
+\hline
+\end{spreadtab}
+\end{center}
+
+\subsubsection{GCD and LCM}
+The macro functions `gcd' and `lcm' compute the Greatest Common Divisor and the Least Common Multiple of the list of numbers in their argument:
+\begin{center}
+\verbinline-gcd(number1,number2,...,numberN)-\par
+\verbinline-lcm(number1,number2,...,numberN)-
+\end{center}
+Example :
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|r|r||c|c|}}\hline
+\multicolumn3{|c||}{@Numbers}& @GCD & @LCM \\\hline
+24 & 18 & 12 & \STcopy{v}{gcd(a2,b2,c2)} & \STcopy{v}{lcm(a2,b2,c2)}\\
+15 & 10 & 25 & & \\
+16 & 12 & 15 & & \\
+\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|r|r||c|c|}}\hline
+\multicolumn3{|c||}{@Numbers}& @GCD & @LCM \\\hline
+24 & 18 & 12 & \STcopy{v}{gcd(a2,b2,c2)} & \STcopy{v}{lcm(a2,b2,c2)}\\
+15 & 10 & 25 & & \\
+16 & 12 & 15 & & \\
+\hline
+\end{spreadtab}
+\end{center}
+
+\subsubsection{Scientific notation}
+The macro function `scitodec' converts a number written in scientific notation into a decimal number, understandable by \fp to achieve its calculations. The syntax is \verbinline-scitodec(<text>)-, where \verb-<text>- is:
+\begin{itemize}
+ \item a sequence of characters with the syntax \verb-<mantissa>EE<exponent>- where \verb-<mantissa>- is a decimal number and the \verb-<exponent>- is an integer. The `EE' may be written uppercase or lowercase.
+
+ \verb-<mantissa>EE<exponent>- means the number $\text{\ttfamily <mantissa>}\times10^{\text{\ttfamily <exponent>}}$
+ \item a reference to the \emph{textual} field of a cell containing \verb-<mantissa>EE<exponent>-
+\end{itemize}
+Example :
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|r|}}\hline
+@Scientific notations & @Decimal notations \\\hline
+@4EE2 & \STcopy{v}{scitodec([-1,0])}\\
+@-3.1EE-3 & \\
+@15ee5 & \\
+@-0.025ee7 & \\
+@2.125EE0 & \\
+@3.1575EE-4 & \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|r|}}\hline
+@Scientific notations & @Decimal notations \\\hline
+@4EE2 & \STcopy{v}{scitodec([-1,0])}\\
+@-3.1EE-3 & \\
+@15ee5 & \\
+@-0.025ee7 & \\
+@2.125EE0 & \\
+@3.1575EE-4 & \\\hline
+\end{spreadtab}
+\end{center}
+
+The engine \xfp natively understands numbers written in scientific notation in the form \verb|<a>e<b>| but this syntax is \emph{impossible} to use with \ST because the number \verb|4e3|, which is 4000, would be understood by \ST as 4 followed by the content of the cell \verb|e3|.
+
+\subsubsection{Identity}
+The simplest macro function is `\verbinline=id(<number>)='. It returns the number in its argument. Mathematically, it is not very useful, but with \ST, it makes possible the writing of mathematical expressions in arguments of macro functions where they are not otherwise allowed -- in the argument of \verbinline=sum= for example.
+
+In the code below, the \verbinline-id- macro function is used to compute the range of cells to add with \verbinline-sum-. In this example, the numeric field of the cell `a2' contains 8. Therefore, `\verbinline=sum([0,-1]:[id(a2-1),-1])/a2=' is equivalent to \verbinline=sum([0,-1]:[7,-1])/8=:
+
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{r*{10}c}}
+ @Integers & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
+Mean of the :={8} first integers & sum([0,-1]:[id(a2-1),-1])/a2 \\
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{r*{10}c}}
+ @Integers & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
+Mean of the :={8} first integers & sum([0,-1]:[id(a2-1),-1])/a2 \\
+\end{spreadtab}
+\end{center}
+
+\subsection{Tests}
+Since \fp and its macro \verb|\FPeval| do not accept test in its argument, three macro-functions provide tests (they are not interesting with \xfp and its terenary operator \verb|?:|, see below):\par\nobreak
+\begin{center}
+\verbinline=ifeq(number1,number2,number3,number4)=\par
+\verbinline=ifgt(number1,number2,number3,number4)=\par
+\verbinline=iflt(number1,number2,number3,number4)=
+\end{center}
+\falseverb{number1} and \falseverb{number2} are compared:
+\begin{itemize}
+ \item for \verbinline-ifeq-, is \falseverb{number1} = \falseverb{number2}?
+ \item for \verbinline-ifgt-, is \falseverb{number1} > \falseverb{number2}?
+ \item for \verbinline-iflt-, is \falseverb{number1} < \falseverb{number2}?
+\end{itemize}
+If the test is positive, \falseverb{number3} is returned, otherwise it is \falseverb{number4}.
+
+Here are some values of the function
+$f(x)=\begin{cases}
+10 &\text{if }x<1\\
+0 &\text{if }x=1\\
+-10 &\text{if }x>1
+\end{cases}
+$\smallskip
+
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*2c|}}\hline
+@$x$ & @$f(x)$ \\\hline
+-0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*2c|}}\hline
+@$x$ & @$f(x)$ \\\hline
+-0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\\hline
+\end{spreadtab}
+\end{center}
+The engine \xfp and its ternary operator \verb|<a>?<b>:<c>| makes tests easier in the evaluated expressions: if the test \verb|<a>| is true, \verb|<b>| is retained otherwise, it is \verb|<c>|. Thus, the nested tests above become:
+
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*2c|}}\hline
+@$x$ & @$f(x)$ \\\hline
+-0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*2c|}}\hline
+@$x$ & @$f(x)$ \\\hline
+-0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Macro-functions manipulating dates}
+\subsubsection{Date to number with \ttfamily engshortdatetonum}\label{datetonum}
+The macro \verbinline-engshortdatetonum- converts a short date like 1789/7/14 to an integer which is the number of days passed since the 1st March of the year 0\footnote{This year 0 does not exist but this should not be a problem with recent dates.}. It is important to note that this macro-function requires a \emph{textual} argument and not a number or the result of a mathematical calculation. Therefore, if the argument of this macro-function refers to a cell, that cell \emph{must} be a text cell, i.e. a cell containing `\verb-@-' or `\verb-:={}-'.
+
+In the example below, the first two lines show how to refer to a text cell. The third line displays the date 0 on the left, and more interesting on the right, it shows how to calculate the number corresponding to the current date with the use of the \TeX{} counters \verbinline-\year-, \verbinline-\month- and \verbinline-\day- which contain the numbers of the current year, month and day.\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{cc}}
+@1789/7/14 & engshortdatetonum(a1)\\
+2001/1/1 :={} & engshortdatetonum(a2)\\\hline
+engshortdatetonum(0/3/1) & engshortdatetonum(\number\year/\number\month/\number\day)
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{cc}}
+@1789/7/14 & engshortdatetonum(a1)\\
+2001/1/1 :={} & engshortdatetonum(a2)\\\hline
+engshortdatetonum(0/3/1) & engshortdatetonum(\number\year/\number\month/\number\day)
+\end{spreadtab}
+\end{center}
+Another macro-function provides the same feature but with a long date like `December 25, 1789' or the string contained in \verbinline-\today-:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{cc}}
+englongdatetonum(February 13, 2005) & englongdatetonum(\today)\\
+@July 1, 1970 & englongdatetonum(a2)
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{cc}}
+englongdatetonum(February 13, 2005) & englongdatetonum(\today)\\
+@July 1, 1970 & englongdatetonum(a2)
+\end{spreadtab}
+\end{center}
+
+\subsubsection{From a number to a date}
+Several macro-functions translate a number into a date. All these macro-functions have in common that their result is \emph{text}. Therefore, the cells containing such results \emph{become cells containing text} and if the cell is composed of two fields, the numeric field becomes empty and `\verb-:={<formula>}-' is replaced by its result in the text field.
+
+These macro-functions are:
+\begin{itemize}
+ \item \verbinline-numtoengshortdate- translate a number into a short date like `1789/7/14';
+ \item \verbinline-numtoenglongdate- translate a number into a long date like `July 14, 1789';
+ \item \verbinline-numtoengmonth- given a number representing a date, it finds the name of the month;
+ \item \verbinline-numtoengday- same as above but it finds the name of the day.
+\end{itemize}
+Here is an example in which we consider 1000 days before and 1000 days after 2009/6/1. For each of these 2 dates, we calculate the short date, long date, month and day of the week.\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{cc}} \hline
+\multicolumn{2}{|c|}{@2009/6/1} \\\hline\hline
+1000 & numtoengshortdate(engshortdatetonum(a1)+[-1,0])\\
+1000 & numtoenglongdate(engshortdatetonum(a1)+[-1,0]) \\
+1000 & numtoengmonth(engshortdatetonum(a1)+[-1,0]) \\
+1000 & numtoengday(engshortdatetonum(a1)+[-1,0]) \\\hline
+-1000 & numtoengshortdate(engshortdatetonum(a1)+[-1,0])\\
+-1000 & numtoenglongdate(engshortdatetonum(a1)+[-1,0]) \\
+-1000 & numtoengmonth(engshortdatetonum(a1)+[-1,0]) \\
+-1000 & numtoengday(engshortdatetonum(a1)+[-1,0])
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{cc}} \hline
+\multicolumn{2}{|c|}{@2009/6/1} \\\hline\hline
+1000 & numtoengshortdate(engshortdatetonum(a1)+[-1,0])\\
+1000 & numtoenglongdate(engshortdatetonum(a1)+[-1,0]) \\
+1000 & numtoengmonth(engshortdatetonum(a1)+[-1,0]) \\
+1000 & numtoengday(engshortdatetonum(a1)+[-1,0]) \\\hline
+-1000 & numtoengshortdate(engshortdatetonum(a1)+[-1,0])\\
+-1000 & numtoenglongdate(engshortdatetonum(a1)+[-1,0]) \\
+-1000 & numtoengmonth(engshortdatetonum(a1)+[-1,0]) \\
+-1000 & numtoengday(engshortdatetonum(a1)+[-1,0])
+\end{spreadtab}
+\end{center}
+
+\subsection{Coordinate macro functions}\label{tag}
+Rather than referring to a cell by its coordinates which are difficult to remember and change if you insert a row or column, it is sometimes more convenient to give a name to a cell and refer to it later by name.
+
+The macro function `\verbinline-tag(<name>)-' gives a name to the cell in which it is located. This is not really a macro function like the others, since it returns nothing when put in a formula and disappears without causing any effect on the mathematical result. We can write `\verbinline-tag(<nom>)-' \emph{anywhere} in the numeric field of a cell. The \verb-<name>- can be any string of alphanumeric characters, but it is not advisable to put a letter and a number that could be understood as a reference to a cell, and would therefore be modified at a copy operation with \verbinline-\STcopy-. This macro function has an additional action, it saves via a \verbinline-\def- the numeric value of the cell in which it is located in order to be able to use later \emph{outside} the table via the purely expandable command \verbinline-\STtag{<name>}-.
+
+Later in the table, instead of writing the coordinates of the cell, we can write `\verbinline-cell(<name>)-', which is a macro function that returns the coordinates of the cell named \verb-<name>-. For example, if `\verbinline-tag(<name>)-' is written in the cell `\verb-B3-' and in a further cell, we write `\verbinline-cell(<name>)-', this macro function returns \verb-B3-.
+
+Here is an example where we add cells and the name `\verb-foo-' is given to the first number and the name `\verb-bar-' to the last. One can see that \verbinline-tag(foo)- is between `1' and `9' but at the end, since this macro function diappears, the numeric field of the cell will be `19':
+
+\begin{minipage}{0.6\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{r@{}r}}
+ & 15tag(foo) \\
+@+ & 37 \\
+@+ & 13 \\
+@+ & 48 \\
+@+ & 1tag(bar)9 \\\cline{2-2}
+ & sum(cell(foo):cell(bar))tag(baz)
+\end{spreadtab}
+
+foo=\STtag{foo}, bar=\STtag{bar}, baz=\STtag{baz}
+\end{lstlisting}
+\end{minipage}\kern6pt%
+\begin{minipage}{0.3\linewidth}
+\begin{spreadtab}{{tabular}{r@{}r}}
+ & 15tag(foo) \\
+@+ & 37 \\
+@+ & 13 \\
+@+ & 48 \\
+@+ & 1tag(bar)9 \\\cline{2-2}
+ & sum(cell(foo):cell(bar))tag(baz)
+\end{spreadtab}
+
+foo=\STtag{foo}, bar=\STtag{bar}, baz=\STtag{baz}
+\end{minipage}
+
+To transmit values between tables computed by \ST\footnote{As requested on \href{https://tex.stackexchange.com/questions/210881}{\texttt{\textbf{tex.stackexchange}}}}, it is possible to tag the cell in the first array using the macro function \verbinline|tag (<name>)|, then in the 2nd array, to call up the previously tagged value with \verbinline|value(<name>)|.
+
+\begin{minipage}{.6\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{cc}}
+ 100 & a1+1tag{abcd}
+\end{spreadtab}
+
+\begin{spreadtab}{{tabular}{c}}
+ value{abcd}
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}\kern6pt
+\begin{minipage}{.3\linewidth}
+\begin{spreadtab}{{tabular}{cc}}
+ 100 & a1+1tag(abcd)
+\end{spreadtab}
+
+\begin{spreadtab}{{tabular}{c}}
+ value(abcd)
+\end{spreadtab}
+\end{minipage}
+
+When the environment \ST is nested in another environment, the assignments made by the macro funtion \verbinline-tag- are \emph{local} in this environment and could not be accessed outside of this environment via \verbinline-\STtag-. In the example below, the table made with \ST is in a \verbinline-center- environment and we must use \verbinline-\STmakegtag{<name>}- to make global the previous saving of the numerical value contained in the cell marked by `tag(<name>)':
+
+\begin{minipage}{.6\linewidth}
+\begin{lstlisting}
+\begin{center}
+ \begin{spreadtab}{{tabular}{cccc}}\hline
+ 6&9&17&21\\\hline
+ \multicolumn{4}{c}{average = :={sum(a1:d1)/4tag(avg)}}
+ \end{spreadtab}
+ \STmakegtag{avg}
+\end{center}
+The average is \STtag{avg}.
+\end{lstlisting}
+\end{minipage}\kern6pt
+\begin{minipage}{.3\linewidth}
+\begin{center}
+ \begin{spreadtab}{{tabular}{cccc}}\hline
+ 6&9&17&21\\\hline
+ \multicolumn{4}{c}{average = :={sum(a1:d1)/4tag(avg)}}
+ \end{spreadtab}
+ \STmakegtag{avg}
+\end{center}
+The average is \STtag{avg}.
+\end{minipage}
+
+The argument of \verbinline-\STmakegtag- can be made of several names, separated with commas.
+
+Although at first sight less useful, \ST also provides the macro functions `\verbinline-row(<name>)-' and `\verbinline-col(<name>)-' that return the number of the row or column of the cell \verbinline-tag(<name>)-. Here is an example of how to calculate the average of a number of values; the first and last values are tagged `first' and `last' and therefore, the number of values is row(last)-row(first)+1:
+
+\begin{minipage}{0.6\linewidth}
+\begin{lstlisting}
+average = \begin{spreadtab}{{tabular}[b]{r}}
+7tag(first)\\9\\15\\6\\20\\13\\11\\55tag(last)\\
+\hline
+sum(cell(first):cell(last))/(row(last)-row(first)+1)
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}\hfill
+\begin{minipage}{0.35\linewidth}
+average = \begin{spreadtab}{{tabular}[b]{r}}
+7tag(first)\\9\\15\\6\\20\\13\\11\\55tag(last)\\
+\hline
+sum(cell(first):cell(last))/(row(last)-row(first)+1)
+\end{spreadtab}
+\end{minipage}
+
+\section{Particular care}
+\subsection{Defining new commands with \ttfamily\textbackslash hline}
+It may be useful to define a new command to produce, for example, a double horizontal line:\par\nobreak
+\begin{center}
+\verbinline-\newcommand\dline{\hline\hline}-
+\end{center}
+and then try to use it in a table as in this simple example that computes the Fibonnacci sequence in the second line:
+\begin{center}
+\newcommand\dline{\hline\hline}
+\begin{spreadtab}{{tabular}{*7c}}
+0 & 1 & 2 & 3 & 4 & 5 & 6 \\\dline
+:={1} & 1 & a2+b2 & b2+c2 & c2+d2 & d2+e2 & e2+f2
+\end{spreadtab}
+\end{center}
+But, if you write the following code, there is a problem when compiling:\par\nobreak
+\begin{lstlisting}
+\newcommand\dline{\hline\hline}
+\begin{spreadtab}{{tabular}{*7c}}
+0 & 1 & 2 & 3 & 4 & 5 & 6 \\\dline
+1 & 1 & a2+b2 & b2+c2 & c2+d2 & d2+e2 & e2+f2
+\end{spreadtab}
+\end{lstlisting}
+In the log file, you can read that \verb-\FPeval- fails and complains:\par
+\hfill\falseverb{! Improper alphabetic constant.}\hfill\null
+
+The reason is simple, \verb-\dline- in line 4 is not recognized by \ST as a horizontal rule and therefore, \emph{it is placed in the cell in the next line}. For \ST, the cell \falseverb{b1} contains:\par
+\hfill\falseverb{\dline 1}\hfill\null
+
+Since there is no \verb-@- or \verb-:={<formula>}-, \ST considers that the whole cell is a numeric field and \verb-\FPeval- tries valiantly to calculate this content and obviously fails.
+
+To compile without error, the cell \falseverb{a2} \emph{must} contain a numeric field marker:\par\nobreak
+\begin{lstlisting}
+\newcommand\dline{\hline\hline}
+\begin{spreadtab}{{tabular}{*7c}}
+0 & 1 & 2 & 3 & 4 & 5 & 6 \\\dline
+:={1} & 1 & a2+b2 & b2+c2 & c2+d2 & d2+e2 & e2+f2
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\newcommand\dline{\hline\hline}
+\begin{spreadtab}{{tabular}{*7c}}
+0 & 1 & 2 & 3 & 4 & 5 & 6 \\\dline
+:={1} & 1 & a2+b2 & b2+c2 & c2+d2 & d2+e2 & e2+f2
+\end{spreadtab}
+\end{center}
+
+\subsection{The use of {\ttfamily\textbackslash multicolumn} and \ttfamily\textbackslash SThidecol}
+Firstly, in normal use, joint use of \verbinline |\multicolumn| and \verbinline-\SThiderow- should not happen, and most users should not encounter this situation and should not read this section.
+
+For the brave here is the problem: first, a hidden column \emph{must not} contain a cell with the command \verbinline-\multicolumn-! But what happens if a hidden column hides cells merged with \verbinline-\multicolumn-?
+
+In general, there is no compilation error or error messages, but there are some subtleties about the references that are a bit turned upside down in the line after the \verbinline-\multicolumn- command\ldots
+
+Let's take an example, and let's say that, in the following table, we want to merge the cell \falseverb{b2} to \falseverb{h2} and we also want to hide the colomns \falseverb{c}, \falseverb{d} and \falseverb{f}, here in gray:\par\nobreak
+\begin{center}
+\ttfamily
+\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
+\hline
+ a1 & b1 & \cellcolor[gray]{0.6}c1 & \cellcolor[gray]{0.6}d1 & e1 & \cellcolor[gray]{0.6}f1 & g1 & h1 & i1 & j1\\\hline
+ a2 & \multicolumn1c{b2} & \multicolumn1{>{\cellcolor[gray]{0.6}}c}{} & \multicolumn1{>{\cellcolor[gray]{0.6}}c}{} & \multicolumn1c{} & \multicolumn1{>{\cellcolor[gray]{0.6}}c}{} & \multicolumn1{c}{} & \multicolumn1{c|}{} & i2 & j2\\\hline
+\end{tabular}
+\end{center}
+There are 4 visible merged cells, so we write \verbinline-\multicolumn{4}- because hidden columns are never taken into account when counting the number of \verbinline-\multicolumn-.
+
+Then we count 4 letters from \falseverb{b} (this letter included): we obtain the letter \falseverb{e}. In the range \falseverb{b-e}, let's count: 2 gray hidden columns are included (\falseverb c and \falseverb d) and 1 hidden column is not included (\falseverb f). These numbers are important to understand the following, also let's call them $x$ and $y$ in the general case.
+
+The rule is:
+\begin{itemize}
+ \item it is necessary to add $y$ signs \verb-&- after \verbinline-\multicolumn- (in the example above, it would be 1);
+ \item references to columns of cells after the \verbinline-\multicolumn- will be shifted $x$ to the beginning of the alphabet. For the example given, if we want to refer to the cell \falseverb{i2}, we should write \falseverb{g2} instead of \falseverb{i2}.
+\end{itemize}
+Here is an example with a similar structure to the previous ($x=2$ and $y=1$) with simple formulas: add 1 to the number above.\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*{7}{c|}}}
+\hline
+1 & 2 & \SThidecol3 & \SThidecol4 & 5& \SThidecol6 & 7& 8& 9 & 10 \\\hline
+a1+1& \multicolumn4{l|}{:={b1+1}} & & i1+1 & j1+1\\\hline
+a2+1& b2+1 & & & & & & & g2+1 & h2+1\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*{7}{c|}}}
+\hline
+1 & 2 & \SThidecol3 & \SThidecol4 & 5& \SThidecol6 & 7& 8& 9 & 10 \\\hline
+a1+1& \multicolumn4{l|}{:={b1+1}} & & i1+1 & j1+1\\\hline
+a2+1& b2+1 & & & & & & & g2+1 & h2+1\\\hline
+\end{spreadtab}
+\end{center}
+And another example with $x=1$ and $y=0$ where a single column is hidden \falseverb d:\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*{9}{c|}}}
+\hline
+1 & 2 & 3 & \SThidecol4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline
+a1+1& \multicolumn6{l|}{:={b1+1}} & i1+1 & j1+1\\\hline
+a2+1& b2+1 & & & & & & & h2+1 & i2+1\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*{9}{c|}}}
+\hline
+1 & 2 & 3 & \SThidecol4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline
+a1+1& \multicolumn6{l|}{:={b1+1}} & i1+1 & j1+1\\\hline
+a2+1& b2+1 & & & & & & & h2+1 & i2+1\\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Messages delivered by \ST}
+The package delivers error messages and aborts compilation in these cases:
+\begin{itemize}
+ \item a circular reference is found in a cell. In this case, the dependent cells are displayed;
+ \item a cell refers to an empty cell or a text cell when a non-empty numeric field is expected;
+ \item a cell refers to an undefined cell (outside the table);
+ \item a cell refers to a cell merged by a \verbinline-\multicolumn- command;
+ \item a relative reference has bad syntax.
+\end{itemize}
+The package can deliver informative messages (in the log file), which it does by default. If the user wants or not the delivery of informative messages, the syntax is \verbinline-\STmessage{true}- or \verbinline-\STmessage{false}-.
+
+To understand the meaning of these messages, let's take a simple table:\par\nobreak
+\begin{minipage}{0.65\linewidth}
+\begin{lstlisting}
+\STmessage{true}% already set by default
+\begin{spreadtab}{{tabular}{|cccc|c|}}\hline
+b1+1 & c1+1 & d1+1 & 10 & a1+b1+c1+d1\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.35\linewidth}
+\centering
+\begin{spreadtab}{{tabular}{|cccc|c|}}\hline
+b1+1 & c1+1 & d1+1 & 10 & a1+b1+c1+d1\\\hline
+\end{spreadtab}
+\end{minipage}
+
+Here are the messages deliverd by \ST:\par\nobreak
+\begin{lstlisting}
+[spreadtab] New spreadtab {tabular}{|cccc|c|}
+* reading tab: ok
+* computing formulas:
+ cell A1-B1-C1
+ cell B1
+ cell C1
+ cell D1
+ cell E1
+* building tab: ok
+[spreadtab] End of spreadtab
+\end{lstlisting}\medskip
+Preceded by a star, we recognize the 3 steps necessary for \ST to complete its task: reading the table, calculation of the formulas and building the final table.
+
+For the second step, cells are evaluated from top to bottom, left to right: at line 4 in the code above, \ST says that it begins by trying to calculate the first cell \falseverb{A1}. After a dash, we see that for this, it must first compute the cell \falseverb{B1}, which itself requires that the cell \falseverb{C1} is calculated: the latter can be calculated since it depends only on \falseverb{D1} which is a cell containing the number 10.
+
+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 dependent 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 information. This display is done just after \ST has read all the cells, and no calculating of formulas 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 show the 3 possible debugging tables for the table above. To do this, just change 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 (by substitution) the result of the numeric field will be inserted. 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!
+
+\subsection{Pascal's triangle again!}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{*7r}}
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]\\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & & & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & & & \\
+[0,1] & [-1,1] & & & & & \\
+\color{red}:={1}& & & & & &
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{*7r}}
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]\\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & & & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & & & \\
+[0,1] & [-1,1] & & & & & \\
+\color{red}:={1}& & & & & &
+\end{spreadtab}
+\end{center}
+
+\subsection{The convergence of a series}
+For people familiar with maths, here is the series of the exponential. Indeed,
+\[\forall x\in \mathbf{R}\qquad e^x=\sum_{k=0}^\infty\frac{x^k}{k!}\]
+and this table shows the speed of convergence for $x=0.5$
+\begin{lstlisting}
+\STautoround{15}
+\renewcommand\STprintnum[1]{\numprint{#1}}
+\begin{spreadtab}{{tabular}{cc}}
+\multicolumn{2}{c}{Convergence at $x=\color{red}:={0.5}$}\\[1.5ex]
+@$n$ & e^a1\SThidecol & @ $\displaystyle e^{\numprint{<<a1>>}}-\sum_{k=0}^n\frac{\numprint{<<a1>>}^k}{k!}$\\[3ex]\hline
+\color{red}:={0}& a1^[-1,0]/fact([-1,0]) & \STcopy{v}{b!2-b3}\\
+\STcopy{v}{a3+1}& \STcopy{v}{a!1^a4/fact(a4)+b3}& \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\STautoround{15}
+\renewcommand\STprintnum[1]{\numprint{#1}}
+\begin{spreadtab}{{tabular}{cc}}
+\multicolumn{2}{c}{Convergence at $x=\color{red}:={0.5}$}\\[1.5ex]
+@$n$ & exp(a1)\SThidecol & @ $\displaystyle e^{\numprint{<<a1>>}}-\sum_{k=0}^n\frac{\numprint{<<a1>>}^k}{k!}$\\[3ex]\hline
+\color{red}:={0}& a1^[-1,0]/fact([-1,0]) & \STcopy{v}{b!2-b3}\\
+\STcopy{v}{a3+1}& \STcopy{v}{a!1^a4/fact(a4)+b3}& \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Convergence to the golden ratio}
+In mathematical terms, the sequence $F_n$ of Fibonacci numbers is defined by the recurrence relation:\[F_0=1\qquad F_1=1\qquad F_{n+2}=F_{n+1}+F_n\]
+
+The golden ratio is the limit of the ratios of successive terms of the Fibonacci sequence. We show here that the quotients $F_{n+1}/F_n$ approximate the golden ratio $\varphi=\frac{1+\sqrt{5}}{2}$ alternately lower and higher than $\varphi$.\par\nobreak
+\begin{lstlisting}
+\STautoround{9}
+$\begin{spreadtab}{{array}{ccN39N{3}{9}}}
+@n & @F_n & @\hfill{\dfrac{F_n}{F_{n-1}}}\hfill\null& @\hfill{\varphi-\dfrac{F_n}{F_{n-1}}}\hfill\null\\[2ex]\hline
+\color{red}:=1 & \color{red}:=1 & & \\
+\STcopy{v}{a2+1} & \color{red}:=1 & \STcopy{v}{b3/b2} & (1+5^0.5)/2-[-1,0] \\
+ & \STcopy{v}{b2+b3} & & \STcopy{v}{d!3+1-c4} \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\\hline
+\end{spreadtab}$
+\end{lstlisting}
+\begin{center}
+\STautoround{9}
+$\begin{spreadtab}{{array}{ccN39N{3}{9}}}
+@n & @F_n & @\hfill{\dfrac{F_n}{F_{n-1}}}\hfill\null& @\hfill{\varphi-\dfrac{F_n}{F_{n-1}}}\hfill\null\\[2ex]\hline
+\color{red}:=1 & \color{red}:=1 & & \\
+\STcopy{v}{a2+1} & \color{red}:=1 & \STcopy{v}{b3/b2} & (1+5^0.5)/2-[-1,0] \\
+ & \STcopy{v}{b2+b3} & & \STcopy{v}{d!3+1-c4} \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\\hline
+\end{spreadtab}$
+\end{center}
+
+\subsection{A billing table}
+Here is a billing table where the decimal points are aligned in columns with the column specifier `N' of the package \falseverb{numprint}.
+
+This table is generated by the environment \verb=tabularx= stretched to fit 80\% of the width of the line. The command \verbinline=\multicolumn= has been widely used for formatting:\par\nobreak
+\begin{lstlisting}
+\nprounddigits2
+\let\PC\%
+\newcommand\Mystrut{\rule[-1.2ex]{0pt}{4ex}}
+\newcommand\RED{\color{red}}
+\begin{spreadtab}{{tabularx}{0.8\linewidth}{|>\Mystrut X>\RED N42>\RED c N42>\RED c<\PC N42|}}
+\hline
+@Item &@\multicolumn1c{Price/U}& @\multicolumn1c{Qty} & @\multicolumn1c{Price} & @\multicolumn1c{Reduction} & @\textbf{Net}\\\hline
+@Item 1 & 5.99 & 20 & [-2,0]*[-1,0] & $-:={20}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 2 & 12 & 7 & [-2,0]*[-1,0] & $-:={10}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 3 & 4.50 & 40 & [-2,0]*[-1,0] & $-:={35}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 4 & 650 & 2 & [-2,0]*[-1,0] & $-:={15}$ & [-2,0]*(1-[-1,0]/100)\\\hline
+@\multicolumn6c{}\\[-1.5ex]\cline{4-6}% empty line and raise it a little
+@\multicolumn1c{\Mystrut}&@\multicolumn2{r|}{\textbf{Total}}& sum(d2:[0,-2]) & \multicolumn1c{$:={round(([1,0]/[-1,0]-1)*100,0)}\PC$} & {\fontseries{b}\selectfont}:={sum(f2:[0,-2])}\\
+\cline{4-6}
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\nprounddigits2
+\let\PC\%
+\newcommand\Mystrut{\rule[-1.2ex]{0pt}{4ex}}
+\newcommand\RED{\color{red}}
+\begin{spreadtab}{{tabularx}{0.8\linewidth}{|>\Mystrut X>\RED N42>\RED c N42>\RED c<\PC N42|}}
+\hline
+@Item &@\multicolumn1c{Price/U}& @\multicolumn1c{Qty} & @\multicolumn1c{Price} & @\multicolumn1c{Reduction} & @\textbf{Net}\\\hline
+@Item 1 & 5.99 & 20 & [-2,0]*[-1,0] & $-:={20}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 2 & 12 & 7 & [-2,0]*[-1,0] & $-:={10}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 3 & 4.50 & 40 & [-2,0]*[-1,0] & $-:={35}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 4 & 650 & 2 & [-2,0]*[-1,0] & $-:={15}$ & [-2,0]*(1-[-1,0]/100)\\\hline
+@\multicolumn6c{}\\\cline{4-6}% empty line
+@\multicolumn1c{\Mystrut}&@\multicolumn2{r|}{\textbf{Total}}& sum(d2:[0,-2]) & \multicolumn1c{$:={round(([1,0]/[-1,0]-1)*100,0)}\PC$} & {\fontseries{b}\selectfont}:={sum(f2:[0,-2])}\\
+\cline{4-6}
+\end{spreadtab}
+\end{center}
+
+\subsection{A magic square}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*3{>{\hfill\rule[-0.4cm]{0pt}{1cm}$}m{0.7cm}<{$\hfill\null}|}}}
+\hline
+\color{red}:=2 & 5*b2-4*a1 & 3*a1-2*b2 \\\hline
+2*a1-b2 & \color{red}:={-1} & 3*b2-2*a1 \\\hline
+4*b2-3*a1 & 4*a1-3*b2 & 2*b2-a1 \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*3{>{\hfill\rule[-0.4cm]{0pt}{1cm}$}m{0.7cm}<{$\hfill\null}|}}}
+\hline
+\color{red}:=2 & 5*b2-4*a1 & 3*a1-2*b2 \\\hline
+2*a1-b2 & \color{red}:={-1} & 3*b2-2*a1 \\\hline
+4*b2-3*a1 & 4*a1-3*b2 & 2*b2-a1 \\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{A pyramid of additions}
+Each number is the sum of two numbers located below it.
+\begin{lstlisting}
+\newlength\cellsize
+\setlength\cellsize{1.5cm}
+\newcolumntype{K}{@{}>{\rule{0pt}{2.5ex}\centering\arraybackslash$}p{\cellsize}<$@{}}
+\begin{spreadtab}{{tabular}{*{8}{@{}p{.5\cellsize}@{}}}}
+\cline{4-5}
+&&&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&&&\\\cline{3-6}
+&&\multicolumn{2}{|K}{:={[-1,1]+[1,1]}}&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&&\\\cline{2-7}
+&\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{lstlisting}
+\begin{center}
+\newlength\cellsize
+\setlength\cellsize{1.5cm}
+\newcolumntype{K}{@{}>{\rule{0pt}{2.5ex}\centering\arraybackslash$}p{\cellsize}<$@{}}
+\begin{spreadtab}{{tabular}{*{8}{@{}p{.5\cellsize}@{}}}}
+\cline{4-5}
+&&&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&&&\\\cline{3-6}
+&&\multicolumn{2}{|K}{:={[-1,1]+[1,1]}}&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&&\\\cline{2-7}
+&\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
+\parskip0pt
+\begin{center}
+$\star$\par
+$\star\quad\star$
+\end{center}\bigskip
+That's all. I hope you will find this package useful!\par\nobreak\medskip
+
+I thank you in advance for sending by \href{mailto:unbonpetit@netc.fr}{\texttt{\textbf{email}}} any bug you find, any macro-function or improvment you would like to be implemented, assuming that it must be \emph{realistic}. This package has to be modest and \ST is not excel or calc: it is impossible to implement some advanced features of these spreadsheets.\par\nobreak\bigskip
+Christian \textsc{Tellechea}
+\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/spreadtab/spreadtab-fr.pdf b/macros/latex/contrib/spreadtab/spreadtab-fr.pdf
new file mode 100644
index 0000000000..52df68ec60
--- /dev/null
+++ b/macros/latex/contrib/spreadtab/spreadtab-fr.pdf
Binary files differ
diff --git a/macros/latex/contrib/spreadtab/spreadtab-fr.tex b/macros/latex/contrib/spreadtab/spreadtab-fr.tex
new file mode 100644
index 0000000000..1eab8cb386
--- /dev/null
+++ b/macros/latex/contrib/spreadtab/spreadtab-fr.tex
@@ -0,0 +1,1668 @@
+% Documentation de l'extension "spreadtab"
+\documentclass[french,a4paper,10pt]{article}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage[a4paper,margin=2.6cm]{geometry}
+\usepackage[table]{xcolor}
+\usepackage{amsmath,amssymb,textcomp,array,arydshln,tabularx,numprint,xspace,fancyhdr,libertine,babel,enumitem,listings,bxtexlogo}
+\bxtexlogoimport{*}\frenchsetup{og=«,fg=»}
+\usepackage[xfp,fp]{spreadtab}\STusexfp
+\usepackage[italic]{mathastext}
+\usepackage[scaled=0.8]{luximono}
+\fancyhead[L]{}
+\fancyhead[C]{\small\bfseries\ST}
+\fancyhead[R]{\scriptsize\slshape \leftmark}
+\fancyfoot[l]{}
+\fancyfoot[c]{}
+\fancyfoot[r]{\thepage}
+\usepackage[bottom]{footmisc}
+\usepackage[protrusion=true,final,verbose=true,babel=true]{microtype}
+\frenchbsetup{StandardLists=true}
+\makeatletter
+\definecolor{ST@bckgcolor}{rgb}{0.87,0.9,1}
+\definecolor{ST@codebckgcolor}{rgb}{0.9,0.9,0.9}
+\definecolor{ST@keywordstc}{rgb}{0.7,0,0}
+\definecolor{ST@keywordslatex}{rgb}{0,0,1}
+\definecolor{ST@arguments}{rgb}{0,0,0}
+\definecolor{ST@comments}{rgb}{0.5,0.5,0.5}
+\lstset{%
+ language=[AlLaTeX]TeX,float=hbp,basicstyle=\footnotesize\ttfamily,identifierstyle=\color{ST@arguments},%
+ keywordstyle=\color{ST@keywordslatex},commentstyle=\itshape\color{ST@comments},%
+ columns=fixed,tabsize=4,frame=single,extendedchars=false,%
+ showspaces=false,showstringspaces=false,numbers=left,numberstyle=\tiny\ttfamily,%
+ breaklines=true,breakindent=3em,backgroundcolor=\color{ST@bckgcolor},breakautoindent=true,%
+ captionpos=t,xleftmargin=1em,xrightmargin=1em,lineskip=0pt,%
+ numbersep=1em,classoffset=1,%
+ morekeywords={% les macros et commandes de spreadtab
+ spreadtab,endspreadtab,SThiderow,SThidecol,STsavecell,STautoround,STmessage,STsetdecimalsep,STtransposecar,STdebug,STdisplaytab,STsetdisplaymarks,%
+ STnumericfieldmarker,STprintnum,STtextcell,STcopy,STtag,STmakegtag,STeol,fact,id,ifeq,ifgt,iflt,numtofrshortdate,STusefp,STusexfp,%
+ numtoengshortdate,numtofrlongdate,numtoenglongdate,numtofrmonth,%
+ numtoengmonth,numtofrday,numtoengday,sum,rand,randint,sumprod,%
+ frshortdatetonum,engshortdatetonum,englongdatetonum,frlongdatetonum,gcd,lcm,tag,cell,row,col,value},%
+ 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}
+
+\def\longfrdate@i#1/#2/#3\@nil{\number#3\relax\ifnum#3=1 \ier\fi\space\ifcase #2 \or janvier\or février\or mars\or avril\or mai\or juin\or juillet\or aout\or septembre\or octobre\or novembre\or décembre\fi\space#1}
+\def\longfrdate{\expandafter\longfrdate@i\STdate\@nil}
+\makeatother
+
+% 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{\STname}\xspace}
+\newcommand\xfp{\texttt{\bfseries xfp}\xspace}
+\newcommand\fp{\texttt{\bfseries fp}\xspace}
+\newcommand\falseverb[1]{\texttt{\detokenize{#1}}}
+
+\usepackage[bookmarks=true,bookmarksopen=true,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,pdfauthor={Christian TELLECHEA},pdftitle={spreadtab},pdfsubject={Spreadtab permet d'utiliser des fonctionnalités de tableur dans un tableau avec LaTeX},pdfkeywords={spreadtab},pdfcreator={LaTeX}]{hyperref}
+
+\begin{document}
+\parindent0pt\pagestyle{fancy}\setitemize{leftmargin=3em,topsep=0pt,parsep=0pt,itemsep=0pt,label=--}\STsetdecimalsep{,}
+\begin{titlepage}
+ \null\par\vfill
+ \begin{center}
+ \begin{minipage}{0.75\linewidth}
+ \begin{center}
+ \Huge\bfseries\ST\par\vspace{5pt}
+ \small v\STver\par\vspace{35pt}
+ \normalsize Manuel de l'utilisateur
+ \end{center}
+ \end{minipage}
+ \end{center}
+ \vspace{1cm}
+ \begin{center}
+ Christian {\sc Tellechea}\par\small
+ \href{mailto:unbonpetit@netc.fr}{\texttt{\textbf{unbonpetit@netc.fr}}}\par\vspace{5pt}
+ \longfrdate
+ \end{center}
+ \vfill
+ \begin{center}
+ \begin{minipage}{0.8\linewidth}
+ \noindent\hrulefill\par
+ \hfill\textbf{\textit{Résumé}}\hfill{}\medskip\par\footnotesize
+ Cette extension permet d'utiliser des fonctionnalités de tableur dans n'importe quel environnement «tableau» avec \LaTeX{}.\par\smallskip
+ La principale fonctionnalité étant de pouvoir écrire des formules dans les cellules d'un tableau qui font références à d'autres cellules, de calculer les formules contenues dans les cellules et d'afficher les résultats numériques de ces formules dans le tableau.\par
+ \hrulefill
+ \end{minipage}
+ \end{center}
+ \vfill{}
+\end{titlepage}
+
+\tableofcontents\newpage
+\parskip\medskipamount
+\section{Introduction}
+
+\subsection{Présentation}
+Cette extension permet de construire des tableaux similaires à des feuilles de calculs. Les cellules du tableau ont des coordonnées (colonne et ligne) qui peuvent être utilisées dans des formules pour calculer des valeurs dans d'autres cellules. On charge le package en écrivant dans le préambule la syntaxe classique
+\begin{center}
+\verb-\usepackage[<options>]{spreadtab}-
+\end{center}
+où les options «\verb|fp|» ou «\verb|xfp|» spécifient le moteur de calcul choisi. Si aucune option n'est spécifiée, le moteur sera \fp. Si les deux options sont spécifiées, le moteur actif au début du document sera \fp, mais dans ce cas, on peut changer de moteur à tout moment en exécutant \verbinline|\STusefp| ou \verbinline|\STusexfp|. Cette documentation est compilée avec le moteur \xfp, sauf exemple où le contraire est spécifié. En règle générale, les deux moteurs de calcul doivent donner des résultats identiques, mais :
+\begin{itemize}
+ \item \fp est un moteur de calcul à virgule fixe (18 chiffres avant et 18 après) et donne donc davantage de chiffres après la virgule que \xfp qui effectue les calculs en virgule flottante avec 16 chiffres significatifs; en revanche, \xfp accepte nativement des tests, gère l'infini et \verb|NaN|, comprend la multiplication implicite par juxtaposition, etc.
+ \item des différences existent entre les deux moteurs concernant les fonctions disponibles tant du point de vue de la syntaxe que de leur existence même. Ainsi, la fonction \verb|max(...)| n'admet que \emph{deux} nombres en argument avec \fp tandis que \xfp accepte autant d'arguments que l'on veut. De la même façon, l'exponentielle s'obtient avec \verb|e^x| ou \verb|pow(x,e)| avec \fp alors que la syntaxe avec \xfp est \verb|exp(x)|. Par ailleurs, les fonctions reconnues par les deux moteurs ne sont pas les mêmes, comme on peut le constater en lisant leurs documentations : \verb|ceil| par exemple, n'existe que pour \xfp. D'une manière générale, on peut considérer \xfp comme étant mieux doté en fonctionnalités que \fp;
+ \item les fonctions \verbinline|rand| et \verbinline|randint| ne sont pas disponibles avec le moteur \xfp lorsqu'on compile avec une version de \XeLaTeX{} trop ancienne.
+\end{itemize}
+
+Ce package nécessite le moteur \eTeX, le format \LaTeXe{} ainsi que le package \href{https://www.ctan.org/pkg/fp}{\fp} ou \href{https://ctan.org/pkg/xfp}{\xfp} à qui sont confiés les calculs. Le package \href{https://www.ctan.org/pkg/xstring}{\texttt{\textbf{xstring}}} est également requis.
+
+J'ai souhaité dès le départ de rendre ce package compatible avec \emph{tous} les environnements de tableaux, sous réserve que les séparateurs entre colonnes soient «\verb=&=» et les retours à la ligne soient «\verb=\\=». Cette contrainte forte sur la compatibilité m'a conduit à programmer \ST pour qu'il agisse d'une façon \emph{totalement indépendante} de l'environnement tableau. Ainsi, la lecture du tableau, le traitement et le calcul des formules se fait \emph{avant} que l'environnement tableau ne prenne la main et ne «voit» le corps du tableau.
+
+Par conséquent, \ST procède en 3 étapes :
+\begin{itemize}
+ \item en premier lieu, \ST lit le corps du tableau et le divise en lignes puis en cellules en reconnaissant dans chacune la présence d'une éventuelle formule;
+ \item ensuite, il procède au calcul des formules contenues dans les cellules, en ayant pris soin pour chacune de calculer auparavant les cellules dépendantes. L'ordre dans lequel les cellules doivent être calculées est déterminé par \ST. Les calculs sont faits par le package \fp ou \xfp, sous réserve que les formules à évaluer dans les cellules soient compatibles avec les syntaxes des macros \verb|\FPeval| du package \fp ou \verb|\fpeval| du package \xfp\footnote{Si l'on souhaite utiliser le «ET» logique de \xfp noté «\texttt{\string&\string&}», il est \emph{obligatoire} de mettre cet opérateur entre accolades dans un tableau afin que les tokens \texttt{\string&} ne soient pas compris comme des séparateurs de colonnes. Dans une cellule d'un tableau, pour tester si le contenu de la cellule \texttt{a1} appartient à un intervalle, on écrira donc par exemple «\texttt{a1>1 \string{\string&\string&\string} a1<10}».};
+ \item enfin, il faut reconstruire le tableau en ayant remplacé chaque formule par la valeur numérique préalablement calculée et passer la main à l'environnement tableau spécifié par l'utilisateur.
+\end{itemize}
+Les deux syntaxes possibles (et équivalentes) sont les suivantes, où \verb-<nom>- représente le nom de n'importe quel environnement de type tableau disponible avec \LaTeX{} ou avec une extension :\par\nobreak
+\begin{minipage}{0.48\linewidth}
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+\begin{spreadtab}{{<nom>}{<parametres>}}
+ tableau avec formules et nombres
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}\hfill ou\hfill
+\begin{minipage}{0.48\linewidth}
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+\spreadtab{{<nom>}{<parametres>}}
+ tableau avec formules et nombres
+\endspreadtab
+\end{lstlisting}
+\end{minipage}
+
+et après le travail de \ST, on obtient un affichage comme si l'on avait écrit :\par\nobreak
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+\begin{<nom>}{<parametres>}
+ tableau avec nombres
+\end{<nom>}
+\end{lstlisting}
+
+Même si disposer de fonctionnalités ressemblant à celles d'un tableur avec \LaTeX{} est appréciable, il ne faut pas perdre de vue que les 3 étapes décrites ci-dessus prennent du temps. L'ensemble conduit donc à des temps de compilation \emph{beaucoup plus importants} qu'avec un tableau classique.
+
+Il faut ajouter que \ST \emph{ne peut remplacer un tableur}. En effet, ses possibilités sont très limitées. De plus, surtout pour des tableaux complexes ou de grande taille, le manque d'aide visuelle devient gênant\footnote{Ceci dit, je certifie qu'avec l'habitude, cette gêne tend à s'estomper (si l'on s'en tient à des tableaux raisonnables, bien sûr).}, et la syntaxe de \ST constitue aussi un obstacle supplémentaire. L'avantage de cette extension est de pouvoir écrire \emph{dans le code \LaTeX} des tableaux comportant des calculs, alors que ces tableaux sont généralement exportés\footnote{On peut signaler les 2 principaux programmes d'exportation : \href{http://calc2latex.sourceforge.net/}{\texttt{\textbf{cacl2latex}}} pour «calc» de Open Office, et \href{http://www.ctan.org/tex-archive/support/excel2latex/}{\texttt{\textbf{excel2latex}}} pour «excel» de Microsoft Office.} d'une feuille de calcul d'un tableur vers le code \LaTeX. On évite ainsi les désagréments des programmes d'exportation : mise en forme souvent à retoucher pour obtenir exactement ce que l'on veut, non compatibilité avec tous les environnements de tableaux, obtention de tableaux ne contenant que les valeurs (les formules sont perdues à l'exportation), exportation à recommencer si l'on modifie un seul nombre ou formule dans le tableau.
+
+\subsection{Motivation}
+Quelques mois avant de commencer à m'attaquer à ce package, Derek \textsc{O'Connor} m'avait fait remarquer que rien n'était disponible dans le monde des extensions de \LaTeX{} pour imiter ---~ne serait-ce qu'un peu~--- le calcul de formules dans des tableaux, comme cela se fait couramment avec des tableurs. J'ai trouvé le défi intéressant et je me suis lancé dans l'écriture de ce package qui en fait, n'est qu'un exercice de programmation.
+
+La route a été longue avant d'arriver à cette version et je tiens à remercier tout particulièrement Christophe \textsc{Casseau} pour l'intérêt qu'il a porté dès le début à ce travail et les suggestions qu'il m'a faites, ainsi que plus récemment Derek \textsc{O'Connor} pour ses conseils et pour les échanges constructifs que nous avons eus. J'adresse également mes remerciements à Andrew \textsc{Parsloe} pour la relecture et les corrections apportées à la traduction de ce manuel en anglais.
+
+\section{Fonctionnalités courantes}
+Il faut noter tout d'abord qu'à l'intérieur d'un tableau sous environnement \ST, les caractères «\verb=:=», «\verb=;=», «\verb|!|» et «\verb|?|» perdent leur code de catégorie actif qui leur a été attribué si vous utilisez l'option \falseverb{french} du package \falseverb{babel}. Par conséquent, l'espace automatique inséré avant ces caractères sera désactivé dans un tableau.
+
+\label{STeol}Par défaut, \ST considère qu'une ligne se termine avec ``\verb-\\-'' qui est habituel dans les tableaux. Ce marqueur de fin de ligne peut être modifié via la commande \verbinline-\STeol{<macro>}-. On peut par exemple écrire \verbinline-\STeol{\tabularnewline}-. Il faut bien comprendre que les fins de lignes qui seront insérées dans le tableau final seront toujours ``\verb-\\-'', même si le marqueur de fin de ligne lorsque \ST \emph{lit} le tableau a été modifié.
+
+\subsection{Références absolues}
+Dans le tableau, les cellules sont repérées par leur références absolues de cette façon :
+\begin{itemize}
+ \item la colonne est une lettre de \falseverb a à \falseverb z, \falseverb a représentant la 1\iere{} colonne de gauche : on est donc d'emblée limité à 26 colonnes, ce qui devrait suffire pour la grande majorité des cas; la lettre est insensible à la casse, elle peut donc être indifféremment minuscule ou majuscule;
+ \item à la suite immédiate de la lettre, un nombre entier strictement positif représente le numéro de la ligne, la ligne numéro 1 étant la ligne du haut.
+\end{itemize}
+Une référence absolue s'écrit donc par exemple : «\falseverb{b4}», «\falseverb{C1}» ou «\falseverb{d13}»\footnote{Cette notation se retrouve dans les tableurs : la lettre représente la colonne et le nombre qui suit représente la ligne. Cet ordre est le contraire de la convention utilisée avec les matrices en mathématiques.}. Visuellement, on peut illustrer ce fonctionnement par ce genre de tableau ressemblant à un tableur, ici volontairement limité à 5 lignes et 5 colonnes :
+\begin{center}
+\begin{OOocalc}[6em]{5}
+&&&&\\&&&&\\&&&&\\&&&&\\&&&&\\
+\end{OOocalc}
+\end{center}
+Voici un exemple où l'on calcule la somme de chaque ligne et de chaque colonne puis, la somme totale :\par\nobreak
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{rr|r}}
+22 & 54 & a1+b1 \\
+43 & 65 & a2+b2 \\
+49 & 37 & a3+b3 \\
+\hline
+a1+a2+a3 & b1+b2+b3 & a4+b4
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.25\linewidth}
+\centering
+\begin{spreadtab}{{tabular}{rr|r}}
+22 & 54 & a1+b1 \\
+43 & 65 & a2+b2 \\
+49 & 37 & a3+b3 \\
+\hline
+a1+a2+a3 & b1+b2+b3 & a4+b4
+\end{spreadtab}
+\end{minipage}%
+
+Pour les matheux, voici un autre exemple où l'on calcule quelques lignes du triangle de Pascal :\par\nobreak
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{ccccc}}
+1 & & & & \\
+a1 & a1 & & & \\
+a2 & a2+b2 & b2 & & \\
+a3 & a3+b3 & b3+c3 & c3 & \\
+a2 & a4+b4 & b4+c4 & c4+d4 & d4
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.25\linewidth}
+\centering
+\begin{spreadtab}{{tabular}{ccccc}}
+1 & & & & \\
+a1 & a1 & & & \\
+a2 & a2+b2 & b2 & & \\
+a3 & a3+b3 & b3+c3 & c3 & \\
+a2 & a4+b4 & b4+c4 & c4+d4 & d4
+\end{spreadtab}
+\end{minipage}%
+
+\subsection{Références relatives}
+Pour faire référence à une cellule, il peut être commode de spécifier sa position par rapport à la cellule où se trouve la formule. Ainsi, les coordonnées «relatives» d'une cellule sont 2 nombres relatifs écrits selon cette syntaxe : \falseverb{[x,y]}, où \falseverb x est le décalage horizontal par rapport à la cellule contenant la formule et \falseverb y est le décalage vertical. Ainsi, \falseverb{[-2,3]} fait référence à la cellule se trouvant 2 colonnes avant (à gauche) et 3 lignes après (plus bas) la cellule où se trouve la formule.
+
+Voici à nouveau le triangle de Pascal vu ci-dessus, mais les références sont relatives et l'environnement «\verbinline-matrix-» du package \href{http://www.ctan.org/tex-archive/macros/latex/required/amslatex/math/}{\texttt{\textbf{amsmath}}} est utilisé :\par\nobreak
+\begin{minipage}{0.82\linewidth}
+\begin{lstlisting}
+$
+\begin{spreadtab}{{matrix}{}}
+1\\
+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]
+\end{spreadtab}
+$
+\end{lstlisting}
+\end{minipage}\hfill
+\begin{minipage}{0.15\linewidth}
+\centering
+$
+\begin{spreadtab}{{matrix}{}}
+1\\
+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]\\
+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]+[0,-1] & [-1,-1]
+\end{spreadtab}
+$
+\end{minipage}%
+
+On remarque que les références relatives sont plus adaptées ici puisque seulement 2 références différentes sont utilisées : \falseverb{[0,-1]} qui se réfère à la cellule de dessus et \falseverb{[-1,-1]} qui se réfère à la cellule au Nord-Ouest de la cellule où se trouve la formule.
+
+On peut utiliser dans une même formule un mélange de références absolues et relatives.
+
+\subsection{Cellules de texte}
+Si l'on veut mettre du texte dans une cellule, il faut indiquer à \ST que la cellule ne doit pas être calculée. Il suffit de placer quelque part dans la cellule le caractère «\falseverb @». Ce faisant, la cellule est ignorée par \ST et devient une cellule inerte à qui il n'est pas possible\footnote{Il y a une exception à cette règle, voir la page \protect\pageref{datetonum}.} de faire référence nulle part ailleurs dans le tableau.
+
+Voici un exemple :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|ccc|}}
+\hline
+@ valeurs de $x$ & -5 & -1 & 4 \\
+@ $f(x)=2x$ & 2*[0,-1] & 2*[0,-1] & 2*[0,-1] \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|ccc|}}
+\hline
+@ valeurs de $x$ & -5 & -1 & 4 \\
+@ $f(x)=2x$ & 2*[0,-1] & 2*[0,-1] & 2*[0,-1] \\\hline
+\end{spreadtab}
+\end{center}
+Le caractère «\falseverb @» est le développement de la séquence de contrôle \verbinline=\STtextcell=. On peut donc redéfinir cette séquence de contrôle en ce que l'on veut et par exemple, \verbinline-\renewcommand\STtextcell{`}- fera qu'une cellule contenant le caractère ``\verb=`='' sera comprise comme étant une cellule de texte.
+
+De plus, si une cellule est vide ou entièrement constituée d'espaces, alors \ST la considérera comme une cellule de texte.
+
+\subsection{Cellules mixtes}
+En réalité, chaque cellule est composée de \emph{deux} champs. D'un côté le \emph{champ numérique} qui contient la formule et de l'autre le \emph{champ textuel} qui sera ignoré par le moteur de calcul et n'entre pas en ligne de compte pour les calculs :
+\begin{itemize}
+ \item dans une cellule, si rien n'est précisé, la totalité de la cellule est considérée comme étant le champ numérique, et le champ textuel est vide (c'était le cas pour toutes les cellules du tableau du triangle de Pascal vu précédemment);
+ \item si la cellule contient «\falseverb{@}», alors la totalité de la cellule est considérée comme étant le champ textuel. Le champ numérique est vide et inaccessible.
+ \item si la cellule contient «\verb-:=-», alors l'argument entre accolades qui suit est le champ numérique, et tout le reste est le champ textuel. La cellule a cette structure :\par\smallskip
+ \hfil\verb-<champ textuel>:={champ numérique}<suite du champ textuel>-\hfil\null\par\smallskip
+ On peut changer ce marqueur en la séquence de contrôle «\verb-\=-» par exemple, en redéfinissant la macro \verbinline-\STnumericfieldmarker- de cette façon :\par\smallskip{\centering
+ \verbinline-\renewcommand\STnumericfieldmarker{\=}-\par\smallskip}
+ Dans ce cas, le développement de \verb-\=- n'aurait strictement aucune importance et n'interviendrait pas dans le processus : pour \ST, il ne s'agit que d'un marqueur de début de formule qui est cherché et reconnu sans être développé.
+\end{itemize}
+Une fois le «\verb-champ numérique-» calculé, lui seul et le marqueur «\verb-:=-» seront remplacés par la valeur numérique calculée.
+
+Il faut noter que «\verb-:={champ numérique}-» peut se trouver à l'intérieur d'accolades et ce quelque soit le niveau d'imbrication. Par exemple, dans une cellule, on peut écrire \verb-\textbf{:={a1+1}}-. Si le champ numérique de la cellule \falseverb{a1} est 5, alors la cellule contiendra au final \verb-\textbf{6}-.
+
+Pour fixer les idées, voici un exemple très simple :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|c|c||c|}}\hline
+valeur 1 : :={50} & valeur 2 : :={29} & moyenne : \textbf{:={(a1+b1)/2}}\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|c|c||c|}}\hline
+valeur 1 : :={50} & valeur 2 : :={29} & moyenne : \textbf{:={(a1+b1)/2}}\\\hline
+\end{spreadtab}
+\end{center}
+À noter également que «\verb-:={}-», qui définit formule vide, a le même effet que «\verb-@-» dans une cellule : celle-ci est comprise comme cellule de texte. Cependant, «\verb-@-» et «\verb-:={}-» \emph{ne sont pas équivalents} car une cellule textuelle contenant ce dernier peut recevoir une formule par copie (voir section suivante), ce qui est impossible avec «\verb-@-».
+
+\subsection{Copier des formules}
+Pour éviter d'avoir à recopier des formules identiques dans des cellules voisines, \ST fournit l'instruction \verbinline-\STcopy-.
+
+Cette commande se place dans une cellule selon cette syntaxe :
+\begin{center}
+\verbinline-\STcopy{>-$x$\verbinline-,v-$y$\verbinline-}{formule}-
+\end{center}
+où $x$ et $y$ sont des nombres positifs qui représentent des décalages horizontaux et verticaux par rapport à la cellule où se trouve l'instruction. La cellule qui contient la commande et la cellule obtenue par ces décalages définissent une plage rectangulaire de cellules qui recevront la \verb-<formule>-\footnote{La copie ne peut donc se faire que vers des cellules se trouvant à droite et plus bas que la cellule dans laquelle se trouve la commande.}. La commande \verbinline-\STcopy -\emph{ne doit pas} se trouver dans une cellule où un marqueur de champ numérique «\verb-:=-» est présent.
+
+Voici comment se déroule la copie : elle se fait en partant de la cellule où se trouve l'instruction, la cellule source. Pour chaque cellule cible, toutes les références dans la formule sont incrémentées pour tenir compte du décalage entre la cellule cible et la cellule source. Ainsi par exemple, mettons que la cellule source contienne la formule \verb-a1+b2+c3-. Lorsque cette formule est copiée dans une cellule cible se trouvant 2 colonnes à droite et 5 lignes en dessous, cette formule deviendra : \verb-c6+d7+e8-. La formule peut également contenir des références relatives qui, puisqu'elle sont relatives, ne seront pas modifiées.
+
+En faisant précéder d'un «\verb-!-» une coordonnée d'une référence, cette coordonnée reste inchangée lors de la copie. Reprenons l'exemple précédent avec la formule \verb-a!1+!b2+!c!3-. Si cette formule est copiée dans la cellule se trouvant 2 colonnes à droite et 5 lignes en dessous, alors, elle deviendra : \verb-c1+b7+c3-. Cette fonctionnalité est compatible avec des références relatives : mettons qu'une cellule contienne la formule \verb|[-1,!-1]+[!-1,1]+[!1,!2]| et que cette formule soit copiée vers la cellule se trouvant 2 colonnes à droite et 5 lignes en dessous. Alors, elle deviendra : \verb|[-1,-6]+[-3,1]+[-1,-3]|.
+
+Le caractère «\verb-!-» est le développement de la séquence de contrôle \verbinline-\STtransposecar-. On peut donc modifier ce caractère en tout autre avec \verbinline-\renewcommand\STtransposecar-\verb-{<caractère>}-. Le point d'exclamation, utilisé par défaut, garde son code de catégorie actif qui lui a été attribué par le package \verb-babel- chargé avec l'option \verb-frenchb-.
+
+Dans la syntaxe \verbinline-\STcopy{>-$x$\verbinline-,v-$y$\verbinline-}{formule}-, si le nombre $x$ est absent, la copie dans le sens horizontal se fait vers la droite jusqu'au bord droit du tableau. Si $y$ est absent, la copie dans le sens vertical se fait jusqu'en bas du tableau.
+
+Voici quelques exemples :
+\begin{tabular}{cl}\hline
+\verb-{>3,v1}- & copie vers les 3 colonnes à droite et 1 ligne en dessous\\
+\verb-{>3}- & copie vers les 3 cellules de droite\\
+\verb-{v1}- & copie vers la cellule de dessous\\
+\verb-{>}- & copie vers toutes les cellules situées à droite\\
+\verb-{v}- & copie vers toutes les cellules situées en dessous\\
+\verb-{v,>}- & copie vers le bas et vers la droite à partir de la cellule courante\\\hline
+\end{tabular}
+
+On peut facilement générer la table de multiplication de 1 à 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}
+
+Lors d'une copie de formule, si la cellule cible contient déjà un champ numérique non vide, celui-ci n'est pas écrasé et la copie ne se fait pas.
+
+Si des commandes \verbinline-\STcopy- se trouvant dans des plusieurs cellules départ ont une même cellule cible, la formule que cette dernière reçoit est celle correspondant à la dernière commande \verbinline-\STcopy- rencontrée lorsque le tableau est lu de haut en bas et de droite à gauche. Dans l'exemple visuel ci-dessous, le \verbinline-\STcopy- se trouvant dans la cellule rose \falseverb{B1} a son champ cible partiellement recouvert par celui du \verbinline-\STcopy- se trouvant dans la cellule verte \falseverb{C3}. En effet, cette dernière est rencontrée plus tard lors de la lecture du tableau :
+\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}
+Voici cet exemple repris ci-dessous pour mettre en évidence ces comportements. Dans cet exemple, la cellule \verb-b5- qui est composée d'un champ numérique et la cellule \verb-c5- qui est mixte, leur champ numérique n'étant pas vide, il est conservé.
+\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}
+Comme on l'a dit à la fin du chapitre précédent, on peut également copier une formule dans une cellule de texte contenant un champ numérique vide (c'est-à-dire une cellule contenant «\verb-:={}-»). Dans ce cas, la formule est copiée à l'endroit où se trouve «\verb-:={}-». Par contre, dans une cellule de texte contenant «\verb-@-», la copie ne se fait pas et la cellule reste purement textuelle.
+
+Exemple :
+\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{Mise en forme du tableau}
+\subsection{Séparateur décimal}
+Les packages \fp et \xfp renvoient les résultats décimaux avec le point comme séparateur décimal. Il est possible de changer ce séparateur décimal de telle sorte que tout se passe comme si les résultats retournés par \fp ou \xfp en tenaient compte. L'instruction \verbinline-\STsetdecimalsep- permet de changer le séparateur décimal en n'importe quel caractère en utilisant la syntaxe :
+\begin{center}
+\verbinline-\STsetdecimalsep-\verb-{<caractère>}-
+\end{center}
+Pour une utilisation en langue française, il faut donc inclure dans le préambule cette ligne :
+\begin{center}
+\verbinline-\STsetdecimalsep{,}-
+\end{center}
+Pour les champs numériques se trouvant en mode math, il faut noter que la virgule n'est pas neutre dans ce mode. En effet, elle est considérée comme une ponctuation ce qui explique qu'elle est suivie d'une espace. Pour neutraliser cet espace, on peut mettre cette virgule entre accolades comme on le voit dans ce code :
+
+\begin{minipage}{0.65\linewidth}
+\begin{lstlisting}[escapechar=Z,backgroundcolor=\color{ST@codebckgcolor}]
+3,14 n'est pas affichZéZ comme $3,14$.\par
+3,14 est affichZéZ comme $3{,}14$
+\end{lstlisting}
+\end{minipage}\hfill
+\begin{minipage}{0.35\linewidth}
+3,14 n'est pas affiché comme $3,14$.\par
+3,14 est affiché comme $3{,}14$
+\end{minipage}%
+
+Lorsque des cellules sont en mode math, on peut\footnote{Il est cependant préférable d'utiliser le package \texttt{numprint} pour formatter les résultats. On peut aussi modifier le code mathématique de la virgule : \texttt{\textbackslash mathcode`,="013B\textbackslash relax}. Cette modification, réservée aux utilisateurs avertis, fait entrer la virgule dans la classe 0 des signes ordinaires alors qu'elle est naturellement dans la classe 6 des signes de ponctuation.} s'inspirer de cette propriété et demander à \ST de remplacer le point décimal par une virgule entre accolades avec la commande \verbinline-\STsetdecimalsep{{,}}-. Dans ces deux tableaux où chaque cellule est en mode math, on constate que l'espacement après la virgule est neutralisé pour le second :
+
+\begin{minipage}{0.65\linewidth}
+\begin{lstlisting}
+\STsetdecimalsep{,}
+\begin{spreadtab}{{tabular}{|*3{>{$}r<{$}}|}}\hline
+@x & @y & @\text{Moyenne}\\\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{Moyenne}\\\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{Moyenne}\\\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{Moyenne}\\\hline
+5 & -4 & (a2+b2)/2\\
+-6.1 & -8 & (a3+b3)/2\\
+9.85 & 3.7 & (a4+b4)/2\\\hline
+\end{spreadtab}
+\end{minipage}
+
+\subsection{Mise en forme des nombres avec le moteur \fp}
+Comme cela a été précisé avec l'option \fp, tous les calculs sont faits par le package \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\texttt{\textbf{fp}}} et sa macro \falseverb{\FPeval}\footnote{À ce propos, les notations infixe ou postfixe sont acceptées par {\ttfamily\string\FPeval} ce qui signifie que les formules dans \ST peuvent être indifféremment sous forme infixe ou postfixe. Par exemple, la formule infixe «\falseverb{a1+b1}» est équivalente aux formules postfixes «\falseverb{a1 b1 add}» ou «\falseverb{a1 b1 +}».}. Ce package fournit d'extraordinaires possibilités de calcul pour \TeX{} et dispose de toutes les fonctions arithmétiques, scientifiques et trigonométriques usuelles. Les calculs sont faits avec une précision de $10^{-18}$, et les 18 décimales sont affichées lorsqu'un calcul ne tombe pas juste ! Sans prendre des précautions, on peut se retrouver avec beaucoup de chiffres dans les parties décimales de certains résultats. Toute cette section est compilée avec \verbinline|\STusefp|.\STusefp
+
+Pour se prémunir de ce problème, plusieurs solutions existent :
+\begin{itemize}
+ \item on peut utiliser le package \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} qui est ce qui se fait de mieux dans l'affichage des nombres;
+ \item on peut demander à \fp d'arrondir un résultat avec sa fonction \verb-round(nombre,entier)- qui arrondit \verb=nombre= avec \verb=entier= chiffres après la virgule;
+ \item on peut également demander à \ST d'arrondir \emph{tous} les nombres placés dans le tableau à une certaine précision avec la macro \verbinline-\STautoround- dont l'argument est le nombre de chiffres demandés après la virgule. Si l'argument est vide, aucun arrondi n'est fait. Si on utilise la macro étoilée \verbinline-\STautoround*-, la partie décimale est remplie si besoin avec des 0 inutiles (uniquement avec \fp).
+\end{itemize}
+Voici un exemple, des nombres de 1 à 7 et leurs inverses sont arrondis à $10^{-6}$ :\par\nobreak
+\begin{lstlisting}
+\STautoround{6}
+\begin{spreadtab}{{tabular}{|l|*7{>{\centering\arraybackslash}m{1.35cm}|}}}
+\hline
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline
+@$x^{-1}$& 1/b1 & 1/c1 & 1/d1 & 1/e1 & 1/f1 & 1/g1 & 1/h1\\\hline
+\end{spreadtab}\medskip
+
+\STautoround*{6}
+\begin{spreadtab}{{tabular}{|l|*7{>{\centering\arraybackslash}m{1.35cm}|}}}
+\hline
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline
+@$x^{-1}$& 1/b1 & 1/c1 & 1/d1 & 1/e1 & 1/f1 & 1/g1 & 1/h1\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\STautoround{6}
+\begin{spreadtab}{{tabular}{|l|*7{>{\centering\arraybackslash}m{1.35cm}|}}}
+\hline
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline
+@$x^{-1}$& 1/b1 & 1/c1 & 1/d1 & 1/e1 & 1/f1 & 1/g1 & 1/h1\\\hline
+\end{spreadtab}\medskip
+
+\STautoround*{6}
+\begin{spreadtab}{{tabular}{|l|*7{>{\centering\arraybackslash}m{1.35cm}|}}}
+\hline
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\\hline
+@$x^{-1}$& 1/b1 & 1/c1 & 1/d1 & 1/e1 & 1/f1 & 1/g1 & 1/h1\\\hline
+\end{spreadtab}
+\end{center}
+
+Tous les nombres contenus dans le tableau final, qu'ils aient été saisis tels quels ou qu'ils proviennent du résultat d'un calcul sont traités par la macro \verbinline-\STprintnum-. Par défaut, cette macro n'a aucun effet et est programmée de la façon suivante :
+\begin{center}
+ \verbinline-\newcommand\STprintnum[1]{#1}-
+\end{center}
+Il est possible d'arrondir tous les nombres via la commande \verbinline-\numprint- du package \verb-\numprint-. Pour ce faire, il faut redéfinir la macro \verbinline-\STprintnum- de cette façon :\par\nobreak
+\begin{lstlisting}
+\renewcommand\STprintnum[1]{\numprint{#1}}
+\nprounddigits{6}
+\begin{spreadtab}{{tabular}{cccccccc}}
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 &7 \\\hline
+@$1/x$ &1/b1&1/c1&1/d1&1/e1&1/f1&1/g1&1/h1
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\renewcommand\STprintnum[1]{\numprint{#1}}
+\nprounddigits{6}
+\begin{spreadtab}{{tabular}{cccccccc}}
+@$x$ & 1 & 2 & 3 & 4 & 5 & 6 &7 \\\hline
+@$1/x$ &1/b1&1/c1&1/d1&1/e1&1/f1&1/g1&1/h1
+\end{spreadtab}
+\end{center}
+
+Voici un autre exemple similaire où l'on teste si le nombre à afficher est négatif avec la commande \verbinline-\FPifneg- du package \fp. Si tel est le cas, le nombre est affiché en rouge. La commande \verbinline-\STautoround- a été préférée à \verbinline-\nprounddigits- du package \verb-numprint- puisque cette dernière ajoute des 0 inutiles. On a également remis le point décimal par défaut puisque \verbinline-\numprint- est en charge de l'affichage des nombres.
+\begin{lstlisting}
+\STsetdecimalsep{.}
+\renewcommand\STprintnum[1]{\FPifneg{#1}\color{red}\fi\numprint{#1}}
+\STautoround{6}
+\begin{spreadtab}{{tabular}{cccccccc}}
+@$x$ & -1 & 2 & -3 & 4 & -5 & 6 & -7 \\\hline
+@$1/x$ &1/b1&1/c1&1/d1&1/e1&1/f1&1/g1&1/h1
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\STsetdecimalsep{.}
+\renewcommand\STprintnum[1]{\STifneg{#1}\color{red}\fi\numprint{#1}}
+\STautoround{6}
+\begin{spreadtab}{{tabular}{cccccccc}}
+@$x$ & -1 & 2 & -3 & 4 & -5 & 6 & -7 \\\hline
+@$1/x$ &1/b1&1/c1&1/d1&1/e1&1/f1&1/g1&1/h1
+\end{spreadtab}
+\end{center}\STusexfp
+
+\subsection{Retours à la ligne et filets horizontaux}
+Pour bien délimiter la fin d'une ligne, \ST est contraint de reconnaître les retours à la ligne et les filets horizontaux. Ce package permet d'utiliser dans le tableau l'argument optionnel de \verb-\\- de cette façon : \verb-\\[<dimension>]-.
+
+Pour les filets horizontaux, on peut utiliser autant de fois que l'on veut:
+\begin{itemize}
+ \item \verb-\hline-;
+ \item \verb=\cline{x-y}= où \falseverb x et \falseverb y sont les numéro des colonnes de départ et d'arrivée du filet;
+ \item \verb=\hhline{<type>}= où \verb=<type>= est le type de ligne désirée (voir la documentation du package \href{http://www.ctan.org/tex-archive/macros/latex/required/tools/}{\texttt{\textbf{hhline}}}).
+ \item n'importe quelle commande du package \href{http://www.ctan.org/tex-archive/macros/latex/contrib/booktabs/}{\texttt{\textbf{booktabs}}}, à savoir \verb-\toprule-, \verb-\midrule-, \verb-\bottomrule-, \verb-\cmidrule-, \verb-\addlinespace-, \verb-\morecmidrule- et \verb-\specialrule-. Tous les arguments de ces macros, optionnels ou pas sont gérés;
+ \item \verbinline-\noalign- et son argument peuvent être placés après \verb-\\- et pris en compte.
+\end{itemize}
+Voici le triangle de Pascal inversé, et massacré pour l'exemple :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{*5c}}
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]\\[1em]
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\ \hline\hline
+[0,1] & [-1,1] & & & \\ \cline{2-4}
+1 & & & & \\ \hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{*5c}}
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]\\[1em]
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\ \hline\hline
+[0,1] & [-1,1] & & & \\ \cline{2-4}
+1 & & & & \\ \hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Masquer une ligne ou une colonne}
+Parfois, une colonne ou une ligne entière est destinée à recevoir des calculs intermédiaires qui n'ont pas à être affichés dans le tableau final. Pour cela \ST dispose de deux séquences de contrôle \verbinline=\SThiderow= et \verbinline=\SThidecol= qui, lorsqu'elles sont placées dans une cellule, masquent la ligne ou la colonne dans laquelle se trouve cette cellule.
+
+Voici un exemple :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|ccc|}}
+\hline
+@ valeurs de $x$ & -1 & 0\SThidecol & 2 & 3 \\\hline
+@$f(x)=2x-1$ & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 \\
+@$g(x)=x-10$\SThiderow & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 \\
+@$h(x)=1-x$ & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|ccc|}}
+\hline
+@ valeurs de $x$ & -1 & 0\SThidecol & 2 & 3 \\\hline
+@$f(x)=2x-1$ & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 \\
+@$g(x)=x-10$\SThiderow & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 \\
+@$h(x)=1-x$ & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] \\\hline
+\end{spreadtab}
+\end{center}
+On peut observer comment on masque la ligne contenant $g(x)$ et la colonne correspondant à la valeur 0.
+
+Il faut se souvenir que les lignes et les colonnes masquées sont \emph{invisibles} pour l'environnement tableau choisi par l'utilisateur, ce qui explique que dans le préambule du tableau, seules 4 colonnes (\falseverb{|r|ccc|}) aient été définies et non 5 comme le voit \ST.
+
+Pour voir la différence, voici le tableau obtenu en définissant 5 colonnes et en ne masquant aucune ligne ni colonne :\par\nobreak
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|cccc|}}
+\hline
+@ valeurs de $x$ & -1 & 0 & 2 & 3 \\\hline
+@$f(x)=2x-1$ & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 & 2*[0,-1]-1 \\
+@$g(x)=x-10$ & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 & [0,-2]-10 \\
+@$h(x)=1-x$ & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] & 1-[0,-3] \\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Sauvegarder la valeur d'une cellule}
+On peut être amené à avoir besoin de la valeur numérique d'une cellule dans le tableau pour l'afficher en dehors d'une formule ou même à l'extérieur du tableau. On doit alors utiliser la commande :\par\nobreak
+\begin{center}
+\verbinline-\STsavecell{<sequence de controle>}{<reference absolue>}-
+\end{center}
+Avec un \verbinline-\global\def-\footnote{La commande \texttt{\string\def} ne vérifie pas si la macro qu'elle définit existe déjà.}, cette commande a pour effet de sauvegarder de façon globale dans \falseverb{<sequence de controle>} le résultat de la formule contenue dans la cellule \falseverb{<reference absolue>}.
+
+On ne peut utiliser que des références \emph{absolues}; les références relatives ne sont pas acceptées car cette commande doit se placer dans l'argument optionnel de l'environnement \verbinline-spreadtab-.
+
+Exemple :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}[\STsavecell\result{c1}]{{tabular}{|c|c|c|c|c|}}
+\hline
+10 & a1+10 & b1+10 & a1+b1+c1 & @cell c1 : \result\\\hline
+\end{spreadtab}
+\par\medskip
+Voici la cellule c1 : \result
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}[\STsavecell\result{c1}]{{tabular}{|c|c|c|c|c|}}
+\hline
+10 & a1+10 & b1+10 & a1+b1+c1 & @cell c1 : \result\\\hline
+\end{spreadtab}
+\par\medskip
+Voici la cellule c1 : \result
+\end{center}
+Si l'on veut sauvegarder plusieurs cellules, on peut mettre autant de fois que l'on veut la commande \verbinline-\STsavecell- dans l'argument optionnel.
+
+Exemple :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}[\STsavecell\hhh{b3}\STsavecell\mmm{c3}\STsavecell\sss{d3}]{{tabular}{|rc|}}\hline
+@Vitesse (km/h) &\SThidecol&\SThidecol&\SThidecol& 35 \\
+@distance (km) & & & & 180\\\hline
+@Temps (h min s) & trunc(e2/e1,0) & trunc(60*(e2/e1-b3),0) & trunc(3600*(e2/e1-b3)-60*c3,1) &@\hhh\ h \mmm\ min \sss\ s\\\hline
+\end{spreadtab}\par\medskip
+On met au moins \hhh\ heures
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}[\STsavecell\hhh{b3}\STsavecell\mmm{c3}\STsavecell\sss{d3}]{{tabular}{|rc|}}\hline
+@Vitesse (km/h) &\SThidecol&\SThidecol&\SThidecol& 35 \\
+@distance (km) & & & & 180\\\hline
+@Temps (h min s) & trunc(e2/e1,0) & trunc(60*(e2/e1-b3),0) & trunc(3600*(e2/e1-b3)-60*c3,1) &@\hhh\ h \mmm\ min \sss\ s\\\hline
+\end{spreadtab}\par\medskip
+On met au moins \hhh\ heures
+\end{center}
+
+\subsection{Afficher la valeur d'une cellule}
+Pour afficher la valeur du champ numérique d'une cellule dans le champ textuel, on vient de voir qu'on pouvait sauvegarder cette valeur dans une séquence de contrôle et se servir de cette séquence de contrôle pour l'afficher ensuite. Le procédé est un peu fastidieux et détourne de ses intentions la commande \verbinline-\STsavecell- qui sert surtout à sauvegarder une valeur pour l'utiliser en dehors du tableau.
+
+Pour afficher simplement la valeur du champ numérique d'une cellule dans un champ textuel, on peut utiliser la syntaxe \verb-<<référence>>- qui sera remplacé par la valeur numérique de la cellule \verb-référence- où la \verb-référence- peut être relativess ou absolue. Si ce qui est entre \verb-<<- et \verb->>- n'est pas une référence, alors rien n'est fait et \verb-<<texte>>- est laissé en l'état. La \verb-référence- ne doit contenir aucun espace. Si on écrit \verb-<< a1>>- alors, l'espace fait que la référence n'est pas reconnue et rien ne sera fait.
+
+Exemple dans une cellule purement textuelle \verb-a3- :
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{lr}}
+@Prix de vente & 250 \\
+@Prix d'achat & 216 \\\hline
+@B\'en\'efice (<<b1>>-<<b2>>) & b1-b2
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{lr}}
+@Prix de vente & 250 \\
+@Prix d'achat & 216 \\\hline
+@B\'en\'efice (<<b1>>-<<b2>>) & b1-b2
+\end{spreadtab}
+\end{center}
+Exemple dans la cellule mixte c1 :
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|c|c||c|}}\hline
+23 & 32 & Moyenne $= \frac{<<a1>>+<<b1>>}{2}= :={(a1+b1)/2}$\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|c|c||c|}}\hline
+23 & 32 & Moyenne $= \frac{<<a1>>+<<b1>>}{2}= :={(a1+b1)/2}$\\\hline
+\end{spreadtab}
+\end{center}
+Les caractères qui délimitent la référence valent "\verb-<<-" et "\verb->>-" par défaut. Ils peuvent être modifiés avec la commande \verbinline-\STsetdisplaymarks- dont les 2 arguments définissent le délimiteur de gauche et le délimiteur de droite. En écrivant \verbinline-\STsetdisplaymarks{|}{|}-, on devra écrire \verb-|référence|- pour provoquer l'affichage du champ numérique de la cellule \verb-référence-.
+
+\subsection{Utiliser \ttfamily\textbackslash multicolumn}
+Le package \ST est compatible avec la syntaxe \verbinline=\multicolumn{<nombre>}{<type>}{<contenu>}= qui fusionne \falseverb{<nombre>} cellules en une cellule de type et de contenu spécifiés dans les arguments.
+
+En utilisant \verbinline=\multicolumn=, \ST permet même de conserver une certaine cohérence au niveau du référencement des cellules. Sur ce tableau où des cellules sont fusionnées, les cases du tableau contiennent les références absolues vues par \ST :\par\nobreak
+\begin{center}
+\ttfamily
+\begin{tabular}{|*7{c|}}\hline
+a1&b1&c1&d1&e1&f1&g1\\\hline
+a2&\multicolumn{2}{l|}{b2}&d2&e2&f2&g2\\\hline
+\multicolumn{3}{|l|}{a3}&d3&\multicolumn{2}{l|}{e3}&g3\\\hline
+\end{tabular}
+\end{center}
+Ainsi, quelque soit le nombre de cellules fusionnées, la cellule suivante porte un numéro de colonne qui tient compte du nombre de cellules fusionnées.
+
+Sur la dernière ligne, les cellules \falseverb{a3}, \falseverb{b3} et \falseverb{c3} sont fusionnées, et si la cellule \falseverb{a3 }contient une formule, les cellules \falseverb{b3} et \falseverb{c3} \emph{n'existent pas} pour \ST : on ne peut nulle part faire référence à ces cellules.
+
+Voici un exemple où chaque nombre de la ligne du haut est le produit des 2 nombres se trouvant au dessous de lui :\par\nobreak
+\begin{lstlisting}
+\newcolumntype{K}[1]{@{}>{\centering\arraybackslash}p{#1cm}@{}}
+\begin{spreadtab}{{tabular}{*6{K{0.5}}}}
+\cline{2-5}
+&\multicolumn{2}{|K{1}|}{:={a2*c2}} & \multicolumn{2}{K{1}|}{:={c2*e2}} &\\\hline
+\multicolumn{2}{|K{1}}{:=8}&\multicolumn{2}{|K{1}}{:=7}&\multicolumn{2}{|K{1}|}{:=6}\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\newcolumntype{K}[1]{@{}>{\centering\arraybackslash}p{#1cm}@{}}
+\begin{spreadtab}{{tabular}{*6{K{0.5}}}}
+\cline{2-5}
+&\multicolumn{2}{|K{1}|}{:={a2*c2}} & \multicolumn{2}{K{1}|}{:={c2*e2}} &\\\hline
+\multicolumn{2}{|K{1}}{:=8}&\multicolumn{2}{|K{1}}{:=7}&\multicolumn{2}{|K{1}|}{:=6}\\\hline
+\end{spreadtab}
+\end{center}
+On remarque que le marqueur de champ numérique «\falseverb{:=}» est nécessaire dans chaque cellule où se trouve la commande \verbinline-\multicolumn-. On comprend en effet que si ce marqueur n'existait pas, la totalite de la cellule, c'est-à-dire \verb-\multicolumn{2}{|c|}{<formule>}- serait considérée comme étant une formule.
+
+\section{Macro-fonctions}
+L'extension \falseverb{fp} fournit un nombre conséquent d'opérations et de fonctions. Malgré tout, dans le cadre d'un package comme \ST, celles-ci peuvent être insuffisantes et il est possible au programmeur averti d'écrire des macro-fonctions supplémentaires en utilisant celles fournies par \falseverb{fp}. Cette section présente les macro-fonctions pour l'instant disponibles\footnote{Bien d'autres restent à écrire ! Elles seront disponibles dans des versions futures de \ST.}. Il y aura plus de précisions sur la méthode pour programmer des macro-fonctions dans la prochaine version de ce manuel.
+
+\subsection{Macro-fonctions mathématiques}
+\subsubsection{Sommer des cellules}
+La fonction «\verbinline=sum=» permet de faire la somme d'une ou plusieurs plages de cellules.
+
+Elle s'utilise ainsi : \verbinline=sum(<plage 1>;<plage 2>;...;<plage n>)=, où une plage de cellules est :
+\begin{itemize}
+ \item soit une cellule isolée comme «\falseverb{a1}» ou «\falseverb{[2,1]}»;
+ \item soit une zone rectangulaire délimitée par la cellule supérieure gauche et inférieure droite de cette façon : «\verb=<cellule 1>:<cellule 2>=», à condition que «\verb=<cellule 1>=» se trouve \emph{avant} «\verb=<cellule 2>=» lorsqu'on parcourt le tableau de haut en bas, de gauche à droite.\par
+ Voici des exemple de plages de cellules : «\falseverb{a2:d5}», «\falseverb{[-1,-1]:[2,3]}», «\falseverb{b4:[5,1]}».
+\end{itemize}
+Dans les plages de cellules, les cellules vides ou ne contenant que du texte sont considérées comme contenant le nombre 0. Il en est de même pour les cellules masquée car fusionnées par \verbinline-\multicolumn-.
+
+Les références relatives et absolues peuvent être utilisées conjointement, comme il semble bon à l'utilisateur. Voici un exemple où l'on fait la somme des coefficients du triangle de Pascal :\par\nobreak
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{*5c}}
+\multicolumn{5}{c}{somme=:={sum(a2:e6)}}\\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\
+[0,1] & [-1,1] & & & \\
+1 & & & &
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.25\linewidth}
+\centering
+\begin{spreadtab}{{tabular}{*5c}}
+\multicolumn{5}{c}{somme=:={sum(a2:e6)}}\\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\
+[0,1] & [-1,1] & & & \\
+1 & & & &
+\end{spreadtab}
+\end{minipage}%
+
+\subsubsection{Macro-fonction \ttfamily fact}
+La macro-fonction \verbinline=fact(<nombre>)= permet de calculer la factorielle de son argument. Avec le moteur de calcul \href{https://www.ctan.org/pkg/fp}{\fp} le nombre doit être un entier compris entre 0 et 18 inclus pour éviter des débordements. Le \falseverb{<nombre>} peut aussi être une référence vers une cellule contenant un nombre entier.
+
+Voici les factorielles de 0 à 8 :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{*9c}}
+ 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 &8\\\hline
+fact(a1)&fact(b1)&fact(c1)&fact(d1)&fact(e1)&fact(f1)&fact(g1)&fact(h1)&fact(i1)
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{*9c}}
+ 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 &8\\\hline
+fact(a1)&fact(b1)&fact(c1)&fact(d1)&fact(e1)&fact(f1)&fact(g1)&fact(h1)&fact(i1)
+\end{spreadtab}
+\end{center}
+
+\subsubsection{Macro-fonction \ttfamily sumprod}
+La fonction \verbinline=sumprod= permet de multiplier les éléments correspondants de 2 plages ou plus et ensuite, additionner ces produits.
+
+Cette fonction s'utilise ainsi : \verbinline{sumprod(<plage 1>;<plage 2>;...;<plage n>)}. Toutes les plages rectangulaires doivent avoir les mêmes dimensions.
+
+Voici un exemple simple où l'on calcule l'âge moyen d'un groupe d'enfants âgés de 10 à 15 ans :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{r*6c}}
+@\^Ages & 10 & 11 & 12 & 13 & 14 & 15\\
+@Nombre & 5 & 8 & 20 & 55 & 9 & 3\\\hline
+@Moyenne&\multicolumn{6}{l}{:={sumprod(b1:g1;b2:g2)/sum(b2:g2)}}
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{r*6c}}
+@\^Ages & 10 & 11 & 12 & 13 & 14 & 15\\
+@Nombre & 5 & 8 & 20 & 55 & 9 & 3\\\hline
+@Moyenne&\multicolumn{6}{l}{:={sumprod(b1:g1;b2:g2)/sum(b2:g2)}}
+\end{spreadtab}
+\end{center}
+De la même façon que pour la macro-fonction \verbinline-sum-, les cellules de texte, vides ou fusionnées par un \verbinline-\multicolumn- sont considérées comme contenant le nombre 0.
+
+\subsubsection{Nombres aléatoires}
+\verbinline-randint- et \verbinline-rand- renvoient un nombre aléatoire, respectivement entier entre bornes et décimal entre 0 et 1.
+
+\paragraph{Nombres aléatoires avec le moteur \fp}
+Avec ce moteur, \verbinline-randint- et \verbinline-rand- sont des \emph{macro fonctions} de \ST qui s'appuient sur la macro \verb|\FPrandom| de \fp.
+
+À noter : la «graine» qui initialise la suite aléatoire dépend de la date ainsi que de la la minute à laquelle est faite la compilation. Les séries aléatoires données par cette fonction changeront entre deux compilations faites à des heures dont les minutes diffèrent. Si l'on veut vraiment avoir des nombres aléatoires indépendant du moment de compilation et donc reproductibles, il faut neutraliser la macro interne \verb-\ST@seed- et définir une graine pour \fp :\par\nobreak
+\begin{lstlisting}[backgroundcolor=\color{ST@codebckgcolor}]
+\makeatletter
+\renewcommand\ST@seed{}% redefinit la macro interne
+\makeatother
+\FPseed=27% donne une graine (n'importe quel entier) a fp
+\end{lstlisting}
+La macro fonction \verbinline-randint([<nombre1>,]<nombre2>)- renvoie une nombre \emph{entier} qui dépend des paramètres : \verb=<nombre1>= est un entier optionnel qui vaut 0 par défaut. L'entier aléatoire renvoyé est compris dans l'intervalle \verb=[<nombre1>;<nombre2>]=.
+
+La macro fonction \verbinline-rand()- renvoie un nombre aléatoire décimal compris entre 0 et 1 :\par\nobreak
+\begin{lstlisting}
+\STautoround{6}
+\STusefp
+\begin{spreadtab}{{tabular}{|l|cccc|}}\hline
+@nombres dans [0;1] &rand() &rand() &rand() &rand() \\
+@nombres dans [-5;5] &randint(-5,5) &randint(-5,5) &randint(-5,5) &randint(-5,5)\\
+@nombres dans [0;20] &randint(20) &randint(20) &randint(20) &randint(20) \\
+\hline
+\end{spreadtab}
+\STusexfp
+\end{lstlisting}
+\begin{center}
+\STautoround{6}
+\STusefp
+\begin{spreadtab}{{tabular}{|l|cccc|}}\hline
+@nombres dans [0;1] &rand() &rand() &rand() &rand() \\
+@nombres dans [-5;5] &randint(-5,5) &randint(-5,5) &randint(-5,5) &randint(-5,5)\\
+@nombres dans [0;20] &randint(20) &randint(20) &randint(20) &randint(20) \\
+\hline
+\end{spreadtab}
+\STusexfp
+\end{center}
+
+\paragraph{Nombres aléatoires avec le moteur \xfp}
+Avec ce moteur, \verbinline-randint- et \verbinline-rand- sont des fonctions reconnues nativement par \xfp. Un avertissement sera émis si \XeLaTeX{} est utilisé dans une version trop ancienne qui n'implémente pas les primitives de génération de nombres pseudo-aléatoires; dans ce cas, utiliser les fonctions \verbinline-randint- et \verbinline-rand- ne sera pas possible et conduira à des erreurs de compilation.
+
+Comme le spécifie la documentation de \href{http://mirrors.ctan.org/macros/latex/contrib/l3kernel/interface3.pdf}{\texttt{\textbf{interface3}}}, la fonction \verbinline|randint(<a>,<b>)| produit un entier aléatoire entre les deux arguments, mais si \verb|<a>| est omis, \verbinline|randint(<b>)| produit un entier entre {\color{red}\bfseries1} et \verb|<b>| ce qui constitue un comportement différent de la macro fonction \verbinline-randint- de \ST utilisée avec \fp qui produit un entier entre {\color{red}\bfseries0} et \verb|<b>|.\STusexfp
+
+\begin{lstlisting}
+\STautoround{6}
+\STusexfp
+\begin{spreadtab}{{tabular}{|l|cccc|}}\hline
+@nombres dans [0;1] &rand() &rand() &rand() &rand() \\
+@nombres dans [-5;5] &randint(-5,5) &randint(-5,5) &randint(-5,5) &randint(-5,5)\\
+@nombres dans [0;20] &randint(20) &randint(20) &randint(20) &randint(20) \\
+\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\STautoround{6}
+\STusexfp
+\begin{spreadtab}{{tabular}{|l|cccc|}}\hline
+@nombres dans [0;1] &rand() &rand() &rand() &rand() \\
+@nombres dans [-5;5] &randint(-5,5) &randint(-5,5) &randint(-5,5) &randint(-5,5)\\
+@nombres dans [1;20] &randint(20) &randint(20) &randint(20) &randint(20) \\
+\hline
+\end{spreadtab}
+\end{center}
+
+\subsubsection{PGCD et PPCM}
+Les macros fonctions "gcd" et "lcm" permettent de calculer le Plus Grand Commun Diviseur (PGCD) et le Plus Petit Commun Multiple (PPCM) des nombres passés en arguments et séparés par des virgules :
+\begin{center}
+\verbinline-gcd(nombre1,nombre2,...,nombreN)-\par
+\verbinline-lcm(nombre1,nombre2,...,nombreN)-
+\end{center}
+Exemple :
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|r|r||c|c|}}\hline
+\multicolumn3{|c||}{@Nombres}& @PGCD & @PPCM \\\hline
+24 & 18 & 12 & \STcopy{v}{gcd(a2,b2,c2)} & \STcopy{v}{lcm(a2,b2,c2)}\\
+15 & 10 & 25 & & \\
+16 & 12 & 15 & & \\
+\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|r|r||c|c|}}\hline
+\multicolumn3{|c||}{@Nombres}& @PGCD & @PPCM \\\hline
+24 & 18 & 12 & \STcopy{v}{gcd(a2,b2,c2)} & \STcopy{v}{lcm(a2,b2,c2)}\\
+15 & 10 & 25 & & \\
+16 & 12 & 15 & & \\
+\hline
+\end{spreadtab}
+\end{center}
+
+\subsubsection{Écriture scientifique}
+La macro fonction "scitodec" permet de convertir un nombre écrit en écriture scientifique en nombre décimal. La syntaxe est \verbinline-scitodec(<texte>)-, où le \verb-<texte>- est :
+\begin{enumerate}[label=--]
+ \item une suite de caractères se présentant sous la syntaxe \verb-<mantisse>EE<exposant>-, où la \verb-<mantisse>- est un nombre décimal et l'\verb->exposant>- est un entier relatif. Les "E" peuvent être écrit en majuscule ou minuscule.
+
+ Le nombre ainsi représenté est $\text{\ttfamily <mantisse>}\times10^{\text{\ttfamily <exposant>}}$
+ \item une référence au champ \emph{textuel} d'une cellule qui doit contenir des caractères obéissants à la syntaxe vue au point précédent.
+\end{enumerate}
+Exemple :
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|r|r|}}\hline
+@Écritures scientifiques & @Écritures décimales \\\hline
+@4EE2 & \STcopy{v}{scitodec([-1,0])}\\
+@-3.1EE-3 & \\
+@15ee5 & \\
+@-0.025ee7 & \\
+@2.125EE0 & \\
+@3.1575EE-4 & \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|r|r|}}\hline
+@Écritures scientifiques & @Écritures décimales \\\hline
+@4EE2 & \STcopy{v}{scitodec([-1,0])}\\
+@-3.1EE-3 & \\
+@15ee5 & \\
+@-0.025ee7 & \\
+@2.125EE0 & \\
+@3.1575EE-4 & \\\hline
+\end{spreadtab}
+\end{center}
+
+Le moteur \xfp est comprend nativement les nombres écrits en notation scientifique sous la forme \verb|<a>e<b>| mais l'utilisation de cette syntaxe est \emph{impossible} à utiliser avec \ST car le nombre \verb|4e3|, qui est 4000, serait compris par \ST comme 4 suivi du contenu de la cellule \verb|e3|.
+
+\subsubsection{Identité}
+La plus simple des macros fonctions est «\verbinline=id(<nombre>)=». Celle-ci renvoie le nombre qui se trouve entre parenthèses. Mathématiquement, elle ne sert pas à grand chose, mais avec \ST, elle permet de passer des expressions mathématiques à des macros qui n'en admettent pas. On peut ainsi s'en servir dans les plages de cellules de \verbinline=sum= par exemple.
+
+Dans le code ci dessous, la macro \verbinline=id= est utilisée pour déterminer la plage de cellules à additionner avec \verbinline-sum-. Dans cet exemple, la valeur du champ numérique de la cellule a2 vaut 8. Et donc, "\verbinline=sum([0,-1]:[id(a2-1),-1])/a2=" est équivalent à \verbinline=sum([0,-1]:[7,-1])/8= :
+
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{r*{10}c}}
+ @Entiers & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
+Moyenne des :={8} premiers entiers & sum([0,-1]:[id(a2-1),-1])/a2 \\
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{r*{10}c}}
+ @Entiers & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
+Moyenne des :={8} premiers entiers & sum([0,-1]:[id(a2-1),-1])/a2 \\
+\end{spreadtab}
+\end{center}
+
+\subsection{Macro-fonctions de test}
+Comme \fp et sa macro \verb|\FPeval| n'admet pas de test dans son argument, 3 macro-fonctions de test sont disponibles (elles sont moins intéressantes pour \xfp qui dispose de l'opérateur «\verb|?:|», voir plus bas) :\par\nobreak
+\begin{center}
+\verbinline=ifeq(nombre1,nombre2,nombre3,nombre4)=\par
+\verbinline=ifgt(nombre1,nombre2,nombre3,nombre4=\par
+\verbinline=iflt(nombre1,nombre2,nombre3,nombre4)=
+\end{center}
+La comparaison se fait entre \falseverb{nombre1} et \falseverb{nombre2} :
+\begin{itemize}
+ \item test d'égalité pour \verbinline-ifeq- : \falseverb{nombre1} = \falseverb{nombre2} ?
+ \item test de supériorité stricte pour \verbinline-ifgt- : \falseverb{nombre1} > \falseverb{nombre2} ?
+ \item test d'infériorité stricte pour \verbinline-iflt- : \falseverb{nombre1} < \falseverb{nombre2} ?
+\end{itemize}
+Si le test est vrai, \falseverb{nombre3} est retourné, sinon c'est \falseverb{nombre4}.
+
+À titre d'exemple, voici quelques valeurs de la fonction
+$f(x)=\begin{cases}
+10 &\text{si }x<1\\
+0 &\text{si }x=1\\
+-10 &\text{si }x>1
+\end{cases}
+$\smallskip
+
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*2c|}}\hline
+@$x$ & @$f(x)$ \\\hline
+-0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*2c|}}\hline
+@$x$ & @$f(x)$ \\\hline
+-0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\
+[0,-1]+0.5 & iflt([-1,0],1,10,ifeq([-1,0],1,0,-10))\\\hline
+\end{spreadtab}
+\end{center}
+Le moteur \xfp et son opérateur ternaire \verb|<a>?<b>:<c>| rend les tests plus faciles dans les expressions évaluées : si le test \verb|<a>| est vrai, \verb|<b>| est retenu sinon, c'est \verb|<c>|. Ainsi, l'imbrication de tests ci-dessus se programme :
+
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*2c|}}\hline
+@$x$ & @$f(x)$ \\\hline
+-0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*2c|}}\hline
+@$x$ & @$f(x)$ \\\hline
+-0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\
+[0,-1]+0.5 & [-1,0]<1 ? 10 : [-1,0]=1 ? 0 : -10\\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Macro-fonctions de date}
+\subsubsection{Convertir une date en nombre avec \ttfamily frshortdatetonum}\label{datetonum}
+La macro \verbinline-frshortdatetonum- permet de convertir une date de la forme 14/7/1789 en un nombre qui est en fait le nombre de jours écoulés depuis le 1\ier{} mars de l'an 0\footnote{Cet «an 0» n'existe d'ailleurs pas, mais cela ne devrait pas être gênant pour les dates contemporaines}. Il est important de noter que cette macro-fonction requiert un argument \emph{textuel} et non pas un nombre ou le résultat d'un calcul mathématique. Par conséquent, si l'argument de cette macro-fonction fait référence à une cellule, cette cellule \emph{doit} être une cellule textuelle, c'est à dire contenant «\verb-@-» ou «\verb-:={}-»
+
+Dans l'exemple ci-dessous, les deux premières lignes montrent que la cellule de gauche contient une date, et la cellule de droite fait référence à cette date pour calculer le nombre correspondant. La troisième ligne montre dans la cellule de gauche la date 0, mais surtout calcule dans la cellule de droite le nombre correspondant à la date \emph{d'aujourd'hui}, en transformant en nombre les compteurs de \TeX{} \verbinline-\day-, \verbinline-\month- et \verbinline-\year- qui contiennent les numéros des jours, mois et année courants.\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{cc}}
+@14/7/1789 & frshortdatetonum(a1)\\
+1/1/2001 :={} & frshortdatetonum(a2)\\\hline
+frshortdatetonum(1/3/0) & frshortdatetonum(\number\day/\number\month/\number\year)
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{cc}}
+@14/7/1789 & frshortdatetonum(a1)\\
+1/1/2001 :={} & frshortdatetonum(a2)\\\hline
+frshortdatetonum(1/3/0) & frshortdatetonum(\number\day/\number\month/\number\year)
+\end{spreadtab}
+\end{center}
+Une autre macro-fonction existe, elle transforme une date longue du type «25 décembre 1789» en un nombre. L'argument peut aussi être la séquence de contrôle \verbinline-\today- si l'on a pris le soin de charger l'extension \verb-babel- avec l'option \verb-frenchb-.\par\nobreak
+\begin{lstlisting}[escapechar=Z]
+\begin{spreadtab}{{tabular}{cc}}
+frlongdatetonum(\today) & frlongdatetonum(25 dZéZcembre 2009)\\
+@1 juillet 1970 & frlongdatetonum(a2)
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{cc}}
+frlongdatetonum(\today) & frlongdatetonum(25 décembre 2009)\\
+@1 juillet 1970 & frlongdatetonum(a2)
+\end{spreadtab}
+\end{center}
+
+\subsubsection{Passer d'un nombre à une date}
+Plusieurs macro-fonctions permettent de traduire un nombre en une donnée de date. Toutes ces macro-fonctions ont en commun que leur résultat est du \emph{texte}. Par conséquent, \emph{la cellule les contenant deviendra une cellule textuelle} dont le texte sera le résultat de cette fonction. Si un texte cohabitait avec la formule dans cette cellule, le résultat de la formule sera inséré à la place de \verb-:={<formule>}-. Il en résulte que la cellule ne peut plus faire l'objet d'aucun traitement mathématique ensuite.
+
+Voici ces fonctions :
+\begin{itemize}
+ \item \verbinline-numtofrshortdate- transforme un nombre en une date courte du type 14/7/1789;
+ \item \verbinline-numtofrlongdate- transforme un nombre en une date longue du type «14 juillet 1789»;
+ \item \verbinline-numtofrmonth- extrait d'un nombre représentant une date le nom du mois correspondant;
+ \item \verbinline-numtofrday- extrait d'un nombre représentant une date le nom du jour correspondant.
+\end{itemize}
+Voici un exemple où l'on se place 1000 jours avant puis 1000 jours après le 1/6/2009. Pour chacune de ces 2 dates, on calcule la date courte, la date longue, le mois et le jour de la semaine.\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{cc}} \hline
+\multicolumn{2}{|c|}{@1/6/2009} \\\hline\hline
+1000 & numtofrshortdate(frshortdatetonum(a1)+[-1,0])\\
+1000 & numtofrlongdate(frshortdatetonum(a1)+[-1,0]) \\
+1000 & numtofrmonth(frshortdatetonum(a1)+[-1,0]) \\
+1000 & numtofrday(frshortdatetonum(a1)+[-1,0]) \\\hline
+-1000 & numtofrshortdate(frshortdatetonum(a1)+[-1,0])\\
+-1000 & numtofrlongdate(frshortdatetonum(a1)+[-1,0]) \\
+-1000 & numtofrmonth(frshortdatetonum(a1)+[-1,0]) \\
+-1000 & numtofrday(frshortdatetonum(a1)+[-1,0])
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{cc}} \hline
+\multicolumn{2}{|c|}{@1/6/2009} \\\hline\hline
+1000 & numtofrshortdate(frshortdatetonum(a1)+[-1,0])\\
+1000 & numtofrlongdate(frshortdatetonum(a1)+[-1,0]) \\
+1000 & numtofrmonth(frshortdatetonum(a1)+[-1,0]) \\
+1000 & numtofrday(frshortdatetonum(a1)+[-1,0]) \\\hline
+-1000 & numtofrshortdate(frshortdatetonum(a1)+[-1,0])\\
+-1000 & numtofrlongdate(frshortdatetonum(a1)+[-1,0]) \\
+-1000 & numtofrmonth(frshortdatetonum(a1)+[-1,0]) \\
+-1000 & numtofrday(frshortdatetonum(a1)+[-1,0])
+\end{spreadtab}
+\end{center}
+
+\subsection{Macro fonctions de coordonnées}\label{tag}
+Plutôt que de faire référence à une cellule par ses coordonnées qui sont difficiles à mémoriser et qui changent si on insère une ligne ou une colonne, il est parfois bien plus pratique de donner un nom à une cellule et d'y faire référence plus loin par ce nom.
+
+La macro fonction ``\verbinline-tag(<nom>)-'' a pour effet de nommer la cellule dans laquelle elle se trouve. Il ne s'agit pas vraiment d'une macro fonction comme les autres puisque ce qu'elle retourne rien lorsqu'elle est mise dans une formule : elle disparait sans provoquer aucun effet sur le résultat mathématique. On peut donc écrire ``\verbinline-tag(<nom>)-'' \emph{n'importe où} dans le champ numérique d'une cellule. Le \verb-<nom>- peut être n'importe quelle suite de caractères alphanumériques, mais il est déconseillé de mettre une lettre et un nombre, qui pourraient être compris comme une référence à une cellule, et serait donc modifié lors d'une opération de copie avec \verbinline-\STcopy-. Cette macro fonction a une action supplémentaire, elle sauvegarde via un \verbinline-\def- la valeur numérique de la cellule dans laquelle elle se trouve de façon à pouvoir y faire appel plus tard \emph{en dehors du tableau} via la commande purement développable \verbinline-\STtag{<nom>}-.
+
+Par la suite dans le tableau, au lieu de mettre les coordonnées de la cellule \verb-<nom>-, on peut écrire ``\verbinline-cell(<nom>)-'' qui est une macro fonction qui renvoit les coordonnées de la cellule précédemment nommée. Par exemple si ``\verbinline-tag(<nom>)-'' a été écrit dans la cellule ``\verb-B3-'' si on a écrit plus loin ``cell(<nom>)'', cette macro fonction renvoit \verb-B3-.
+
+Voici un exemple où l'on fait la somme de cellules et l'on donne le nom ``\verb-foo-'' au premier nombre et le nom ``\verb-bar-'' au dernier. On peut observer que \verbinline-tag(bar)- se trouve entre ``1'' et ``9'' et qu'au final, puisque cette macro fonction disparait, le champ numérique de la cellule contiendra ``19'' :
+
+\begin{minipage}{0.6\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{r@{}r}}
+ & 15tag(foo) \\
+@+ & 37 \\
+@+ & 13 \\
+@+ & 48 \\
+@+ & 1tag(bar)9 \\\cline{2-2}
+ & sum(cell(foo):cell(bar))tag(baz)
+\end{spreadtab}
+
+foo=\STtag{foo}, bar=\STtag{bar}, baz=\STtag{baz}
+\end{lstlisting}
+\end{minipage}\kern6pt%
+\begin{minipage}{0.3\linewidth}
+\begin{spreadtab}{{tabular}{r@{}r}}
+ & 15tag(foo) \\
+@+ & 37 \\
+@+ & 13 \\
+@+ & 48 \\
+@+ & 1tag(bar)9 \\\cline{2-2}
+ & sum(cell(foo):cell(bar))tag(baz)
+\end{spreadtab}
+
+foo=\STtag{foo}, bar=\STtag{bar}, baz=\STtag{baz}
+\end{minipage}
+
+Pour transmettre des valeurs entre tableaux calculés par \ST\footnote{Comme on l'avait demandé sur \href{https://tex.stackexchange.com/questions/210881}{\texttt{\textbf{tex.stackexchange}}}}, il est possible de taguer la cellule dans le premier tableau à l'aide de la macro fonction \verbinline|tag(<nom>)|, puis dans le 2\ieme{} tableau, de faire appel à la valeur \emph{via} tagguée par \verbinline|valtag(<nom>)|
+
+\begin{minipage}{.6\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{cc}}
+ 100 & a1+1tag{abcd}
+\end{spreadtab}
+
+\begin{spreadtab}{{tabular}{c}}
+ value{abcd}
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}\kern6pt
+\begin{minipage}{.3\linewidth}
+\begin{spreadtab}{{tabular}{cc}}
+ 100 & a1+1tag(abcd)
+\end{spreadtab}
+
+\begin{spreadtab}{{tabular}{c}}
+ value(abcd)
+\end{spreadtab}
+\end{minipage}
+
+Lorsque l'environnement \ST se trouve inclus dans un autre environnement, les affectations faites par la macro fonction \verb-tag- restent \emph{locales} à cet environnement et ne pourraient pas être accessibles en dehors de cet environnement via \verbinline-\STtag-. Dans l'exemple ci-dessous, le tableau fait par \ST est dans un environnement \verb-center- et l'on doit donc utiliser \verbinline-\STmakegtag{<nom>}- pour rendre global la sauvegarde de la valeur numérique contenus dans la cellule marquée par ``tag{<nom>}'' :
+
+\begin{minipage}{.6\linewidth}
+\begin{lstlisting}
+\begin{center}
+ \begin{spreadtab}{{tabular}{cccc}}\hline
+ 6&9&17&21\\\hline
+ \multicolumn{4}{c}{moyenne = :={sum(a1:d1)/4tag(moy)}}
+ \end{spreadtab}
+ \STmakegtag{moy}
+\end{center}
+La moyenne est de \STtag{moy}.
+\end{lstlisting}
+\end{minipage}\kern6pt
+\begin{minipage}{.3\linewidth}
+\begin{center}
+ \begin{spreadtab}{{tabular}{cccc}}\hline
+ 6&9&17&21\\\hline
+ \multicolumn{4}{c}{moyenne = :={sum(a1:d1)/4tag(moy)}}
+ \end{spreadtab}
+ \STmakegtag{moy}
+\end{center}
+La moyenne est de \STtag{moy}.
+\end{minipage}
+
+L'argument de \verbinline-\STmakegtag- peut êre constitué de plusieurs noms séparés par des virgules.
+
+Bien qu'elles soient à première vue moins utiles, \ST fournit également les macros fonctions ``\verbinline-row(<nom>)-'' et ``\verbinline-col(<nom>)-'' qui renvoient le numéro de la ligne ou de la colonne où se trouvait \verbinline-tag(<nom>)-. Voici par exemple une façon de dénombrer des valeurs pour en calculer la moyenne : on nomme ``un'' la première valeur et ``der'' la dernière, et le nombre de valeurs est donc row(der)-row(un)+1 :
+
+\begin{minipage}{0.6\linewidth}
+\begin{lstlisting}
+moyenne = \begin{spreadtab}{{tabular}[b]{r}}
+7tag(un)\\9\\15\\6\\20\\13\\11\\55tag(der)\\
+\hline
+sum(cell(un):cell(der))/(row(der)-row(un)+1)
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}\hfill
+\begin{minipage}{0.35\linewidth}
+moyenne = \begin{spreadtab}{{tabular}[b]{r}}
+7tag(un)\\9\\15\\6\\20\\13\\11\\55tag(der)\\
+\hline
+sum(cell(un):cell(der))/(row(der)-row(un)+1)
+\end{spreadtab}
+\end{minipage}
+
+\section{Précautions particulières}
+\subsection{Redéfinition des commandes de filets horizontaux}
+On peut être tenté de définir une commande pour produire ---~par exemple~--- une double ligne horizontale :\par\nobreak
+\begin{center}
+\verbinline-\newcommand\dline{\hline\hline}-
+\end{center}
+puis essayer de l'utiliser dans un tableau pour produire ce simple exemple qui calcule à la seconde ligne les termes de la suite de Fibonacci :\par\nobreak
+\begin{center}
+\newcommand\dline{\hline\hline}
+\begin{spreadtab}{{tabular}{*7c}}
+0 & 1 & 2 & 3 & 4 & 5 & 6 \\\dline
+:={1} & 1 & a2+b2 & b2+c2 & c2+d2 & d2+e2 & e2+f2
+\end{spreadtab}
+\end{center}
+Mais en écrivant ce code, il y a un problème :\par\nobreak
+\begin{lstlisting}
+\newcommand\dline{\hline\hline}
+\begin{spreadtab}{{tabular}{*7c}}
+0 & 1 & 2 & 3 & 4 & 5 & 6 \\\dline
+1 & 1 & a2+b2 & b2+c2 & c2+d2 & d2+e2 & e2+f2
+\end{spreadtab}
+\end{lstlisting}
+En effet la compilation échoue et dans le log, on peut lire que \verb-\FPeval- se plaint :\par
+\hfill\falseverb{! Improper alphabetic constant.}\hfill\null
+
+La raison est simple, c'est que le \verb-\dline- de la ligne 4, n'est \emph{pas} reconnu par \ST comme un filet horizontal et \emph{il se retrouve donc dans la cellule de la ligne suivante}. Pour \ST, cette cellule \falseverb{b1} contient :\par
+\hfill\falseverb{\dline 1}\hfill\null
+
+Comme il n'y a pas de \verb-@- ni de délimiteur de formule \verb-:={...}-, \verb-\FPeval- essaie vaillamment de calculer ce contenu et échoue évidemment !
+
+Pour pouvoir compiler ce code sans erreur, la cellule \falseverb{a2} \emph{doit} contenir un marqueur de champ numérique :\par\nobreak
+\begin{lstlisting}
+\newcommand\dline{\hline\hline}
+\begin{spreadtab}{{tabular}{*7c}}
+0 & 1 & 2 & 3 & 4 & 5 & 6 \\\dline
+:={1} & 1 & a2+b2 & b2+c2 & c2+d2 & d2+e2 & e2+f2
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\newcommand\dline{\hline\hline}
+\begin{spreadtab}{{tabular}{*7c}}
+0 & 1 & 2 & 3 & 4 & 5 & 6 \\\dline
+:={1} & 1 & a2+b2 & b2+c2 & c2+d2 & d2+e2 & e2+f2
+\end{spreadtab}
+\end{center}
+
+\subsection{Cohabitation de {\ttfamily\textbackslash multicolumn} et \ttfamily\textbackslash SThidecol}
+Tout d'abord, dans une utilisation normale, l'utilisation conjointe de \verbinline|\multicolumn| et \verbinline-\SThiderow- ne doit pas arriver, et la plupart des utilisateurs ne devrait pas rencontrer cette situation ni lire ce chapitre.
+
+Pour les courageux venons-en au c\oe ur du problème : tout d'abord, une colonne masquée ne doit \emph{jamais} contenir une cellule où se trouve la commande \verbinline-\multicolumn- ! Mais que se passe t-il si une colonne masquée cache des cellules fusionnées par \verbinline-\multicolumn-?
+
+Déjà, en général, il n'y a pas d'erreur de compilation ni message d'erreur, mais il y a quelques subtilités quant aux références qui sont un peu chamboulées dans la ligne concernée après le \verbinline-\multicolumn-\ldots
+
+Prenons un exemple, et mettons que dans le tableau suivant, on fusionne les cellules \falseverb{b2} à \falseverb{h2} et que l'on souhaite cacher les colonnes \falseverb{c}, \falseverb{d} et \falseverb{f}, ici en gris :\par\nobreak
+\begin{center}
+\ttfamily
+\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
+\hline
+ a1 & b1 & \cellcolor[gray]{0.6}c1 & \cellcolor[gray]{0.6}d1 & e1 & \cellcolor[gray]{0.6}f1 & g1 & h1 & i1 & j1\\\hline
+ a2 & \multicolumn1c{b2} & \multicolumn1{>{\cellcolor[gray]{0.6}}c}{} & \multicolumn1{>{\cellcolor[gray]{0.6}}c}{} & \multicolumn1c{} & \multicolumn1{>{\cellcolor[gray]{0.6}}c}{} & \multicolumn1{c}{} & \multicolumn1{c|}{} & i2 & j2\\\hline
+\end{tabular}
+\end{center}
+Il y a 4 cellules \emph{visibles} fusionnées, on écrira donc \verbinline-\multicolumn{4}- car on ne tient \emph{jamais} compte des colonnes masquées dans le décompte du nombre de cellules à fusionner.
+
+Maintenant, on compte 4 lettres à partir de la lettre \falseverb{b} en l'incluant dans le décompte. On arrive à la lettre \falseverb{e} : cela détermine un intervalle de colonnes «\falseverb{b-e}». Dans cet intervalle, 2 colonnes masquées sont incluses (\falseverb c et \falseverb d) et 1 colonne masquée n'est pas comprise (\falseverb f). Ces 2 nombres sont importants pour comprendre la suite, aussi, notons-les $x$ et $y$ dans le cas général.
+
+La règle est la suivante :
+\begin{itemize}
+ \item il faut rajouter $y$ signes «\verb-&-» après le \verbinline-\multicolumn- (pour l'exemple, il en faudrait 1).
+ \item les références des colonnes des cellules qui suivent le \verbinline-\multicolumn- seront décalées de $x$ lettres vers le début de l'alphabet. Pour l'exemple donnée, si on veut faire référence à la cellule marquée «\falseverb{i2}», il faudra écrire \falseverb{g2} (au lieu de \falseverb{i2}).
+\end{itemize}
+Voici un vrai exemple dont la structure est similaire au précédent : $x=2$ et $y=1$. Dans le code, remarquer le «\textcolor{red}{\texttt{\&}}» qui a été ajouté puisque $y=1$. Par ailleurs, on reste simple avec les formules, on ajoute 1 au nombre du dessus :\par\nobreak
+\begin{lstlisting}[escapechar=Z]
+\begin{spreadtab}{{tabular}{|*{7}{c|}}}
+\hline
+1 & 2 & \SThidecol3 & \SThidecol4 & 5& \SThidecol6 & 7& 8& 9 & 10 \\\hline
+a1+1& \multicolumn4{l|}{:={b1+1}}Z\ttfamily\color{red}\rlap\&Z & i1+1 & j1+1\\\hline
+a2+1& b2+1 & & & & & & & g2+1 & h2+1\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*{7}{c|}}}
+\hline
+1 & 2 & \SThidecol3 & \SThidecol4 & 5& \SThidecol6 & 7& 8& 9 & 10 \\\hline
+a1+1& \multicolumn4{l|}{:={b1+1}}& & i1+1 & j1+1\\\hline
+a2+1& b2+1 & & & & & & & g2+1 & h2+1\\\hline
+\end{spreadtab}
+\end{center}
+Voici encore un exemple similaire où une seule colonne est masquée (la colonne \falseverb d), et où $x=1$ et $y=0$ :\par\nobreak
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*{9}{c|}}}
+\hline
+1 & 2 & 3 & \SThidecol4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline
+a1+1& \multicolumn6{l|}{:={b1+1}} & i1+1 & j1+1\\\hline
+a2+1& b2+1 & & & & & & & h2+1 & i2+1\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*{9}{c|}}}
+\hline
+1 & 2 & 3 & \SThidecol4 & 5 & 6 & 7 & 8 & 9 & 10 \\\hline
+a1+1& \multicolumn6{l|}{:={b1+1}} & i1+1 & j1+1\\\hline
+a2+1& b2+1 & & & & & & & h2+1 & i2+1\\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Messages émis par \ST}
+Le package émet des messages d'erreur et arrête la compilation dans ces cas :
+\begin{itemize}
+ \item Pour calculer une cellule, on calcule de proche en proche des cellules qui par le jeu des références, reviennent sur la cellule d'origine (références circulaires). Dans ce cas, l'arbre des dépendances est affiché dans le message d'erreur;
+ \item une formule nécessitant un nombre fait référence à une cellule vide ou ne contenant que du texte;
+ \item une cellule fait référence à une cellule non définie (hors limite du tableau);
+ \item une cellule fait référence à une cellule fusionnée par un \verbinline-\multicolumn-;
+ \item une référence relative entre crochets ne respecte pas la syntaxe.
+\end{itemize}
+
+Le package peut émettre des messages d'information (dans le fichier de log), ce qu'il fait par défaut. La commande \verbinline-\STmessage- permet ou pas l'émission de messages d'information. Pour chacune des ces altenatives, la syntaxe est la suivante : \verbinline-\STmessage{true}- ou \verbinline-\STmessage{false}-.
+
+Pour comprendre la signification des messages, prenons un tableau simple :\par\nobreak
+\begin{minipage}{0.65\linewidth}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|cccc|c|}}\hline
+b1+1 & c1+1 & d1+1 & 10 & a1+b1+c1+d1\\\hline
+\end{spreadtab}
+\end{lstlisting}
+\end{minipage}%
+\begin{minipage}{0.35\linewidth}
+\centering
+\begin{spreadtab}{{tabular}{|cccc|c|}}\hline
+b1+1 & c1+1 & d1+1 & 10 & a1+b1+c1+d1\\\hline
+\end{spreadtab}
+\end{minipage}
+
+Le fonctionnement du tableau est ici très simple à comprendre. Voici les informations délivrées par \ST :\par\nobreak
+\begin{lstlisting}
+[spreadtab] New spreadtab {tabular}{|cccc|c|}
+* reading tab: ok
+* computing formulas:
+ cell A1-B1-C1
+ cell B1
+ cell C1
+ cell D1
+ cell E1
+* building tab: ok
+[spreadtab] End of spreadtab
+\end{lstlisting}
+L'environnement spécifié par l'utilisateur est repris entre parenthèses (ici \verbinline-{tabular}{|cccc|c|}-). Précédées d'une étoile, on retrouve les 3 étapes nécessaires à \ST pour mener à bien sa mission : lecture du tableau, calcul des formules et construction du tableau final.
+
+Pour la seconde étape, les cellules sont évaluées de haut en bas, de gauche à droite : \ST indique qu'il commence par essayer de calculer la première cellule \falseverb{A1}. Pour cela, il indique qu'il doit d'abord évaluer \falseverb{B1} et avant cela encore, évaluer \falseverb{C1}. Comme il n'y a plus de cellule après \falseverb{C1}, c'est qu'elle peut être évaluée; en effet, elle ne dépend que de \falseverb{D1} qui est un nombre égal à 10.
+
+Pour chaque ligne suivante, il n'y a qu'une seule cellule ce qui signifie que lorsque \ST essaie de les évaluer, elles l'ont déjà été et sont des nombres ou alors, elles ne font références qu'à des cellules déjà calculées.
+
+\subsection{Débogage}
+Pour faciliter l'utilisation de \ST, un mode de débogage est disponible. Il est activé lorsque la commande \verbinline-\STdebug- est présente dans l'argument optionnel de l'environnement \verb-spreadtab-. Cette commande change le comportement de \ST qui, au lieu d'afficher le tableau final, affiche un (ou plusieurs) tableau de débogage. Cet affichage se fait juste après que \ST ait lu l'ensemble de toutes les cellules ; aucun calcul de formule n'a encore eu lieu. Il y a autant de tableaux affichés que de commande \verbinline-\STdebug- présentes, sous réserve que leur argument soit différent. Seuls 3 arguments sont possibles, et voici ce qu'il permettent :
+\begin{itemize}
+ \item \verbinline-\STdebug{formula}- : affichage des champs numériques de toutes les cellules et les fins de ligne;
+ \item \verbinline-\STdebug{text}- : affichage des champs textuels de toutes les cellules;
+ \item \verbinline-\STdebug{code}- : affichage du code interne que \ST affecte à chaque cellule. Ce code interne est assigné à chaque cellule lors de la lecture du tableau. Il vaut :
+ \begin{enumerate}[label=\small\textbullet]
+ \item $-1$ s'il s'agit d'une cellule fusionnée par une commande \verbinline-\multicolumn-;
+ \item 0 si la cellule est vide ou purement textuelle;
+ \item 1 si le champ numérique de la cellule contient une formule qui sera à évaluer plus tard;
+ \item 2 si la champ numérique de la cellule contient un nombre.
+ \end{enumerate}
+\end{itemize}
+
+Lorsque le mode débogage est activé, le tableau final \emph{n'est pas affiché}. Il est cependant possible de forcer cet affichage en mettant la commande \verbinline-\STdisplaytab- dans l'argument optionnel.
+
+Voici un tableau sur lequel s'appuiera l'exemple suivant :
+
+\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}
+On va demander à ce que \ST affiche les 3 tableaux de débogage possibles concernant le tableau ci-dessus. Pour cela, il suffit de modifier la ligne 1 du code ci-dessus comme ceci :
+
+\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}
+Ces 3 tableaux de débogage peuvent aider à comprendre un peu mieux le fonctionnement interne de \ST. On peut observer dans le tableau 2 que toutes les cellules ayant un champ numérique ont un code interne de 1 ou 2 (voir tableau 3) et ont un marqueur de champ numérique "\verb-:=-" qui leur est associé (voir tableau 1). Ce marqueur représente l'endroit où sera inséré ---~par substitution~--- le résultat du calcul du champ numérique. C'est donc à partir des contenus des champs textuels du tableau 1 et par simple substitution, qu'une fois les champs numériques calculés, les cellules sont reconstituées pour donner celles du tableau final.
+
+Dans les tableaux ci-dessus, les cellules contenant les coordonnées ne sont grisées que si le package \href{http://www.ctan.org/tex-archive/macros/latex/contrib/colortbl/}{\texttt{\textbf{colortbl}}} a été chargé.
+
+\section{Exemples}
+Voici quelques tableaux pour finir !
+
+Afin que l'on sache quels nombres sont calculés, seuls les nombres non calculés sont en \textcolor{red}{rouge}. Dans ces tableaux, beaucoup d'artifices (des struts, des multicolumn) et des packages (notamment numprint et ses colonnes «N» qui alignent les séparateurs décimaux) ont été utilisés pour obtenir un résultat satisfaisant. Le code est parfois lourd et peu lisible, mais il ne s'agit pas ici d'exemples basiques mais de tableaux peaufinés !
+
+\subsection{Encore un triangle de Pascal}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{*7r}}
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]\\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & & & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & & & \\
+[0,1] & [-1,1] & & & & & \\
+\color{red}:={1}& & & & & &
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{*7r}}
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]\\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & & \\
+[0,1] & [-1,1]+[0,1] & [-1,1]+[0,1] & [-1,1] & & & \\
+[0,1] & [-1,1]+[0,1] & [-1,1] & & & & \\
+[0,1] & [-1,1] & & & & & \\
+\color{red}:={1}& & & & & &
+\end{spreadtab}
+\end{center}
+
+\subsection{Convergence d'une série}
+Pour les matheux, il s'agit du développement limité de la fonction exponentielle en \numprint{0.5}. En effet,
+\[\forall x\in \mathbf{R}\qquad e^x=\sum_{k=0}^\infty\frac{x^k}{k!}\]
+et le tableau illustre la rapidité de la convergence au fur et à mesure de l'ordre du développement limité.\par\nobreak
+\begin{lstlisting}
+\STautoround{15}
+\renewcommand\STprintnum[1]{\numprint{#1}}
+\begin{spreadtab}{{tabular}{cc}}
+\multicolumn{2}{c}{Convergence en $x=\color{red}:={0.5}$}\\[1.5ex]
+@$n$ & e^a1\SThidecol & @ $\displaystyle e^{\numprint{<<a1>>}}-\sum_{k=0}^n\frac{\numprint{<<a1>>}^k}{k!}$\\[3ex]\hline
+\color{red}:={0}& a1^[-1,0]/fact([-1,0]) & \STcopy{v}{b!2-b3}\\
+\STcopy{v}{a3+1}& \STcopy{v}{a!1^a4/fact(a4)+b3}& \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\STautoround{15}
+\renewcommand\STprintnum[1]{\numprint{#1}}
+\begin{spreadtab}{{tabular}{cc}}
+\multicolumn{2}{c}{Convergence en $x=\color{red}:={0.5}$}\\[1.5ex]
+@$n$ & exp(a1)\SThidecol & @ $\displaystyle e^{\numprint{<<a1>>}}-\sum_{k=0}^n\frac{\numprint{<<a1>>}^k}{k!}$\\[3ex]\hline
+\color{red}:={0}& a1^[-1,0]/fact([-1,0]) & \STcopy{v}{b!2-b3}\\
+\STcopy{v}{a3+1}& \STcopy{v}{a!1^a4/fact(a4)+b3}& \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\
+ & & \\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Convergence vers le nombre d'or}
+Voici la définition des nombres de Fibonacci : $F_0=1\qquad F_1=1\qquad F_{n+2}=F_{n+1}+F_n$
+
+On va mettre ici en évidence que le quotient de 2 nombres de Fibonacci consécutifs $F_n$ et $F_{n-1}$ tend vers le nombre d'or $\varphi=\frac{1+\sqrt{5}}{2}$ de telle sorte que la suite $u_n=\varphi-\frac{F_n}{F_{n-1}}$ soit alternativement positive et négative.\par\nobreak
+\begin{lstlisting}
+\STautoround{9}
+$\begin{spreadtab}{{array}{ccN39N{3}{9}}}
+@n & @F_n & @\hfill{\dfrac{F_n}{F_{n-1}}}\hfill\null& @\hfill{\varphi-\dfrac{F_n}{F_{n-1}}}\hfill\null\\[2ex]\hline
+\color{red}:=1 & \color{red}:=1 & & \\
+\STcopy{v}{a2+1} & \color{red}:=1 & \STcopy{v}{b3/b2} & (1+5^0.5)/2-[-1,0] \\
+ & \STcopy{v}{b2+b3} & & \STcopy{v}{d!3+1-c4} \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\\hline
+\end{spreadtab}$
+\end{lstlisting}
+\begin{center}
+\STautoround{9}
+$\begin{spreadtab}{{array}{ccN39N{3}{9}}}
+@n & @F_n & @\hfill{\dfrac{F_n}{F_{n-1}}}\hfill\null& @\hfill{\varphi-\dfrac{F_n}{F_{n-1}}}\hfill\null\\[2ex]\hline
+\color{red}:=1 & \color{red}:=1 & & \\
+\STcopy{v}{a2+1} & \color{red}:=1 & \STcopy{v}{b3/b2} & (1+5^0.5)/2-[-1,0] \\
+ & \STcopy{v}{b2+b3} & & \STcopy{v}{d!3+1-c4} \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\
+ & & & \\\hline
+\end{spreadtab}$
+\end{center}
+
+\subsection{Tableau de facturation}
+Voici un tableau de facturation, où les séparateurs décimaux sont alignés dans les colonnes grâce au spécificateur de colonne «N» du package \falseverb{numprint}.
+
+Ce tableau est généré par l'environnement \verb=tabularx= de façon à occuper 80\% de la largeur de la ligne. La commande \verbinline=\multicolumn= a été largement utilisée pour la mise en forme :\par\nobreak
+\begin{lstlisting}
+\nprounddigits2
+\let\PC\%
+\newcommand\Mystrut{\rule[-1.2ex]{0pt}{4ex}}
+\newcommand\RED{\color{red}}
+\begin{spreadtab}{{tabularx}{0.8\linewidth}{|>\Mystrut X>\RED N42>\RED c N42>\RED c<\PC N42|}}
+\hline
+@D\'esignation &@\multicolumn1c{Prix U}& @\multicolumn1c{Qt\'e} & @\multicolumn1c{Prix} & @\multicolumn1c{R\'eduction} & @\textbf{\`A payer}\\\hline
+@Item 1 & 5.99 & 20 & [-2,0]*[-1,0] & $-:={20}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 2 & 12 & 7 & [-2,0]*[-1,0] & $-:={10}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 3 & 4.50 & 40 & [-2,0]*[-1,0] & $-:={35}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 4 & 650 & 2 & [-2,0]*[-1,0] & $-:={15}$ & [-2,0]*(1-[-1,0]/100)\\\hline
+@\multicolumn6c{}\\[-1.5ex]\cline{4-6}% ligne vide et on remonte un peu !
+@\multicolumn1c{\Mystrut}&@\multicolumn2{r|}{\textbf{Total}}& sum(d2:[0,-2]) & \multicolumn1c{$:={round(([1,0]/[-1,0]-1)*100,0)}\PC$} & {\fontseries{b}\selectfont}:={sum(f2:[0,-2])}\\
+\cline{4-6}
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\nprounddigits2
+\let\PC\%
+\newcommand\Mystrut{\rule[-1.2ex]{0pt}{4ex}}
+\newcommand\RED{\color{red}}
+\begin{spreadtab}{{tabularx}{0.8\linewidth}{|>\Mystrut X>\RED N42>\RED c N42>\RED c<\PC N42|}}
+\hline
+@D\'esignation &@\multicolumn1c{Prix U}& @\multicolumn1c{Qt\'e} & @\multicolumn1c{Prix} & @\multicolumn1c{R\'eduction} & @\textbf{\`A payer}\\\hline
+@Item 1 & 5.99 & 20 & [-2,0]*[-1,0] & $-:={20}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 2 & 12 & 7 & [-2,0]*[-1,0] & $-:={10}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 3 & 4.50 & 40 & [-2,0]*[-1,0] & $-:={35}$ & [-2,0]*(1-[-1,0]/100)\\
+@Item 4 & 650 & 2 & [-2,0]*[-1,0] & $-:={15}$ & [-2,0]*(1-[-1,0]/100)\\\hline
+@\multicolumn6c{}\\\cline{4-6}% ligne vide et on remonte un peu !
+@\multicolumn1c{\Mystrut}&@\multicolumn2{r|}{\textbf{Total}}& sum(d2:[0,-2]) & \multicolumn1c{$:={round(([1,0]/[-1,0]-1)*100,0)}\PC$} & {\fontseries{b}\selectfont}:={sum(f2:[0,-2])}\\
+\cline{4-6}
+\end{spreadtab}
+\end{center}
+
+\subsection{Carré magique}
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{|*3{>{\hfill\rule[-0.4cm]{0pt}{1cm}$}m{0.7cm}<{$\hfill\null}|}}}
+\hline
+\color{red}:=2 & 5*b2-4*a1 & 3*a1-2*b2 \\\hline
+2*a1-b2 & \color{red}:={-1} & 3*b2-2*a1 \\\hline
+4*b2-3*a1 & 4*a1-3*b2 & 2*b2-a1 \\\hline
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{|*3{>{\hfill\rule[-0.4cm]{0pt}{1cm}$}m{0.7cm}<{$\hfill\null}|}}}
+\hline
+\color{red}:=2 & 5*b2-4*a1 & 3*a1-2*b2 \\\hline
+2*a1-b2 & \color{red}:={-1} & 3*b2-2*a1 \\\hline
+4*b2-3*a1 & 4*a1-3*b2 & 2*b2-a1 \\\hline
+\end{spreadtab}
+\end{center}
+
+\subsection{Pyramide additive}
+Chaque nombre est la somme des deux nombres se trouvant au dessous de lui.\par\nobreak
+\begin{lstlisting}
+\newlength\cellsize
+\setlength\cellsize{1.5cm}
+\newcolumntype{K}{@{}>{\rule{0pt}{2.5ex}\centering\arraybackslash$}p{\cellsize}<$@{}}
+\begin{spreadtab}{{tabular}{*{8}{@{}p{.5\cellsize}@{}}}}
+\cline{4-5}
+&&&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&&&\\\cline{3-6}
+&&\multicolumn{2}{|K}{:={[-1,1]+[1,1]}}&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&&\\\cline{2-7}
+&\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{lstlisting}
+\begin{center}
+\newlength\cellsize
+\setlength\cellsize{1.5cm}
+\newcolumntype{K}{@{}>{\rule{0pt}{2.5ex}\centering\arraybackslash$}p{\cellsize}<$@{}}
+\begin{spreadtab}{{tabular}{*{8}{@{}p{.5\cellsize}@{}}}}
+\cline{4-5}
+&&&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&&&\\\cline{3-6}
+&&\multicolumn{2}{|K}{:={[-1,1]+[1,1]}}&\multicolumn{2}{|K|}{:={[-1,1]+[1,1]}}&&\\\cline{2-7}
+&\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
+\parskip0pt
+\begin{center}
+$\star$\par
+$\star\quad\star$
+\end{center}
+C'est tout, j'espère que cette extension vous sera utile !\par\nobreak\medskip
+
+Je vous remercie d'avance de me signaler par \href{mailto:unbonpetit@netc.fr}{\texttt{\textbf{email}}} tout bug, toute macro-fonction à implémenter que vous pensez utile ou toute proposition d'amélioration \emph{réaliste} : il ne faut pas oublier que cette extension doit rester modeste, que \ST n'est pas excel ou calc et qu'il est impossible d'implémenter toutes les fonctionnalités avancées de ces tableurs.\par\nobreak\bigskip
+Christian \textsc{Tellechea}
+\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/spreadtab/spreadtab.sty b/macros/latex/contrib/spreadtab/spreadtab.sty
new file mode 100644
index 0000000000..3ae130e9fa
--- /dev/null
+++ b/macros/latex/contrib/spreadtab/spreadtab.sty
@@ -0,0 +1,2193 @@
+% !TeX encoding = ISO-8859-1
+% Ce fichier contient le code de l'extension "spreadtab"
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+\def\STname {spreadtab} %
+\def\STver {0.5} %
+% %
+\def\STdate {2019/02/27} %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% Author : Christian Tellechea %
+% Status : Maintained %
+% Maintainer : Christian Tellechea %
+% Email : unbonpetit@netc.fr %
+% Package URL: https://www.ctan.org/pkg/spreadtab %
+% Bug tracker: https://framagit.org/unbonpetit/spreadtab/issues %
+% Repository : https://framagit.org/unbonpetit/spreadtab/tree/master %
+% Copyright : Christian Tellechea 2009-2019 %
+% Licence : Released under the LaTeX Project Public License v1.3c %
+% or later, see http://www.latex-project.org/lppl.txt %
+% Files : 1) spreadtab.sty %
+% 2) spreadtab-fr.tex %
+% 3) spreadtab-fr.pdf %
+% 4) spreadtab-en.tex %
+% 5) spreadtab-en.pdf %
+% 6) README %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\ProvidesPackage{spreadtab}[\STdate\space v\STver\space Spreadsheet features for table environments (CT)]
+\NeedsTeXFormat{LaTeX2e}
+\def\ST@cslet#1#2{\expandafter\let\expandafter#1\csname#2\endcsname}
+\RequirePackage{xstring}[2013/07/29]% version nécessaire
+
+% liste des fonctions dont l'argument est numérique
+\def\ST@functions@with@num@arg{%
+ id,fact,ifeq,ifgt,iflt,numtofrshortdate,numtoengshortdate,numtofrlongdate,gcd,lcm,%
+ numtoenglongdate,numtofrmonth,numtoengmonth,numtofrday,numtoengday}
+
+% liste des fonctions dont l'argument est un texte
+\def\ST@functions@with@text@arg{frshortdatetonum,engshortdatetonum,englongdatetonum,frlongdatetonum,scitodec,tag,row,col,cell,value}
+
+% liste des fonctions dont l'argument ne doit pas être calculé
+\def\ST@functions@no@calc@arg{ifeq,ifgt,iflt,gcd,lcm,value}
+
+% liste des fonctions dont l'argument est une variable -> il ne faut donc pas aller chercher des références dans l'argument
+\def\ST@functions@with@assign@argument{tag,row,col,cell,value}
+
+% liste des fonctions dont le résultat est un texte
+\def\ST@functions@with@textresult{%
+ numtofrshortdate,numtoengshortdate,numtofrlongdate,numtoenglongdate,%
+ numtofrmonth,numtoengmonth,numtofrday,numtoengday}
+
+% liste totale des fonctions
+%\edef\ST@functions@list{\ST@functions@with@range@arg,\ST@functions@with@num@arg,\ST@functions@with@text@arg}
+
+\newif\if@fp \@fpfalse
+\newif\if@xfp\@xfpfalse
+\newif\if@STfpactive
+\def\STusefp {\PackageError\STname{The FP package is not loaded, you cannot select it with \string\STusefp}{Please, read the manual.}}
+\def\STusexfp{\PackageError\STname{The xfp package is not loaded, you cannot select it with \string\STusexfp}{Please, read the manual.}}
+\DeclareOption{fp}{\@fptrue}
+\DeclareOption{xfp}{\@xfptrue}
+\DeclareOption*{\PackageWarning{spreadtab}{Unknown "\CurrentOption"}}
+
+\ProcessOptions\relax
+\ifnum0\if@fp1\fi\if@xfp1\fi=0 \@fptrue\fi% charger fp si aucune option
+\if@fp\expandafter\@firstofone\else\expandafter\@gobble\fi% car les \fi ne sont pas équilibrés
+{ \RequirePackage{fp}%
+ \def\STusefp{%
+ \let\STeval\FPeval
+ \let\STround\FPround
+ \let\STclip\FPclip
+ \let\STtrunc\FPtrunc
+ \let\STadd\FPadd
+ \let\STmul\FPmul
+ \let\STdiv\FPdiv
+ \def\STseed{\FPseed\number\time\number\day\number\month}%
+ \let\STrandom\FPrandom
+ \let\STifzero\FPifzero
+ \let\STifgt\FPifgt
+ \let\STiflt\FPiflt
+ \let\STifeq\FPifeq
+ \let\STifint\FPifint
+ \def\STifneg##1{\STiflt{##1}{0}}%
+ \def\ST@functions@with@range@arg{sum,randint,rand,sumprod}% liste des fonctions dont l'argument est une plage ou est vide
+ \edef\ST@functions@list{\ST@functions@with@range@arg,\ST@functions@with@num@arg,\ST@functions@with@text@arg}% liste totale des fonctions
+ % Calcule la factorielle du nombre ##1 et met le résultat dans la sc ##2
+ \def\ST@func@fact##1##2{%
+ \edef##2{%
+ \ifcase##1 1\or1\or2\or6\or24\or120\or720\or5040\or40320\or362880\or3628800\or39916800\or479001600\or
+ 6227020800\or87178291200\or1307674368000\or20922789888000\or355687428096000\or6402373705728000\else
+ -1%
+ \fi}%
+ }%
+ \message{\STname\space message: FP calc engine now active}%
+ \@STfpactivetrue
+ }%
+ \STusefp
+}
+\if@xfp
+ \RequirePackage{xfp}%
+ \ExplSyntaxOn
+ \def\STusexfp{
+ \def\STeval##1##2{\edef##1{\fpeval{##2}}}
+ \def\STround##1##2##3{\edef##1{\fpeval{round(##2,##3)}}}
+ \def\STclip##1##2{}%
+ \def\STtrunc##1##2##3{\edef##1{\fpeval{trunc(##2,##3)}}}
+ \def\STadd##1##2##3{\edef##1{\fpeval{##2+##3}}}
+ \def\STmul##1##2##3{\edef##1{\fpeval{##2*##3}}}
+ \def\STdiv##1##2##3{\edef##1{\fpeval{##2/##3}}}
+ \let\STseed\relax
+ \def\STrandom##1{\edef##1{\fpeval{rand()}}}
+ \ST@cslet\ST@iftrue{iftrue}\ST@cslet\ST@iffalse{iffalse}
+ \def\STifgt##1##2{\fp_compare:nNnTF{##1}>{##2}\ST@iftrue\ST@iffalse}
+ \def\STiflt##1##2{\fp_compare:nNnTF{##1}<{##2}\ST@iftrue\ST@iffalse}
+ \def\STifeq##1##2{\fp_compare:nNnTF{##1}={##2}\ST@iftrue\ST@iffalse}
+ \def\STifint ##1{\fp_compare:nNnTF{##1-trunc(##1,0)}={0}\ST@iftrue\ST@iffalse}
+ \def\STifzero##1{\STifeq{##1}{0}}
+ \def\STifneg##1{\STiflt{##1}{0}}
+ \ifdefined\XeTeXrevision% si on compile avec XeLaTeX
+ \ifdefined\uniformdeviate\else% avec une version trop ancienne ( < TL13 ?)
+ \PackageWarning\STname{With this version of XeLaTeX, functions rand and randint are not available}
+ \fi
+ \fi
+ \def\ST@functions@with@range@arg{sum,sumprod}
+ \edef\ST@functions@list{\ST@functions@with@range@arg,\ST@functions@with@num@arg,\ST@functions@with@text@arg}% liste totale des fonctions
+ \def\ST@func@fact##1##2{
+ \bool_if:nTF{ \fp_compare_p:nNn {##1}>{-1} && \fp_compare_p:nNn {##1-trunc(##1,0)}={0} }
+ {\def##2{1}\def\ST@factcntt{0}
+ \fp_do_while:nNnn {\ST@factcntt}<{##1}
+ {\edef\ST@factcntt{\number\numexpr\ST@factcntt+1}
+ \edef##2{##2*\ST@factcntt}%
+ }
+ \edef##2{\fpeval{##2}}
+ }
+ {\ST@fact@outofrange}
+ }
+ \message{\STname~message:~xfp~calc~engine~now~active}
+ \@STfpactivefalse
+ }
+ \ExplSyntaxOff
+ \if@fp\else\expandafter\expandafter\expandafter\STusexfp\fi
+\fi
+
+\newcount\ST@count
+\newcount\ST@colcount
+\newcount\ST@colcount@i
+\newcount\ST@rowcount
+\newcount\ST@rowcount@i
+\newcount\ST@intpart
+
+\newif\ifST@hiddencol
+\newif\ifST@debugmode
+\newif\ifST@colortblloaded
+\AtBeginDocument{\@ifpackageloaded{colortbl}\ST@colortblloadedtrue\ST@colortblloadedfalse}
+
+% Définit le marqueur qui signale le commencement du champ numérique
+\def\STnumericfieldmarker{:=}
+
+% Définit la macro qui va afficher les valeurs numériques dans le tableau
+\def\STprintnum#1{#1}
+
+% Définit les caractères entre lesquels doivent entre enveloppées les références des cellules
+% que l'on veut afficher dans les champs textuels
+\def\STsetdisplaymarks#1#2{\def\ST@startdisplay{#1}\def\ST@enddisplay{#2}}
+\STsetdisplaymarks{<<}{>>}% délimiteurs par défaut
+
+% définit le marqueur qui signale une cellule de texte
+\edef\STtextcell{\string @}
+
+% Commande qui permet à l'utilisateur de définir le caractère qui conserve une référence lors de la copie d'une formule
+\AtBeginDocument{\def\STtransposecar{!}}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Messages d'erreur %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newif\ifST@message
+
+\def\STmessage#1{\csname ST@message#1\endcsname}
+
+\def\ST@emit@message#1{\ifST@message\message{#1}\fi}
+
+\def\STseedoc@i{Please, read the manual.}
+
+\def\ST@circular@reference{%
+ \ST@coord@toref\ST@coord
+ \let\ST@deptree\@empty
+ \ST@show@dependance@tree
+ \PackageError\STname{circular reference found in cell \ST@coord!^^J
+ Here is its dependant cells: \ST@deptree}\STseedoc@i
+}
+
+\def\ST@undefined@cell{%
+ \ST@coord@toref\ST@temp@callcell
+ \ST@coord@toref\ST@coord
+ \PackageError\STname{Undefined reference!^^J
+ Cell \ST@temp@callcell\space contains a reference to an undefined cell: \ST@coord}\STseedoc@i
+}
+
+\def\ST@zerocodecell@cell{%
+ \ST@coord@toref\ST@temp@callcell
+ \ST@coord@toref\ST@coord
+ \PackageError\STname{A reference to a non-numeric or empty cell is not allowed!^^J
+ Cell \ST@temp@callcell\space contains a reference to an empty or text cell: \ST@coord}\STseedoc@i
+}
+
+\def\STmulticol@cell{%
+ \ST@coord@toref\ST@temp@callcell
+ \ST@coord@toref\ST@coord
+ \PackageError\STname{Cell \ST@temp@callcell\space contains a reference to a merged
+ \string\multicolumn\space cell: \ST@coord}\STseedoc@i
+}
+
+\def\ST@illegal@relativeref{%
+ \edef\ST@temp@callcell{\ST@current@colnumber,\ST@current@rownumber}%
+ \ST@coord@toref\ST@temp@callcell
+ \PackageError\STname{Illegal relative reference found in cell \ST@temp@callcell!}\STseedoc@i
+}
+
+\def\ST@illegal@ref{\PackageError\STname{Illegal reference in \string\STsavecell!}\STseedoc@i}
+
+\def\ST@unmatch@matrixdim{%
+ \edef\ST@temp@callcell{\ST@current@colnumber,\ST@current@rownumber}%
+ \ST@coord@toref\ST@temp@callcell
+ \PackageError\STname{Somprod dimension of matrix do not match in cell \ST@temp@callcell!}\STseedoc@i
+}
+
+\def\ST@fact@outofrange{\PackageError\STname{Argument of fact is not integer or is out of range!}\STseedoc@i}
+
+\def\ST@invalid@date{%
+ \edef\ST@temp@callcell{\ST@current@colnumber,\ST@current@rownumber}%
+ \ST@coord@toref\ST@temp@callcell
+ \PackageError\STname{Invalid date in cell \ST@temp@callcell.}\STseedoc@i
+}
+
+\def\ST@invalid@range{%
+ \edef\ST@temp@callcell{\ST@current@colnumber,\ST@current@rownumber}%
+ \ST@coord@toref\ST@temp@callcell
+ \PackageError\STname{Invalid range in cell \ST@temp@callcell.}\STseedoc@i
+}
+
+\def\ST@invalidSTcopy{%
+ \edef\ST@temp@callcell{\ST@current@colnumber,\ST@current@rownumber}%
+ \ST@coord@toref\ST@temp@callcell
+ \PackageError\STname{Numeric field marker found, \string\STcopy\space forbidden in cell \ST@temp@callcell.}\STseedoc@i
+}
+
+\def\ST@unknown@tag{%
+ \edef\ST@temp@callcell{\ST@current@colnumber,\ST@current@rownumber}%
+ \ST@coord@toref\ST@temp@callcell
+ \PackageError\STname{Undefined tag in cell \ST@temp@callcell.}\STseedoc@i
+}
+
+\def\ST@intarg@required{\PackageError\STname{Macro function randint require integer argument}\STseedoc@i}
+
+% transforme la chaine de cellules "(1,3)(4,5)(3,2)(1,3)" rencontré en référence circulaire en "A3-D5-C2-A3"
+\def\ST@show@dependance@tree{%
+ \ST@between\ST@dependance@tree()\ST@currentref
+ \ST@right\ST@dependance@tree)\ST@dependance@tree
+ \ST@coord@toref\ST@currentref
+ \ST@expadd@tomacro\ST@deptree\ST@currentref
+ \unless\ifx\@empty\ST@dependance@tree
+ \STadd@tomacro\ST@deptree-%
+ \expandafter\ST@show@dependance@tree
+ \fi
+}
+
+% transforme la séquence de contrôle #1 qui contient par exemple «4,5» en «D5»
+\def\ST@coord@toref#1{%
+ \ST@split#1,\ST@temp@a#1%
+ \edef#1{\ifcase\ST@temp@a\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
+ N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\fi#1}%
+}
+
+\def\ST@illegal@copy{\PackageError\STname{Illegal reference in copied formula!}\STseedoc@i}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%% Macros d'affectation et d'expansion %%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\ST@letname#1{\expandafter\let\csname#1\endcsname}
+
+\def\ST@exp@two@args#1#2#3{%
+ \def\ST@tmp@{#1}%
+ \ST@expadd@tomacro\ST@tmp@{\expandafter{#2}}%
+ \ST@expadd@tomacro\ST@tmp@{\expandafter{#3}}%
+ \ST@tmp@
+}
+
+\def\STadd@tomacro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
+
+\def\ST@expadd@tomacro#1#2{\expandafter\STadd@tomacro\expandafter#1\expandafter{#2}}
+
+\def\ST@edefadd@tomacro#1#2{\edef#1{\unexpanded\expandafter{#1}#2}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%% Macros de manipulation de chaines %%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\ST@gobble@remain{% mange tous jusqu'à \ST@nil. Méthode LENTE privilégiée car il peut y avoir des ) de catcode 2 isolées
+ \afterassignment\ST@gobble@remain@i
+ \let\ST@toks=
+}
+\def\ST@gobble@remain@i{\unless\ifx\ST@toks\ST@nil\expandafter\ST@gobble@remain\fi}
+
+\def\ST@splitatfirstcar#1#2#3{%
+ \def\ST@splitatfirstcar@i##1##2\@nil{\def#2{##1}\def#3{##2}}%
+ \expandafter\ST@splitatfirstcar@i#1\@nil
+}
+
+% dans la sc #1, remplace le . par le séparateur décimal
+\def\ST@substdecsep#1{%
+ \ST@Ifinstr#1.
+ {\expandafter\ST@substdecsep@i\expandafter#1\expandafter{\ST@decsep}}
+ {}%
+}
+\def\ST@substdecsep@i#1#2{%
+ \def\ST@substdecsep@ii##1.##2\@nil{\def#1{##1#2##2}}%
+ \expandafter\ST@substdecsep@ii#1\@nil
+}
+
+% enlève tous les espaces de la sc #1 et assigne le résultat à #1
+\def\ST@remove@firST@spaces#1{%
+ \IfBeginWith#1\space
+ {\StrGobbleLeft#11[#1]\ST@remove@firST@spaces{#1}}%
+ {}%
+}
+
+\def\ST@keep@firstcar#1{% on ne garde dans la sc #1 que le 1er caractère de la sc #1 ou on enlève les accolades
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter#1\expandafter\expandafter\expandafter{\expandafter\@car#1\@nil}%
+}
+
+\def\ST@firstarg@after#1#2#3{% assigne à la sc #3 l'argument qui suit #2 dans le développement de la sc #1
+ \def\ST@firstarg@after@i##1#2##2##3\@nil{\def#3{##2}}%
+ \expandafter\ST@firstarg@after@i#1\@nil
+}
+
+\def\ST@thirdarg@after#1#2#3{% assigne à la sc #3 le 3è argument qui suit #2 dans le développement de la sc #1
+ \def\ST@thirdarg@after@i##1#2##2##3##4##5\@nil{\def#3{##4}}%
+ \expandafter\ST@thirdarg@after@i#1\@nil
+}
+
+% est ce que la sc #1 contient la sc #2 ?
+\def\ST@Ifinstr#1#2{\ST@exp@two@args\ST@Ifinstr@i{#1}{#2}}
+\def\ST@Ifinstr@i#1#2{%
+ \def\ST@Ifinstr@ii##1#2##2\@nil{\ifx\@empty##2\@empty\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}%
+ \ST@Ifinstr@ii#1\@@nil#2\@nil
+}
+
+% Est ce que la sc #1 commence par les caractères #2 ?
+\def\ST@Iffirstis#1#2{%
+ \expandafter\ST@Ifinstr@i\expandafter{#1}{#2}%
+ {\def\ST@Iffirstis@i##1#2##2\@nil{%
+ \ifx\@empty##1\@empty\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
+ }%
+ }%
+ {\def\ST@Iffirstis@i##1\@nil{\@secondoftwo}}%
+ \expandafter\ST@Iffirstis@i#1\@@nil#2\@nil
+}
+
+% Coupe la sc #1 au caractère #2
+% ce qui est avant est assigné à #3 et ce qui est après à #4
+\def\ST@split#1#2#3#4{%
+ \def\ST@split@i##1#2##2\@nil{\def#3{##1}\def#4{##2}}%
+ \expandafter\ST@split@i#1\@nil
+}
+
+% Dans la sc #1, assigne ce qui est avant le développement de la sc #2 à la sc #3
+\def\ST@left#1#2#3{\ST@exp@two@args\ST@left@i{#1}{#2}#3}
+\def\ST@left@i#1#2#3{%
+ \def\ST@left@ii##1#2##2\@nil{\def#3{##1}}%
+ \ST@left@ii#1\@nil
+}
+
+% Dans la sc #1, assigne ce qui est après le développement de la sc #2 à la sc #3
+\def\ST@right#1#2#3{\ST@exp@two@args\ST@right@i{#1}{#2}#3}
+\def\ST@right@i#1#2#3{%
+ \def\ST@right@ii##1#2##2\@nil{\def#3{##2}}%
+ \ST@right@ii#1\@nil
+}
+
+% Dans la sc #1, assigne à la sc #4 ce qui est entre les caractères #2 et #3
+\def\ST@between#1#2#3#4{%
+ \def\ST@between@i##1#2##2#3##3\@nil{\def#4{##2}}%
+ \expandafter\ST@between@i#1\@nil
+}
+
+% Dans la sc #1, substitue la première occurrence du pattern #2 par le pattern #3
+\def\ST@subST@once#1#2#3{%
+ \def\ST@subST@once@i##1#2##2\@nil{\def#1{##1#3##2}}%
+ \ST@Ifinstr#1{\@empty#2}
+ {\expandafter\ST@subST@once@i#1\@nil}
+ {}%
+}
+
+% Dans la sc #1, substitue le pattern #2 par le pattern #3
+\def\ST@subst#1#2#3{%
+ \def\ST@subST@i##1#2##2\@nnil{%
+ \ifx\@empty##2\@empty
+ \def#1{##1}\expandafter\remove@to@nnil
+ \else
+ \expandafter\ST@subST@i
+ \fi
+ ##1#3##2\@nnil
+ }%
+ \expandafter\ST@subST@i#1#2\@nnil
+}
+
+\def\ST@expsubst#1#2#3{\ST@exp@two@args{\ST@subst#1}{#2}{#3}}
+
+\def\ST@removespaces#1{\ST@subst#1{ }{}}
+
+\def\ST@ifvalid@csname#1{%
+ \ifcsname#1\endcsname
+ \expandafter\ifx\csname#1\endcsname\ST@undef@content
+ \expandafter\expandafter\expandafter\@secondoftwo
+ \else
+ \expandafter\expandafter\expandafter\@firstoftwo
+ \fi
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Lecture du tableau %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% lit le tableau : considère que \\ sépare les lignes
+\def\ST@read@tab{%
+ \def\ST@total@colnumber{0}%
+ \ST@rowcount\z@
+ \ST@search@hline% on met de côté la (ou les) ligne supérieure du tableau
+ \ST@read@tab@i
+}
+
+\def\ST@read@tab@i{%
+ \advance\ST@rowcount\@ne
+ \ST@Ifinstr\ST@tab{\ST@eol}% si contient \\, il reste encore des lignes
+ {\expandafter\ST@split\expandafter\ST@tab\expandafter{\ST@eol}\ST@current@row\ST@tab
+ \@namedef{endrow@\number\ST@rowcount\expandafter}\expandafter{\ST@eol}% est la fin de cette ligne, pour l'instant
+ \ST@Iffirstis\ST@tab[% on prend en compte l'éventuel argument optionnel de \\
+ {\ST@between\ST@tab[]\ST@temp@a% prend ce qui est entre crochet
+ \ST@Ifinstr\ST@temp@a,% si c'est une référence (on teste juste la présence de la virgule, ça devrait suffire)
+ {}% on ne fait rien
+ {\ST@split\ST@tab]\ST@temp@a\ST@tab% sinon, coupe au crocher fermant
+ \expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname{\ST@temp@a]}}% ajoute l'argument optionnel à la fin de ligne
+ }%
+ {}%
+ \ST@search@hline% on va purger les hlines et les mettre dans la fin de ligne
+ \ifx\ST@tab\@empty
+ \let\ST@next@readrows\relax
+ \edef\ST@total@rownumber{\number\ST@rowcount}%
+ \else
+ \let\ST@next@readrows\ST@read@tab@i
+ \fi
+ }%
+ {\let\ST@current@row\ST@tab% plus de ligne ? on prend le tout c-à-d la ligne incomplète qui finit le tableau
+ \let\ST@next@readrows\relax
+ \edef\ST@total@rownumber{\number\ST@rowcount}}%
+ \ST@Ifinstr\ST@current@row{\@empty\SThiderow}% il est demandé de masquer la colonne ?
+ {\edef\ST@row@skiplist{(\number\ST@rowcount)\ST@row@skiplist}% on ajoute le numéro de ligne à masquer à la skiplist
+ \StrDel\ST@current@row{\@empty\SThiderow}[\ST@current@row]%
+ }%
+ {}%
+ \ST@colcount\z@
+ \let\STmulticol@number\@empty
+ \let\ST@nextcell\@empty
+ \ST@read@cells% lit les cellules de la ligne courante \ST@current@row
+ \ST@next@readrows
+}
+
+\def\ST@read@cells{% divise la ligne contenue dans \ST@current@row en cellules
+ \advance\ST@colcount\@ne
+ \ST@Ifinstr\ST@current@row&%
+ {\ST@split\ST@current@row&\ST@current@cell\ST@current@row
+ \let\ST@next@readcells\ST@read@cells
+ }%
+ {\let\ST@current@cell\ST@current@row
+ \let\ST@next@readcells\relax
+ \ifnum\ST@colcount>\ST@total@colnumber\edef\ST@total@colnumber{\number\ST@colcount}\fi
+ }%
+ \ST@Ifinstr\ST@current@cell{\@empty\SThidecol}% on doit masquer cette colonnes ?
+ {\ST@Ifinstr\ST@col@skiplist{\expandafter(\number\ST@colcount)}% ça a déjà été demandé ?
+ {}% on fait rien
+ {\edef\ST@col@skiplist{(\number\ST@colcount)\ST@col@skiplist}% sinon -> ajout à la skiplist
+ \ifnum\ST@colcount>\ST@laST@skipcol\edef\ST@laST@skipcol{\number\ST@colcount}\fi
+ }%
+ \StrDel\ST@current@cell{\@empty\SThidecol}[\ST@current@cell]%
+ }%
+ {}%
+ \exploregroups
+ \ST@Ifinstr\ST@current@cell{\@empty\multicolumn}% tester la présence d'un \multicol
+ {\ST@firstarg@after\ST@current@cell\multicolumn\STmulticol@number}%
+ {\let\STmulticol@number\@empty}%
+ \IfSubStr\ST@current@cell\STnumericfieldmarker% il y a un marqueur de champ numérique ?
+ {\IfSubStr\ST@current@cell{\@empty\STcopy}\ST@invalidSTcopy{}% s'il y a un \STcopy, erreur (pas de champ numérique et de \STcopy dans une même cellule)
+ \StrBehind\ST@current@cell\STnumericfieldmarker[\ST@current@formula]%
+ \noexploregroups
+ \StrChar\ST@current@formula1[\ST@temp@a]% \ST@temp@a contient {<formule}
+ \exploregroups
+ \let\ST@temp@b\STnumericfieldmarker
+ \ST@expadd@tomacro\ST@temp@b\ST@temp@a
+ \StrSubstitute[1]\ST@current@cell\ST@temp@b\STnumericfieldmarker[\ST@current@cell]% on remplace :={<formule>} par ":="
+ \noexploregroups
+ \ST@keep@firstcar\ST@temp@a% dans la formule, on enlève les accolades
+ \ST@removespaces\ST@temp@a% et tous les espaces
+ \ifx\ST@temp@a\@empty% \ST@temp@a contient la formule : si la formule est vide
+ \ifx\ST@copylist\@empty% pas de copylist ?
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{0}% met le code à 0
+ \else% si la copylist existe
+ \ST@lookincopylist{\number\ST@colcount}{\number\ST@rowcount}\ST@celltocopy% on cherche si la cellule en cours est dans une plage de copie
+ \ifx\ST@celltocopy\@empty
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{0}% si c'est non, met le code à 0
+ \StrDel[1]\ST@current@cell\STnumericfieldmarker[\ST@current@cell]% on supprime aussi ":="
+ \else
+ \ST@letname{formula@\number\ST@colcount @\number\ST@rowcount}\ST@celltocopy% il y a une cellule à copier : on l'assigne au champ numérique
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{1}% et on met le code à 1
+ \fi
+ \fi
+ \else% la formule n'est pas vide
+ \ST@letname{formula@\number\ST@colcount @\number\ST@rowcount}\ST@temp@a% et on assigne à la formule
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{1}% code 1 à priori
+ \fi
+ }% ci dessous, il n'y a pas de marqueur de champ numérique
+ {\IfSubStr\ST@current@cell\STtextcell% si c'est une cellule de texte
+ {\StrDel\ST@current@cell\STtextcell[\ST@current@cell]% on le(s) supprime les flags
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{0}% met le code à 0
+ }% ci dessous, ce n'est pas une cellule texte, c'est donc une cellule purement champ numérique sans marqueur
+ {\StrDel\ST@current@cell\space[\ST@temp@a]%
+ \ifx\@empty\ST@temp@a% il n'y a que des espaces, c'est donc une cellule vide
+ \ifx\ST@copylist\@empty% pas de copylist ?
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{0}% met le code à 0
+ \else% si la copylist existe
+ \ST@lookincopylist{\number\ST@colcount}{\number\ST@rowcount}\ST@celltocopy% on cherche si la cellule en cours est dans un oplage de copie
+ \ifx\ST@celltocopy\@empty
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{0}% si c'est non, met le code à 0
+ \else
+ \let\ST@current@cell\STnumericfieldmarker% il y a une cellule à copier ici
+ \ST@letname{formula@\number\ST@colcount @\number\ST@rowcount}\ST@celltocopy% on l'assigne au champ numérique
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{1}% et on met le code à 1
+ \fi
+ \fi
+ \else% ici, la cellule est composée d'une champ numérique sans marqueur
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{1}% toute la cellule est considérée comme champ numérique
+ \ST@remove@firST@spaces\ST@current@cell
+ \ST@Ifinstr\ST@current@cell{\@empty\STcopy}%
+ {\ST@findcopyargs\ST@current@cell\ST@copyrange\ST@copyformula% on chope les arguments de \STcopy
+ \ST@seekcopyoffset\ST@copyrange% cherche les décalages
+ \edef\ST@copyrange{\ST@hoffest,\ST@voffest}% et affecte sous forme a,b où a et b sont des nombres ou sont vides
+ \expandafter\def\expandafter\ST@newtocopylist\expandafter{\expandafter|\ST@copyformula|}% \ST@newtocopylist est le nouvel élément à ajouter à la copylist
+ \ST@edefadd@tomacro\ST@newtocopylist{[\number\ST@colcount,\number\ST@rowcount]}%
+ \ST@expadd@tomacro\ST@newtocopylist{\expandafter(\ST@copyrange)}%
+ \ST@expadd@tomacro\ST@newtocopylist\ST@copylist% ajoute la copylist à la fin
+ \let\ST@copylist\ST@newtocopylist% et l'assigne à copylist
+ \ST@transposeformula00\ST@copyformula\ST@copyformula% on transpose éventuellement pour gérer les "!"
+ \ST@letname{formula@\number\ST@colcount @\number\ST@rowcount}\ST@copyformula% affecte la formule inchangée au champ numérique courant
+ }%
+ {\ST@letname{formula@\number\ST@colcount @\number\ST@rowcount}\ST@current@cell% et on assigne toute la cellule
+ \let\ST@current@cell\STnumericfieldmarker% et on met le flag pour la formule
+ }%
+ \fi
+ }%
+ }%
+ \noexploregroups
+ \ifnum\csname code@\number\ST@colcount @\number\ST@rowcount\endcsname>\z@% si le code est > 0
+ \ST@try@calc@cell(\number\ST@colcount,\number\ST@rowcount)% on essaie de calculer la cellule
+ \fi
+ \ST@letname{text@\number\ST@colcount @\number\ST@rowcount}\ST@current@cell
+ \unless\ifx\@empty\STmulticol@number% si c'est une cellule qui contient \multicolumn
+ \loop% on met tous les codes des cellules fusionées qui suivent la cellule en cours à -1
+ \ifnum\STmulticol@number>\@ne
+ \edef\STmulticol@number{\number\numexpr\STmulticol@number-1}%
+ \advance\ST@colcount\@ne
+ \@namedef{code@\number\ST@colcount @\number\ST@rowcount}{-1}% -1 = cellule multicol
+ \repeat
+ \fi
+ \ST@next@readcells
+}
+
+% On va essayer de purger dans #1 toutes les \hline, \clines, \hhline etc, et ajouter tout ce beau monde
+% et leur evéntuels arguments dans des sc spéciales (par ex \endrow@3 pour la fin de la 3e ligne.)
+\def\ST@search@hline{%
+ \ST@ifvalid@csname{endrow@\number\ST@rowcount}%
+ {}
+ {\ST@letname{endrow@\number\ST@rowcount}\@empty}%
+ \ST@search@hline@i
+}
+
+\def\ST@search@hline@i{%
+ \ST@remove@firST@spaces\ST@tab% on enlève les espaces au début
+ \StrChar\ST@tab1[\ST@temp@a]% \ST@temp@a est le 1er car
+ \let\ST@next\ST@search@hline@i
+ \IfStrEqCase\ST@temp@a{% on envisage tous les cas de tracé de ligne horizontale
+ {\@empty\hline}{\StrGobbleLeft\ST@tab1[\ST@tab]\expandafter\STadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\hline}%
+ {\@empty\cline}{\StrSplit\ST@tab2\ST@temp@a\ST@tab\expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a}%
+ {\@empty\hhline}{\StrSplit\ST@tab2\ST@temp@a\ST@tab\expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a}%
+ {\@empty\noalign}{\StrSplit\ST@tab2\ST@temp@a\ST@tab\expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a}%
+ {\@empty\toprule}{% les commandes de booktabs
+ \StrSplit\ST@tab1\ST@temp@a\ST@tab% chope le 1er lexème : la commande \toprule
+ \IfBeginWith\ST@tab[{\StrBefore\ST@tab][\ST@temp@b]\ST@expadd@tomacro\ST@temp@a{\ST@temp@b]}\StrBehind\ST@tab][\ST@tab]}{}%
+ \expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a
+ }%
+ {\@empty\midrule}{%
+ \StrSplit\ST@tab1\ST@temp@a\ST@tab% chope le 1er lexème : la commande \midrule
+ \IfBeginWith\ST@tab[{\StrBefore\ST@tab][\ST@temp@b]\ST@expadd@tomacro\ST@temp@a{\ST@temp@b]}\StrBehind\ST@tab][\ST@tab]}{}%
+ \expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a
+ }%
+ {\@empty\bottomrule}{%
+ \StrSplit\ST@tab1\ST@temp@a\ST@tab% chope le 1er lexème : la commande \bottomrule
+ \IfBeginWith\ST@tab[{\StrBefore\ST@tab][\ST@temp@b]\ST@expadd@tomacro\ST@temp@a{\ST@temp@b]}\StrBehind\ST@tab][\ST@tab]}{}%
+ \expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a
+ }%
+ {\@empty\cmidrule}{%
+ \StrSplit\ST@tab1\ST@temp@a\ST@tab% chope le 1er lexème : la commande \cmidrule
+ \IfBeginWith\ST@tab[{\StrBefore\ST@tab][\ST@temp@b]\ST@expadd@tomacro\ST@temp@a{\ST@temp@b]}\StrBehind\ST@tab][\ST@tab]}{}%
+ \IfBeginWith\ST@tab({\StrBefore\ST@tab)[\ST@temp@b]\ST@expadd@tomacro\ST@temp@a{\ST@temp@b)}\StrBehind\ST@tab)[\ST@tab]}{}%
+ \StrSplit\ST@tab1\ST@temp@b\ST@tab% chope l'argument obligatoire : {a-b}
+ \ST@expadd@tomacro\ST@temp@a\ST@temp@b% l'ajoute à \ST@temp@b
+ \expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a% et on ajoute le tout à endrow
+ }%
+ {\@empty\addlinespace}{%
+ \StrSplit\ST@tab1\ST@temp@a\ST@tab% chope le 1er lexème : la commande \addlinespace
+ \IfBeginWith\ST@tab[{\StrBefore\ST@tab][\ST@temp@b]\ST@expadd@tomacro\ST@temp@a{\ST@temp@b]}\StrBehind\ST@tab][\ST@tab]}{}%
+ \expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a
+ }%
+ {\@empty\morecmidrules}{\StrGobbleLeft\ST@tab1[\ST@tab]\expandafter\STadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\morecmidrules}%
+ {\@empty\specialrule}{\StrSplit\ST@tab4\ST@temp@a\ST@tab\expandafter\ST@expadd@tomacro\csname endrow@\number\ST@rowcount\endcsname\ST@temp@a}%
+ }[\let\ST@next\relax]%
+ \ST@next
+}
+
+% Cette macro transpose toutes les références (absolues et relatives) de la sc #3.
+% Le décalage est de #1 (nombre signé) pour les colonnes et de #2 (nombre signé) pour les lignes.
+% La sc #4 recoit la formule transposée.
+\def\ST@transposeformula#1#2#3#4{%
+ \def\STaddcol{#1}\def\STaddrow{#2}\let\ST@temp@formula#3%
+ \let\ST@transposed@formula\@empty
+ \ST@transposeformula@i
+ \let#4\ST@transposed@formula
+}
+
+\def\ST@transposeformula@i{%
+ \unless\ifx\@empty\ST@temp@formula% tant que l'on n'a pas parcouru \ST@temp@formula
+ \ST@splitatfirstcar\ST@temp@formula\ST@firstcar\ST@temp@formula% prend le 1er car de \ST@temp@formula
+ \if\expandafter\noexpand\STtransposecar\expandafter\noexpand\ST@firstcar% si ce caractère est un !
+ \let\STaddcol@\z@% pas de tranposition sur la colonne
+ \ST@splitatfirstcar\ST@temp@formula\ST@firstcar\ST@temp@formula% on prend le premier caractère qui suit le !
+ \else
+ \let\STaddcol@\STaddcol% sinon, on copie le vecteur
+ \fi
+ \expandafter\ST@ifcar@isletter\expandafter{\ST@firstcar}% est-ce que le 1er car est une lettre ?
+ {\if\expandafter\noexpand\STtransposecar\expandafter\expandafter\expandafter\noexpand\expandafter\@car\ST@temp@formula\@nil% le caractère suivant est un "!" ?
+ \let\STaddrow@\z@% pas de tranposition sur la ligne
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\ST@temp@formula\expandafter\expandafter\expandafter{\expandafter\@cdr\ST@temp@formula\@nil}% on prend ce qui est après le !
+ \else
+ \let\STaddrow@\STaddrow% sinon, on copie le vecteur
+ \fi
+ \IfInteger\ST@temp@formula{}{}% on prend le nombre qui suit
+ \ifnum\integerpart>\z@% si ce nombre est plus grand que 0 -> référence valide
+ \let\ST@temp@formula\@xs@afterinteger% on prend ce qui est après le nombre
+ \expandafter\lowercase\expandafter{\expandafter\def\expandafter\ST@firstcar\expandafter{\ST@firstcar}}% met en minuscules
+ \edef\ST@firstcar{\number\numexpr\expandafter`\ST@firstcar-`a+1+\STaddcol@}% est le numéro de la colonne
+ \ifnum\ST@firstcar<\@ne\ST@illegal@copy\fi% erreur de copie ?
+ \ST@edefadd@tomacro\ST@transposed@formula{%
+ \ifcase\ST@firstcar \or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or
+ n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\fi
+ \number\numexpr\integerpart+\STaddrow@}%
+ \ifnum\numexpr\integerpart+\STaddrow@<\@ne\ST@illegal@copy\fi% erreur de copie ?
+ \else
+ \let\ST@temp@formula\@xs@afterinteger
+ \ST@expadd@tomacro\ST@transposed@formula\ST@firstcar
+ \fi
+ }%
+ {\if[\expandafter\noexpand\ST@firstcar% si le 1er car est [
+ \ST@left\ST@temp@formula]\ST@temp@ref% on prend ce qui est entre crochet
+ \ST@right\ST@temp@formula]\ST@temp@formula% pour la suite, on prend ce qui après le crochet
+ \ST@left\ST@temp@ref,\ST@rel@num% ce qui est avant la virgule
+ \if\expandafter\noexpand\STtransposecar\expandafter\expandafter\expandafter\noexpand\expandafter\@car\ST@rel@num\@nil% commence par un "!" ?
+ \let\STaddcol@\STaddcol% compensation pour conserver la cellule initiale
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\ST@rel@num\expandafter\expandafter\expandafter{\expandafter\@cdr\ST@rel@num\@nil}% on prend ce qui est après le !
+ \else
+ \let\STaddcol@\z@% sinon, on n'ajoute rien
+ \fi
+ \IfInteger\ST@rel@num
+ {\edef\STaddcol@{\number\numexpr\ST@rel@num-\STaddcol@}%
+ \ST@right\ST@temp@ref,\ST@rel@num% ce qui est après la virgule
+ \if\expandafter\noexpand\STtransposecar\expandafter\expandafter\expandafter\noexpand\expandafter\@car\ST@rel@num\@nil% commence par un "!"?
+ \let\STaddrow@\STaddrow% on compense pour conserver la cellule initiale
+ \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\ST@rel@num\expandafter\expandafter\expandafter{\expandafter\@cdr\ST@rel@num\@nil}% on prend ce qui est après le !
+ \else
+ \let\STaddrow@\z@% sinon, on n'ajoute rien
+ \fi
+ \IfInteger\ST@rel@num
+ {\ST@edefadd@tomacro\ST@transposed@formula{[\STaddcol@,\number\numexpr\ST@rel@num-\STaddrow@]}%
+ }%
+ \ST@illegal@relativeref
+ }%
+ \ST@illegal@relativeref
+ \else
+ \ST@expadd@tomacro\ST@transposed@formula\ST@firstcar
+ \fi
+ }%
+ \expandafter\ST@transposeformula@i
+ \fi
+}
+
+% Cherche dans la sc #1 les 3 arguments qui se trouvent après \STcopy
+% Affecte le 1er à #2, le 2è à #3 et le 3è à #4
+\def\ST@findcopyargs#1#2#3{%
+ \def\ST@argaftercopy##1\STcopy##2##3##4\@nil{%
+ \def#1{##1}\ST@expadd@tomacro#1{\STnumericfieldmarker##4}% dans #1,supprime \STcopy{<arg1>}{<arg2>} et le remplace par :=
+ \def#2{##2}\def#3{##3}%
+ }%
+ \expandafter\ST@argaftercopy#1\@nil
+}
+
+% teste si #1 est dans l'intervalle [#3,#3+#5] et si #2 est dans [#4,#4+#6]
+% si #5 est vide, c'est l'intervalle [#3,+inf] et si #6 est vide, c'est [#4,+inf]
+\def\ST@Ifin#1#2[#3,#4](#5,#6)%
+{%
+ \ifnum#1<#3
+ \let\ST@next\@secondoftwo
+ \else
+ \ifnum#2<#4
+ \let\ST@next\@secondoftwo
+ \else
+ \ifx\@empty#5\@empty
+ \ifx\@empty#6\@empty
+ \let\ST@next\@firstoftwo
+ \else
+ \ifnum#2>\numexpr#4+#6\relax
+ \let\ST@next\@secondoftwo
+ \else
+ \let\ST@next\@firstoftwo
+ \fi
+ \fi
+ \else
+ \ifnum#1>\numexpr#3+#5\relax
+ \let\ST@next\@secondoftwo
+ \else
+ \ifx\@empty#6\@empty
+ \let\ST@next\@firstoftwo
+ \else
+ \ifnum#2>\numexpr#4+#6\relax
+ \let\ST@next\@secondoftwo
+ \else
+ \let\ST@next\@firstoftwo
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \ST@next
+}
+
+% Regarde dans la liste de copie si la cellule de coodonnées #1 #2 est dans une plage de copie
+% si oui, affecte à #3 la formule transposée
+% La liste de copy est parcourue de gauche à droite avec sortie dès qu'une plage qui convient est rencontrée
+\def\ST@lookincopylist#1#2#3{%
+ \let\ST@alias@copylist\ST@copylist
+ \let\ST@returnedformula\@empty
+ \def\ST@copycol{#1}\def\ST@copyrow{#2}\let#3\@empty
+ \ST@lookincopyliST@i
+ \let#3\ST@returnedformula
+}
+
+\def\ST@lookincopyliST@i{%
+ \expandafter\ST@testfirstincopylist\ST@alias@copylist\@nil
+ \ifx\@empty\ST@alias@copylist
+ \let\ST@next\relax
+ \else
+ \ifx\@empty\ST@returnedformula
+ \let\ST@next\ST@lookincopyliST@i
+ \else
+ \let\ST@next\relax
+ \fi
+ \fi
+ \ST@next
+}
+
+% Teste si un élément de la copylist contient une plage qui inclus la cellule en cours.
+\def\ST@testfirstincopylist|#1|[#2,#3](#4,#5)#6\@nil{%
+ \def\ST@alias@copylist{#6}% on enlève le premier élément de la copylist
+ \ST@Ifin\ST@copycol\ST@copyrow[#2,#3](#4,#5)% si ça correspond
+ {\def\ST@returnedformula{#1}%
+ \ST@transposeformula{\numexpr\ST@copycol-#2}{\numexpr\ST@copyrow-#3}\ST@returnedformula\ST@returnedformula
+ }%
+ {\ifx\@empty#5\@empty\else
+ \ifnum\ST@copyrow>\numexpr#3+#5\relax
+ \ST@subst\ST@copylist{|#1|[#2,#3](#4,#5)}{}% si on a dépassé la ligne, on retire ce premier élément de la copylist
+ \fi
+ \fi
+ }%
+}
+
+% Cherche dans la sc#1 du type ">4,v9" les décalages horizontaux et verticaux
+% spécifiés avec > et v
+% S'il trouve > ou v sans nombre derrière, le décalage correspondant est vide
+% S'il ne trouve pas > ou v, le décalage correspond est égal à 0
+% Assigne les décalages trouvés dans \ST@hoffest et \ST@voffest
+\def\ST@seekcopyoffset#1{%
+ \ST@Ifinstr#1>%
+ {\ST@findcopyoffest#1>\ST@hoffest}%
+ {\def\ST@hoffest{0}}%
+ \ST@Ifinstr#1v%
+ {\ST@findcopyoffest#1v\ST@voffest}%
+ {\def\ST@voffest{0}}%
+}
+
+% Cherche dans la sc #1 ce qui est entre #2 et ,
+\def\ST@findcopyoffest#1#2#3{%
+ \def\ST@findcopyoffeST@i##1#2##2,##3\@nil{\def#3{##2}}%
+ \expandafter\ST@findcopyoffeST@i#1,\@nil
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%% Recherche d'une référence %%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% teste si le token #1 est une lettre (majuscule ou minuscule)
+\def\ST@ifcar@isletter#1{%
+ \begingroup\escapechar`\\
+ \lowercase{\expandafter\ST@ifcar@isletter@i\detokenize{#1}}.\@nil
+}
+\def\ST@ifcar@isletter@i#1#2\@nil{%
+ \endgroup
+ \ifnum\numexpr(`#1-`a)*(`#1-`z)\relax>\z@\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi
+}
+
+% cherche une référence du type lettre+nombre dans la sc #1
+% si on trouve, renvoie les coordonnées dans #2 sous la forme x@y
+% si on ne trouve pas, #2 est vide.
+\def\ST@findref@informula#1#2{%
+ \let\ST@temp@formula#1%
+ \ST@findref@informula@i
+ \let#2\ST@temp@formula
+ \unless\ifx\@empty\ST@ref@found
+ \ST@Iffirstis\ST@after@ref@found|
+ {}
+ {\ST@exp@two@args{\ST@subST@once#1}\ST@ref@found{\ST@ref@found|}}%
+ \fi
+}
+
+\def\ST@findref@informula@i{%
+ \let\ST@next@search\ST@findref@informula@i
+ \ifx\@empty\ST@temp@formula
+ \let\ST@next@search\relax
+ \else
+ \StrSplit\ST@temp@formula1\ST@firstcar\ST@temp@formula% prend le 1er car de ce qui reste
+ \expandafter\ST@ifcar@isletter\expandafter{\ST@firstcar}% est-ce que le 1er car est une lettre ?
+ {\IfInteger\ST@temp@formula{}{}% on prend le nombre qui suit
+ \ifnum\integerpart>\z@% si ce nombre est plus grand que 0 -> référence valide
+ \let\ST@after@ref@found\@xs@afterinteger
+ \edef\ST@ref@found{\ST@firstcar\number\integerpart}% est la référence trouvée
+ \edef\ST@distant@rownumber{\number\integerpart}% on chope ce nombre pour le numéro de colonne
+ \edef\ST@distant@colnumber{\number\numexpr\expandafter`\ST@firstcar-`a+1}% traduction lettre->chiffre
+ \ifnum\ST@distant@colnumber<\z@\edef\ST@distant@colnumber{\number\numexpr\ST@distant@colnumber+32}\fi% met les majuscules en minuscules
+ \edef\ST@temp@formula{\ST@distant@colnumber @\ST@distant@rownumber}% les coordonnées de la référence
+ \let\ST@next@search\relax
+ \fi
+ }%
+ {\if[\expandafter\noexpand\ST@firstcar% si le 1er car est [
+ \ST@right\ST@temp@formula]\ST@after@ref@found
+ \ST@left\ST@temp@formula]\ST@temp@formula% on prend ce qui est entre crochet
+ \expandafter\def\expandafter\ST@ref@found\expandafter{\expandafter[\ST@temp@formula]}%
+ \ST@left\ST@temp@formula,\ST@rel@num
+ \IfInteger\ST@rel@num
+ {\edef\ST@distant@colnumber{\number\numexpr\ST@current@colnumber+\ST@rel@num}%
+ \ST@right\ST@temp@formula,\ST@rel@num
+ \IfInteger\ST@rel@num
+ {\edef\ST@distant@rownumber{\number\numexpr\ST@current@rownumber+\ST@rel@num}%
+ \edef\ST@temp@formula{\ST@distant@colnumber @\ST@distant@rownumber}% les coordonnées de la référence
+ \let\ST@next@search\relax
+ }%
+ \ST@illegal@relativeref
+ }%
+ \ST@illegal@relativeref
+ \fi
+ }%
+ \fi
+ \ST@next@search
+}
+
+% cette commande teste si la sc #1 est syntaxiquement une référence
+\def\ST@ifref#1{%
+ \let\ST@temp@formula#1%
+ \let\ST@ref@found\@empty
+ \ST@findref@informula@i
+ \ifx\@empty\ST@ref@found
+ \let\ST@next\@secondoftwo
+ \else
+ \ifx#1\ST@ref@found
+ \let\ST@next\@firstoftwo
+ \else
+ \let\ST@next\@secondoftwo
+ \fi
+ \fi
+ \ST@next
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%% Le noyau : évaluation de toutes les cellules %%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Essaie de calculer la cellule (#1,#2)
+\def\ST@try@calc@cell(#1,#2){%
+ \ST@ifvalid@csname{formula@#1@#2}% on vérifie que la formule existe
+ {\expandafter\ifx\csname formula@#1@#2\endcsname\@empty
+ \@namedef{code@#1@#2}{0}% si vide, code à 0
+ \else% et qu'elle est non vide
+ \def\ST@current@colnumber{#1}\def\ST@current@rownumber{#2}%
+ \expandafter\ST@find@firST@func\csname formula@#1@#2\endcsname% cherche une fonction dans la formule
+ \ifx\@empty\ST@function@namefound% s'il n'y a pas de fonction
+ \expandafter\ST@findref@informula\csname formula@#1@#2\endcsname\ST@coord
+ \ifx\@empty\ST@coord% ni de référence
+ \ST@calc@cell(#1,#2)% on va la calculer la cellule
+ \fi
+ \fi
+ \fi
+ }
+ {}%
+}
+
+\def\ST@calc@cell(#1,#2){% calcule la formule numérique de la cellule (#1,#2)
+ \unless\ifnum\csname code@#1@#2\endcsname<\@ne% si le code est >= 1
+ \ST@cslet\ST@temp@a{formula@#1@#2}% \ST@temp@a est le contenu de la formule
+ \ST@Iffirstis\ST@temp@a-{\expandafter\def\expandafter\ST@temp@a\expandafter{\expandafter0\ST@temp@a}}{}%
+ \STeval\ST@temp@a\ST@temp@a% on calcule cette formule
+ \unless\ifx\STrounddigit\@empty\STround\ST@temp@a\ST@temp@a\STrounddigit\fi% on arrondi s'il faut
+ \ifST@clipround% on arrondit en enlevant les 0 inutiles ?
+ \STclip\ST@temp@a\ST@temp@a
+ \else% si on laisse certains 0 inutiles
+ \unless\ifx\STrounddigit\@empty% on ne tronque que si le nombre n'est pas vide
+ \STtrunc\ST@temp@a\ST@temp@a\STrounddigit
+ \fi
+ \fi
+ \ST@letname{formula@#1@#2}\ST@temp@a% assigne le résultat à la formule
+ \@namedef{code@#1@#2}{2}% et met le code à 2 (cellule calculée)
+ \fi
+}
+
+% Calcule toutes les formules du tableau
+\def\STeval@tab{%
+ \ST@rowcount\@ne\ST@colcount\@ne
+ \STeval@tab@i
+}
+
+\def\STeval@tab@i{%
+ \ifnum\ST@rowcount>\ST@total@rownumber
+ \let\ST@nextcell\relax
+ \else
+ \ST@ifvalid@csname{formula@\number\ST@colcount @\number\ST@rowcount}% si la formule existe
+ {\STeval@cell(\number\ST@colcount,\number\ST@rowcount)}% on la calcule
+ {}%
+ \advance\ST@colcount\@ne
+ \let\ST@nextcell\STeval@tab@i
+ \ifnum\ST@colcount>\ST@total@colnumber
+ \ST@colcount\@ne
+ \advance\ST@rowcount\@ne
+ \fi
+ \fi
+ \ST@nextcell
+}
+
+% la sc #1 est le nom d'une fonction.
+% La macro renvoie dans la sc #2 : 1, 2 ou 2 selon que #1 est le nom d'une macro à argument numérique, à argument plage ou à argument texte.
+% #2 est vaut 0 si #1 n'est pas le nom d'une fonction
+\def\ST@determine@function@code#1#2{%
+ \ST@Ifinstr{\ST@functions@with@num@arg,}{#1,}%
+ {\def#2{1}}%
+ {\ST@Ifinstr{\ST@functions@with@range@arg,}{#1,}%
+ {\def#2{2}}%
+ {\ST@Ifinstr{\ST@functions@with@text@arg,}{#1,}%
+ {\def#2{3}}%
+ {\def#2{0}}%
+ }%
+ }%
+}
+
+% évalue la cellule (#1#2) par ses coordonnées numériques (col,row)
+\def\STeval@cell(#1,#2){%
+ \edef\ST@dependance@tree{(#1,#2)}% FIXME : mettre \edef
+ \let\ST@stackcall\@empty
+ \let\ST@function@namesaved\@empty
+ \STeval@cell@i(#1,#2)% on appelle la macro récursive
+ \ifST@message
+ \let\ST@deptree\@empty
+ \ST@show@dependance@tree
+ \ST@dependance@tree
+ \message{\space\space\space\space\space cell \ST@deptree^^J}%
+ \fi
+}
+
+% Ceci est la macro principale : elle évalue la cellule (#1,#2)
+\def\STeval@cell@i(#1,#2){% #1 = no colonne #2 = no ligne
+ \ifnum\csname code@#1@#2\endcsname=\@ne% on ne fait quelque chose que si le code est 1 : cellule non calculée
+ \def\ST@current@colnumber{#1}\def\ST@current@rownumber{#2}%
+ \expandafter\ST@find@firST@func\csname formula@#1@#2\endcsname% cherche une fonction dans la formule
+ \ifx\@empty\ST@function@namefound% il n'y a pas de fonction
+ \IfSubStr[2]\ST@dependance@tree{(#1,#2)}%
+ {\edef\ST@coord{#1,#2}\ST@circular@reference}% message et on s'arrête si référence circulaire
+ {}%
+ \expandafter\ST@findref@informula\csname formula@#1@#2\endcsname\ST@coord% y a t-il une référence dans l'argument ?
+ \ifx\ST@coord\@empty% pas de référence dans l'argument
+ \ifx\ST@function@namesaved\@empty% si aucune fonction n'a été décelée
+ \ST@calc@cell(#1,#2)% on calcule la cellule en cours
+ \else
+ \ST@Ifinstr{\ST@functions@with@textresult,}{\ST@function@namesaved,}% si la dernière fonction rend du texte
+ {\ifx\ST@stackcall\@empty% et si on est dans la cellule source
+ \@namedef{code@#1@#2}{0}% on met le code à 0, la cellule devient textuelle
+ \exploregroups
+ \expandafter\StrSubstitute\expandafter[\expandafter\@ne\expandafter]\csname text@#1@#2\expandafter\endcsname\expandafter\STnumericfieldmarker\csname formula@#1@#2\expandafter\endcsname\expandafter[\csname text@#1@#2\endcsname]% copie de la formule vers la zone texte
+ \noexploregroups
+ \ST@letname{formula@#1@#2}\@empty% et plus rien dans la formule
+ \else
+ \ST@calc@cell(#1,#2)% sinon, on se trouve dans une cellule appelée par une macrofonction et donc, on la calcule
+ \fi
+ }%
+ {\ST@calc@cell(#1,#2)}% c'est une fonction qui donne un arg numérique : on calcule la cellule en cours
+ \fi
+ \else
+ \ST@ifvalid@csname{code@\ST@coord}% le code distant exite ?
+ {\ifcase\csname code@\ST@coord\endcsname% code distant = 0 ==> cellule vide ou textuelle, pas bon du tout !
+ \edef\ST@temp@callcell{#1,#2}% coordonnées de la cellule appelante
+ \edef\ST@coord{\ST@distant@colnumber,\ST@distant@rownumber}% coordonnées appelées
+ \ST@zerocodecell@cell% erreur : référence à une cellule de code 0
+ \or% code distant = 1
+ \edef\ST@dependance@tree{\ST@dependance@tree(\ST@distant@colnumber,\ST@distant@rownumber)}% on l'ajoute à l'arbre des dépendances
+ % on doit évaluer cette formule distante et ensuite, on doit encore recommence avec la formule en cours : on les ajoute sur la pile lifo
+ \edef\ST@stackcall{(\ST@distant@colnumber,\ST@distant@rownumber)(#1,#2)\ST@stackcall}%
+ \or% code distant = 2, la cellule distante est calculée, on créé un alias pour le contenu de la formule distante
+ \ST@cslet\ST@distant@formula{formula@\ST@coord}%
+ % si la valeur distante est <0, on la met entre parenthèses
+ \ST@Iffirstis\ST@distant@formula-%
+ {\expandafter\def\expandafter\ST@distant@formula\expandafter{\expandafter(\ST@distant@formula)}}%
+ {}%
+ % on remplace toutes les références par la valeur distante
+ \expandafter\ST@expsubst\csname formula@#1@#2\endcsname{\ST@ref@found|}\ST@distant@formula
+ \edef\ST@stackcall{(#1,#2)\ST@stackcall}% puis, on évalue à nouveau cette cellule
+ \else% code distant n'est pas {0,1,2} donc est -1, pas bon du tout !
+ \edef\ST@temp@callcell{#1,#2}% coordonnées de la cellule appelante
+ \ST@subst\ST@coord @,% coordonnées appelées
+ \STmulticol@cell
+ \fi}%
+ {\edef\ST@temp@callcell{#1,#2}% coordonnées de la cellule appelante
+ \ST@subst\ST@coord @,% coordonnées appelées
+ \ST@undefined@cell% code distant inexistant -> cellule hors limite du tableau
+ }%
+ \fi
+ \else% il y a une fonction dans la formule
+ \let\ST@function@namesaved\ST@function@namefound
+ \ST@determine@function@code\ST@function@namefound\ST@codefunc% détermine le code de la fonction
+ \ifcase\ST@codefunc\relax
+ \PackageError\STname{This error should not occur! Please email the author. Thanks.}{}%
+ \or% le code vaut 1, c'est une fonction à argument numérique
+ \ST@findref@informula\ST@function@argfound\ST@temp@formula% y a t-il une référence dans l'argument de la formule ?
+ \ifx\ST@temp@formula\@empty% pas de référence dans l'argument de la fonction
+ \ST@cslet\ST@current@formula{formula@#1@#2}% alias pour la formule
+ \let\ST@tobereplaced\ST@function@namefound
+ \ST@expadd@tomacro\ST@tobereplaced{\expandafter(\ST@function@argfound)}% ce qui va être replacé : fonction(argument)
+ \ST@Ifinstr{\ST@functions@no@calc@arg,}{\ST@function@namefound,}% doit-on calculer l'argument de cette fonction ?
+ {}%
+ {\STeval\ST@function@argfound\ST@function@argfound\STclip\ST@function@argfound\ST@function@argfound}%
+ \csname ST@func@\ST@function@namefound\endcsname\ST@function@argfound\ST@result@func% puis on évalue la fonctionfound
+ \ST@Iffirstis\ST@result@func-{\expandafter\def\expandafter\ST@result@func\expandafter{\expandafter(\ST@result@func)}}{}%
+ \ST@expsubst\ST@current@formula\ST@tobereplaced\ST@result@func% on replace dans l'alias
+ \ST@letname{formula@#1@#2}\ST@current@formula% on l'assigne dans la formule
+ \ifx\@empty\ST@current@formula% pour cause de macro fonction "tag" qui est seule et qui a disparue après substitution
+ \@namedef{code@#1@#2}{0}%
+ \else
+ \edef\ST@stackcall{(#1,#2)\ST@stackcall}% puis, on évalue à nouveau cette cellule
+ \fi
+ \else
+ \ifnum\csname code@\ST@temp@formula\endcsname=\tw@% si la référence est calculée, on la replace par sa valeur
+ \ST@cslet\ST@current@formula{formula@\ST@temp@formula}% alias pour la formule distante
+ \ST@Iffirstis\ST@current@formula-%
+ {\expandafter\def\expandafter\ST@current@formula\expandafter{\expandafter(\ST@current@formula)}}%
+ {}%
+ \let\ST@tobereplaced\ST@function@namefound
+ \ST@expadd@tomacro\ST@tobereplaced{\expandafter(\ST@function@argfound)}%
+ \let\ST@replaced\ST@tobereplaced
+ \ST@expsubst\ST@replaced{\ST@ref@found|}\ST@current@formula
+ \ST@subst\ST@tobereplaced|{}%
+ \expandafter\ST@expsubst\csname formula@#1@#2\endcsname\ST@tobereplaced\ST@replaced
+ \edef\ST@stackcall{(#1,#2)\ST@stackcall}%
+ \else% la référence n'est pas calculée, donc d'abord il faut
+ \edef\ST@stackcall{(\ST@distant@colnumber,\ST@distant@rownumber)(#1,#2)\ST@stackcall}% l'évaluer, et ensuite ré-evaluer la cellule courante
+ \edef\ST@dependance@tree{\ST@dependance@tree(\ST@distant@colnumber,\ST@distant@rownumber)}% mise à jour de l'arbre des dépendances
+ \fi
+ \fi
+ \or% le code vaut 2, c'est une fonction à argument «plage de cellules»
+ \let\ST@tobereplaced\ST@function@namefound\ST@expadd@tomacro\ST@tobereplaced{\expandafter(\ST@function@argfound)}%
+ \csname ST@func@\ST@function@namefound\endcsname\ST@function@argfound\ST@result@func% puis on essaie d'évaluer la fonction
+ \unless\ifx\ST@result@func\@empty% si le calcul a abouti
+ \ST@Iffirstis\ST@result@func-{\expandafter\def\expandafter\ST@result@func\expandafter{\expandafter(\ST@result@func)}}{}%
+ \expandafter\ST@expsubst\csname formula@#1@#2\endcsname\ST@tobereplaced\ST@result@func% on replace dans la formule
+ \edef\ST@stackcall{(#1,#2)\ST@stackcall}% puis, on évalue à nouveau cette cellule
+ \fi
+ \or% le code vaut 3, c'est un fonction dont l'argument est textuel
+ \let\ST@function@argfound@edefed\ST@function@argfound
+ \ST@Ifinstr{\ST@functions@with@assign@argument,}{\ST@function@namefound,}%
+ {\let\ST@temp@formula\@empty}%
+ {\ST@findref@informula\ST@function@argfound\ST@temp@formula}% y a t-il une référence dans l'argument de la fonction ?
+ \ifx\ST@temp@formula\@empty% pas de référence dans l'argument de la fonction
+ \ST@cslet\ST@current@formula{formula@#1@#2}% alias pour la formule
+ \let\ST@tobereplaced\ST@function@namefound
+ \ST@expadd@tomacro\ST@tobereplaced{\expandafter(\ST@function@argfound)}% ce qui va être remplacé : fonction(argument)
+ \csname ST@func@\ST@function@namefound\endcsname\ST@function@argfound@edefed\ST@result@func% puis on évalue la fonction
+ \ST@expsubst\ST@current@formula\ST@tobereplaced\ST@result@func% on replace dans l'alias
+ \ST@letname{formula@#1@#2}\ST@current@formula% on l'assigne dans la formule
+ \edef\ST@stackcall{(#1,#2)\ST@stackcall}% puis, on évalue à nouveau cette cellule
+ \else% il y a une référence dans l'argument de la fontion
+ \ifnum\csname code@\ST@temp@formula\endcsname=\z@% si la référence est une cellule texte
+ \ST@cslet\ST@current@formula{text@\ST@temp@formula}% alias pour la zone texte distante
+ \StrDel[1]\ST@current@formula\STnumericfieldmarker[\ST@current@formula]% on enlève le := si besoin
+ \ST@Ifinstr\ST@current@formula{\@empty\multicolumn}% on ne prend que le texte s'il y a un \multicolumn qui traine
+ {\ST@thirdarg@after\ST@current@formula\multicolumn\ST@current@formula}
+ {}%
+ \let\ST@tobereplaced\ST@function@namefound
+ \ST@expadd@tomacro\ST@tobereplaced{\expandafter(\ST@function@argfound)}%
+ \ST@subst\ST@tobereplaced|{}%
+ \csname ST@func@\ST@function@namefound\endcsname\ST@current@formula\ST@result@func% puis on évalue la fonction
+ \expandafter\ST@expsubst\csname formula@#1@#2\endcsname\ST@tobereplaced\ST@result@func
+ \edef\ST@stackcall{(#1,#2)\ST@stackcall}% puis, on évalue à nouveau cette cellule
+ \else
+ \PackageError\STname{Macro function \ST@function@namefound\space requires a reference to a text cell!}\STseedoc@i
+ \fi
+ \fi
+ \fi
+ \fi
+ \expandafter\ST@next@onstack
+ \fi
+}
+
+% On regarde s'il y a des appels de calcul de cellules en attente
+% Si oui, on enlève le 1er appel de la pile lifo et on l'exécute
+\def\ST@next@onstack{%
+ \unless\ifx\ST@stackcall\@empty
+ \ST@split\ST@stackcall)\ST@temp@a\ST@stackcall
+ \STadd@tomacro\ST@temp@a)%
+ \ST@sanitize@stack
+ \expandafter\def\expandafter\ST@temp@a\expandafter{\expandafter\STeval@cell@i\ST@temp@a}%
+ \expandafter\ST@temp@a
+ \fi
+}
+
+\def\ST@sanitize@stack{% enlève de \ST@stackcall toutes les occurrences de \ST@temp@a
+ \ST@Ifinstr\ST@stackcall\ST@temp@a
+ {\expandafter\ST@subst\expandafter\ST@stackcall\expandafter{\ST@temp@a}{}%
+ \ST@sanitize@stack
+ }%
+ {}%
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Macro-fonctions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\ST@for#1#2{% \ST@for{#1}{code} -> exécute le code pour toutes les cellules des plages passées en argument #1
+ \def\ST@forcode{#2}%
+ \expandafter\def\expandafter\ST@for@rangelist\expandafter{#1;}%
+ \ST@for@i
+}
+
+\def\ST@for@loopcode{% #2 est le code à exécuter dans la boucle for
+ \ST@forcode% on exécute le code
+ \let\ST@nextfor\ST@for@loopcode
+ \advance\ST@colcount@i\@ne
+ \ifnum\ST@colcount@i>\ST@for@col@end
+ \ST@colcount@i\ST@for@col@start
+ \advance\ST@rowcount@i\@ne
+ \ifnum\ST@rowcount@i>\ST@for@row@end
+ \ST@right\ST@for@rangelist;\ST@for@rangelist
+ \ifx\ST@for@rangelist\@empty\let\ST@nextfor\relax\else\let\ST@nextfor\ST@for@i\fi
+ \fi
+ \fi
+ \ST@nextfor
+}
+
+\def\ST@for@i{%
+ \ST@left\ST@for@rangelist;\ST@for@currentrange
+ \ST@left{\ST@for@currentrange:}{\@empty:}\ST@temp@a
+ \ST@ifref\ST@temp@a{}\ST@invalid@range
+ \let\ST@for@col@start\ST@distant@colnumber
+ \let\ST@for@row@start\ST@distant@rownumber
+ \ST@colcount@i\ST@distant@colnumber
+ \ST@rowcount@i\ST@distant@rownumber
+ \ST@Ifinstr\ST@for@currentrange{\@empty:}%
+ {\ST@right\ST@for@currentrange{\@empty:}\ST@temp@a
+ \ST@ifref\ST@temp@a{}\ST@invalid@range
+ \let\ST@for@col@end\ST@distant@colnumber
+ \let\ST@for@row@end\ST@distant@rownumber
+ \let\ST@nextfor\ST@for@loopcode
+ \ifnum\ST@for@col@start>\ST@for@col@end\let\ST@nextfor\relax\fi
+ \ifnum\ST@for@row@start>\ST@for@row@end\let\ST@nextfor\relax\fi
+ }%
+ {\ST@forcode
+ \ST@right\ST@for@rangelist;\ST@for@rangelist
+ \ifx\ST@for@rangelist\@empty
+ \let\ST@nextfor\relax
+ \else
+ \let\ST@nextfor\ST@for@i
+ \fi
+ }%
+ \ST@nextfor
+}
+
+% Cette macro cherche dans la sc #1 la première fonction qu'elle trouve ne contenant pas d'autre fonction dans son argument
+% En sortie, \ST@function@namefound contient le nom de la fonction trouvée et \ST@function@argfound son argument.
+% Si aucune fonction mot-clé n'est trouvé, ces 2 dernières séquences de contrôles sont vides.
+\def\ST@find@firST@func#1{%
+ \let\ST@function@namefound\@empty\let\ST@function@argfound\@empty
+ \let\ST@function@namefound@\@empty\let\ST@function@argfound@\@empty
+ \let\ST@tempfunc#1%
+ \ST@find@firST@func@i
+}
+
+\def\ST@find@firST@func@i{%
+ \edef\ST@tempfunctions@list{\ST@functions@list,}% réinitialise la liste
+ \let\ST@tempfunc@\ST@tempfunc% sauveagrde pour restauration ultérieure
+ \let\ST@function@namefound\@empty% initialise avant appel à la macro
+ \ST@Ifinstr\ST@tempfunc(% s'il y a une parenthèse
+ {\ST@find@firST@func@ii% cherche la 1ere fonction dans l'argument
+ \ifx\ST@function@namefound\@empty% elle n'existe pas ?
+ \let\ST@function@namefound\ST@function@namefound@\let\ST@function@argfound\ST@function@argfound@% on restaure les valeurs précédentes
+ \else% si il y a une fonction dans l'argument
+ \ST@right\ST@tempfunc@\ST@function@namefound\ST@tempfunc% prend ce qui est après le nom de la fonction
+ \ST@seekfunc@arg\ST@tempfunc\ST@function@argfound% isole l'argument entre parenthèses
+ \let\ST@function@namefound@\ST@function@namefound\let\ST@function@argfound@\ST@function@argfound% met à jour les valeurs précédentes
+ \let\ST@tempfunc\ST@function@argfound% recommence avec l'argument
+ \expandafter\ST@find@firST@func@i
+ \fi}%
+ {\let\ST@function@namefound\ST@function@namefound@\let\ST@function@argfound\ST@function@argfound@}%
+}
+
+\def\ST@find@firST@func@ii{%
+ \unless\ifx\ST@tempfunc\@empty% tant que le contenu n'est pas vide
+ \unless\ifx\ST@tempfunctions@list\@empty% et tant que tous les noms de fonctions n'ont pas été explorés
+ \ST@split\ST@tempfunctions@list,\ST@current@funcname\ST@tempfunctions@list
+ \ST@Ifinstr\ST@tempfunc{\ST@current@funcname(}% si l'argument contient le nom de fonction courant
+ {\let\ST@function@namefound\ST@current@funcname
+ \ST@left\ST@tempfunc{\ST@current@funcname(}\ST@tempfunc% on réduit l'argument à ce qui est avant ce nom
+ }%
+ {}%
+ \expandafter\expandafter\expandafter\ST@find@firST@func@ii
+ \fi
+ \fi
+}
+
+% la sc #1 commence normalement (sinon, ça va gueuler) par une parenthèse
+% La macro trouve l'argument se trouvant entre les parenthèses les plus extérieures
+% et l'assigne à la sc #2
+\def\ST@seekfunc@arg#1#2{%
+ \begingroup
+ \everyeof{\ST@nil}% met un \@nil à la fin du fichier virtuel
+ \endlinechar\m@ne
+ \catcode\z@12
+ \catcode`(=1 \catcode`)=2
+ \afterassignment\ST@gobble@remain
+ \expandafter\def\expandafter\ST@temp@a\scantokens\expandafter{#1}% Attentionn !!! Il peut rester des ) non équilibrées
+ \catcode`(=12 \catcode`)=12
+ \def\ST@assign@result##1\ST@nil{\endgroup\def#2{##1}}%
+ \expandafter\ST@assign@result\scantokens\expandafter{\ST@temp@a}% on fait l'assignation
+}
+
+\def\ST@func@sum#1#2{% #1 est la sc contenant la plage de valeurs, #2 est la sc recevant le résultat
+ \def#2{0}% résultat nul pour l'instant
+ \let\ST@temp@stack\@empty% pile d'appel temporaire vide aussi au début
+ \ST@for{#1}% on parcourt la <plage de cellules>
+ {\ifnum\numexpr10000*(\ST@colcount@i-\ST@current@colnumber)+\ST@rowcount@i-\ST@current@rownumber=\z@
+ \ST@invalid@range% si la cellule courante est dans la plage, erreur
+ \fi
+ \ifcase\csname code@\number\ST@colcount@i @\number\ST@rowcount@i\endcsname\relax% on ne prend en compte que les code 1 et 2
+ \or% code=1
+ \edef\ST@temp@stack{\ST@temp@stack(\number\ST@colcount@i,\number\ST@rowcount@i)}%
+ \or% code=2
+ \ifx\ST@temp@stack\@empty% on ne prend la peine d'additionner que si toutes les cellules sont calculées
+ \expandafter\STadd\expandafter#2\expandafter#2\csname formula@\number\ST@colcount@i @\number\ST@rowcount@i\endcsname
+ \edef\ST@dependance@tree{\ST@dependance@tree(\number\ST@colcount@i,\number\ST@rowcount@i)}% mise à jour de l'arbre des dépendances
+ \fi
+ \fi
+ }%
+ \ifx\ST@temp@stack\@empty% toutes les cellules dans la plage étaient calculées ?
+ \STclip#2#2% on ôte les 0 inutiles si le calcul a été mené au bout
+ \else
+ \let#2\@empty
+ \edef\ST@stackcall{\ST@temp@stack(\ST@current@colnumber,\ST@current@rownumber)\ST@stackcall}% on met à jour la pile d'appel
+ \fi
+}
+
+\def\ST@func@sumprod#1#2{% #1 est la sc contenant la plage de valeurs, #2 est la sc recevant le résultat
+ \ST@left{#1;};\ST@firstmat
+ \ST@right#1;\ST@othermat
+ \ST@left\ST@firstmat{\@empty:}\ST@temp@a
+ \ST@ifref\ST@temp@a{}\ST@invalid@range
+ \let\ST@mat@firstcol\ST@distant@colnumber
+ \let\ST@mat@firstrow\ST@distant@rownumber
+ \StrBehind\ST@firstmat{\@empty:}[\ST@temp@a]%
+ \ST@ifref\ST@temp@a{}\ST@invalid@range
+ \edef\ST@matcol{\number\numexpr\ST@distant@colnumber-\ST@mat@firstcol}%
+ \edef\ST@matrow{\number\numexpr\ST@distant@rownumber-\ST@mat@firstrow}%
+ \ST@count\@ne
+ \loop% regarde si toutes les matrices ont la même dimension que la 1ere et pour chacune, calcule les vecteurs de décalage par rapport à la première
+ \unless\ifx\ST@othermat\@empty
+ \ST@left{\ST@othermat;};\ST@currentmat
+ \ST@right{\ST@othermat;};\ST@othermat
+ \ST@left{\ST@currentmat:}{\@empty:}\ST@temp@a
+ \ST@ifref\ST@temp@a{}\ST@invalid@range
+ \let\ST@currentmatcol\ST@distant@colnumber
+ \let\ST@currentmatrow\ST@distant@rownumber
+ \expandafter\edef\csname ST@vectorcol@\romannumeral\ST@count\endcsname{\number\numexpr\ST@distant@colnumber-\ST@mat@firstcol}%
+ \expandafter\edef\csname ST@vectorrow@\romannumeral\ST@count\endcsname{\number\numexpr\ST@distant@rownumber-\ST@mat@firstrow}%
+ \ST@right\ST@currentmat{\@empty:}\ST@temp@a
+ \ST@ifref\ST@temp@a{}\ST@invalid@range
+ \edef\ST@currentmatcol{\number\numexpr\ST@distant@colnumber-\ST@currentmatcol}%
+ \edef\ST@currentmatrow{\number\numexpr\ST@distant@rownumber-\ST@currentmatrow}%
+ \unless\ifnum\ST@matcol=\ST@currentmatcol\ST@unmatch@matrixdim\fi% la dimension horizontale ne correspond pas
+ \unless\ifnum\ST@matrow=\ST@currentmatrow\ST@unmatch@matrixdim\fi% la dimension verticale ne correspond pas
+ \advance\ST@count\@ne
+ \repeat
+ \let\ST@temp@stack\@empty% pile d'appel temporaire vide au début
+ \edef\ST@numbermat{\number\ST@count}% c'est le nombre de matrices à multiplier
+ \def#2{0}% résultat nul pour l'instant
+ \ST@for{\ST@firstmat}% pour chaque cellule de la 1ere matrice
+ {\def\ST@inter@result{0}% résultat partiel nul pour l'instant
+ \ifcase\csname code@\number\ST@colcount@i @\number\ST@rowcount@i\endcsname
+ \or% code =1
+ \edef\ST@temp@stack{\ST@temp@stack(\number\ST@colcount@i,\number\ST@rowcount@i)}%
+ \edef\ST@dependance@tree{\ST@dependance@tree(\number\ST@colcount@i,\number\ST@rowcount@i)}% mise à jour de l'arbre des dépendances
+ \or% code=2
+ \ST@cslet\ST@inter@result{formula@\number\ST@colcount@i @\number\ST@rowcount@i}%
+ \fi
+ \ST@count\@ne
+ \loop% on multiplie tous les nombres qui se correspondent dans les matrices
+ \edef\ST@tempcoord{\number\numexpr\ST@colcount@i+\csname ST@vectorcol@\romannumeral\ST@count\endcsname @\number\numexpr\ST@rowcount@i+\csname ST@vectorrow@\romannumeral\ST@count\endcsname}%
+ \ifcase\csname code@\ST@tempcoord\endcsname
+ \def\ST@inter@result{0}% code =0 -> on met le résultat partiel à 0
+ \or% code =1
+ \ST@subst\ST@tempcoord @,%
+ \edef\ST@temp@stack{\ST@temp@stack(\ST@tempcoord)}%
+ \edef\ST@dependance@tree{\ST@dependance@tree(\ST@tempcoord)}% mise à jour de l'arbre des dépendances
+ \or% code=2
+ \expandafter\STmul\expandafter\ST@inter@result\expandafter\ST@inter@result\csname formula@\ST@tempcoord\endcsname
+ \else
+ \def\ST@inter@result{0}% code = autre -> on met le résultat partiel à 0
+ \fi
+ \advance\ST@count\@ne
+ \ifnum\ST@count<\ST@numbermat
+ \repeat
+ \STadd#2#2\ST@inter@result
+ }%
+ \ifx\ST@temp@stack\@empty% toutes les cellules dans la plage étaient calculées ?
+ \STclip#2#2% on ôte les 0 inutiles si le calcul a été mené au bout
+ \else
+ \let#2\@empty
+ \edef\ST@stackcall{\ST@temp@stack(\ST@current@colnumber,\ST@current@rownumber)\ST@stackcall}% on met à jour la pile d'appel
+ \fi
+}
+
+\def\ST@func@id#1#2{\expandafter\def\expandafter#2\expandafter{#1}}
+
+\newif\ifST@gcd
+\def\ST@arithmetic#1#2{% #1 est une liste de nombres séparés par des virgules, #2 la sc qui reçoit leur pgcd ou ppcm selon \ifST@gcd
+ \ST@split{#1},#2\ST@argB
+ \ST@Ifinstr\ST@argB,{\ST@split\ST@argB,\ST@argB\ST@remain\let\ST@next\ST@arithmetic}{\let\ST@remain\@empty\let\ST@next\@gobbletwo}%
+ \let\ST@argA#2%
+ \STeval\ST@argA\ST@argA\STeval\ST@argB\ST@argB% évalue les 2 nombres au cas où il y ait des opérations
+ \STeval#2{trunc(abs(max(\ST@argB,\ST@argA)),0)}%
+ \STeval\ST@argB{trunc(abs(min(\ST@argB,\ST@argA)),0)}%
+ \STifzero\ST@argB\else% si 0, on ignore puisque tous les nombres divisent 0 ou en sont leur multiple
+ \ifST@gcd\else\STmul\ST@argC#2\ST@argB\fi
+ \loop
+ \let\ST@argA\ST@argB
+ \STeval\ST@argB{trunc(#2-trunc(#2/\ST@argB,0)*\ST@argB,0)}% reste de la division #2/\ST@argB
+ \let#2\ST@argA
+ \STifzero\ST@argB\else
+ \repeat
+ \ifST@gcd\else\STeval#2{trunc(\ST@argC/#2,0)}\fi
+ \fi
+ \csname @\ifST@gcd firstofone\else gobble\fi\endcsname{\STifeq#21\let\ST@next\@gobbletwo\fi}% pour le pgcd, inutile de continuer si le pgcd est 1
+ \expandafter\expandafter\expandafter\ST@next\expandafter\expandafter\expandafter{\expandafter#2\expandafter,\ST@remain}#2%
+}
+
+\def\ST@func@gcd#1#2{% #1 est une liste de nombres séparés par des virgules, #2 la sc qui reçoit leur pgcd
+ \ST@gcdtrue\ST@arithmetic{#1}#2%
+}
+
+\def\ST@func@lcm#1#2{% #1 est une liste de nombres séparés par des virgules, #2 la sc qui reçoit leur ppcm
+ \ST@gcdfalse\ST@arithmetic{#1}#2%
+}
+
+% la fonction randint
+\def\ST@func@randint#1#2{% #1=sc contenant l'argument #2: sc recevant le résultat
+ \ST@Ifinstr#1,% s'il y a 2 nombres -> intervalle [nb1;nb2]
+ {\ST@split#1,\ST@limita\ST@limitb
+ \STifeq\ST@limita\ST@limitb\PackageError\STname{Macro function randint require two different numbers}\STseedoc@i\fi
+ \STifgt\ST@limita\ST@limitb
+ \let\ST@temp@a\ST@limitb\let\ST@limitb\ST@limita\let\ST@limita\ST@temp@a
+ \fi
+ \STifint\ST@limita\else\ST@intarg@required\fi
+ \STifint\ST@limitb\else\ST@intarg@required\fi
+ \STrandom#2%
+ \STeval#2{trunc(trunc(#2*(\ST@limitb-\ST@limita+1),0)+\ST@limita,0)}%
+ }%
+ {\STifint#1\else\ST@intarg@required\fi
+ \STrandom#2% s'il n'y a qu'un nombre -> intervalle [0;nb2]
+ \STeval#2{trunc(#2*(#1+1),0)}%
+ }%
+}
+
+\def\ST@func@rand#1#2{\STrandom#2}% #1=sc contenant l'argument (ignoré) #2: sc recevant le résultat
+
+\def\ST@genzeros#1{\if#1m0\expandafter\ST@genzeros\fi}
+
+\def\ST@powerten#1#2{% génère 10^abs(#1) dans la sc #2
+ \edef#2{1\expandafter\ST@genzeros\romannumeral\number\ifnum#1<\z@-\fi#1000\relax}%
+}
+
+\def\ST@func@scitodec#1#2{% #1=sc contenant l'argument #2: sc recevant le résultat
+ \expandafter\lowercase\expandafter{\expandafter\def\expandafter#1\expandafter{#1}}%
+ \ST@Ifinstr#1{ee}% on regarde s'il y a "ee"
+ {\ST@split#1{ee}\ST@mantissa\ST@exposant
+ \ST@powerten\ST@exposant\ST@tenpow
+ \csname ST\ifnum\ST@exposant<\z@ div\else mul\fi\endcsname#2\ST@mantissa\ST@tenpow}%
+ {\IfDecimal#1%
+ {\let#2#1}%
+ {\PackageError\STname{Illegal number in scitodec argument}\STseedoc@i}}%
+}
+% les fonctions de test
+\def\ST@liST@offour#1,#2,#3,#4\@nil{%
+ \def\ST@argA{#1}\def\ST@argB{#2}\def\ST@argC{#3}\def\ST@argD{#4}%
+}
+
+\def\ST@def@funcif#1#2#3{%
+ \expandafter\ST@liST@offour#1\@nil
+ \STeval\ST@argA\ST@argA\STeval\ST@argB\ST@argB
+ \csname STif#3\endcsname\ST@argA\ST@argB
+ \let#2\ST@argC
+ \else
+ \let#2\ST@argD
+ \fi
+}
+
+\def\ST@func@ifeq#1#2{\ST@def@funcif#1#2{eq}}
+\def\ST@func@ifgt#1#2{\ST@def@funcif#1#2{gt}}
+\def\ST@func@iflt#1#2{\ST@def@funcif#1#2{lt}}
+
+% Transforme une date en nombre
+\def\STdatetonum#1#2#3#4{% #1=sc recevant le résultat #2=jj #3=mm #4=aa
+ \STeval#1{#3+9-12*trunc((#3+9)/12,0)}%
+ \STeval\ST@@@year{#4-trunc(#1/10,0)}%
+ \STeval#1{365*\ST@@@year+trunc(\ST@@@year/4,0)-trunc(\ST@@@year/100,0)+trunc(\ST@@@year/400,0)+trunc((#1*306+5)/10,0)+#2-1}%
+ \STclip#1#1%
+}
+
+% Transforme un nombre en une date
+\def\ST@numtodate#1#2#3#4{% #1=nombre représentant la date #2=jour #3=mois #4=année
+ \STeval#4{trunc((10000*#1+14780)/3652425,0)}%
+ \STeval#2{#1-(365*#4+trunc(#4/4,0)-trunc(#4/100,0)+trunc(#4/400,0))}%
+ \STiflt{#2}0%
+ \STadd#4#4{-1}%
+ \STeval#2{#1-(365*#4+trunc(#4/4,0)-trunc(#4/100,0)+trunc(#4/400,0))}%
+ \fi
+ \STeval#3{trunc((100*#2+52)/3060,0)}%
+ \STeval#4{#4+trunc((#3+2)/12,0)}\STclip#4#4%
+ \STeval#2{#2-trunc((#3*306+5)/10,0)+1}\STclip#2#2%
+ \STeval#3{#3+2-12*trunc((#3+2)/12,0)+1}\STclip#3#3%
+}
+
+\def\ST@parse@datefr#1/#2/#3\@nil{\def\ST@@@day{#1}\def\ST@@@month{#2}\def\ST@@@year{#3}}
+
+\def\ST@parse@dateeng#1/#2/#3\@nil{\def\ST@@@day{#3}\def\ST@@@month{#2}\def\ST@@@year{#1}}
+
+% transforme une date française courte du type jj/mm/aaaa en nombre
+\def\ST@func@frshortdatetonum#1#2{% #1=sc étant l'argument jj/mm/aaaa #2=sc recevant le résultat
+ \expandafter\ST@parse@datefr#1\@nil
+ \STdatetonum#2\ST@@@day\ST@@@month\ST@@@year
+}
+
+% Transforme un nombre en une date française de type jj/mm/aaaa
+\def\ST@func@numtofrshortdate#1#2{% % #1=nombre représentant la date #2=sc recevant le résultat
+ \ST@numtodate#1\ST@@@day\ST@@@month\ST@@@year
+ \edef#2{\ST@@@day/\ST@@@month/\ST@@@year}%
+}
+
+% Transforme un nombre en une date longue française du type «14 juillet 1789»
+\def\ST@func@numtofrlongdate#1#2{% % #1=nombre représentant la date #2=sc recevant le résultat
+ \ST@numtodate#1\ST@@@day\ST@@@month\ST@@@year
+ \edef#2{\ST@@@day\space\ifcase\ST@@@month\or janvier\or f\'evrier\or mars\or avril\or mai\or
+ juin\or juillet\or ao\^ut\or septembre\or octobre \or novembre\or d\'ecembre\fi\space\ST@@@year}%
+}
+
+% Extrait d'un nombre représentant une date le mois en toutes lettres en français
+\def\ST@func@numtofrmonth#1#2{% % #1=nombre représentant la date #2=sc recevant le résultat
+ \ST@numtodate#1\ST@@@day\ST@@@month\ST@@@year
+ \edef#2{\ifcase\ST@@@month\or janvier\or f\'evrier\or mars\or avril\or mai\or
+ juin\or juillet\or ao\^ut\or septembre\or octobre \or novembre\or d\'ecembre\fi}%
+}
+
+% Extrait d'un nombre repésentant une date le nom du jour en français
+\def\ST@func@numtofrday#1#2{% % #1=nombre représentant la date #2=sc recevant le résultat
+ \STeval\ST@@@day{#1-7*trunc(#1/7,0)}\STclip\ST@@@day\ST@@@day
+ \edef#2{\ifcase\ST@@@day mercredi\or jeudi\or vendredi\or samedi\or dimanche\or lundi\or mardi\fi}
+}
+
+% transforme une date anglaise courte du type aaaa/mm/jj en nombre
+\def\ST@func@engshortdatetonum#1#2{% #1=sc étant l'argument aaaa/mm/jj #2=sc recevant le résultat
+ \expandafter\ST@parse@dateeng#1\@nil
+ \STdatetonum#2\ST@@@day\ST@@@month\ST@@@year
+}
+
+% Transforme un nombre en une date anglaise de type aaaa/mm/jj
+\def\ST@func@numtoengshortdate#1#2{% % #1=nombre représentant la date #2=sc recevant le résultat
+ \ST@numtodate#1\ST@@@day\ST@@@month\ST@@@year
+ \edef#2{\ST@@@year/\ST@@@month/\ST@@@day}
+}
+
+% Transforme un nombre en une date longue anglaise du type «July 14, 1789»
+\def\ST@func@numtoenglongdate#1#2{% % #1=nombre représentant la date #2=sc recevant le résultat
+ \ST@numtodate#1\ST@@@day\ST@@@month\ST@@@year
+ \edef#2{\ifcase\ST@@@month\or January\or February\or March\or April\or May\or
+ June\or July\or August\or September\or October\or November\or December\fi\space\ST@@@day,\space\ST@@@year}%
+}
+
+% Extrait d'un nombre représentant une date le mois en toutes lettres en anglais
+\def\ST@func@numtoengmonth#1#2{% % #1=nombre représentant la date #2=sc recevant le résultat
+ \ST@numtodate#1\ST@@@day\ST@@@month\ST@@@year
+ \edef#2{\ifcase\ST@@@month\or January\or February\or March\or April\or May\or
+ June\or July\or August\or September\or October\or November\or December\fi}%
+}
+
+% Extrait d'un nombre repésentant une date le nom du jour en anglais
+\def\ST@func@numtoengday#1#2{% % #1=nombre représentant la date #2=sc recevant le résultat
+ \STeval\ST@@@day{#1-7*trunc(#1/7,0)}\STclip\ST@@@day\ST@@@day
+ \edef#2{\ifcase\ST@@@day wednesday\or thursday\or friday\or saturday\or sunday\or monday\or tuesday\fi}
+}
+
+% Teste si la date contenue dans les 3 sc #1 (jour) #2(mois) #3(année) est valide. Sinon, envoie un message d'erreur
+\def\ST@teST@date@validity#1#2#3{%
+ \IfInteger#1{}\ST@invalid@date
+ \IfInteger#2{}\ST@invalid@date
+ \IfInteger#3{}\ST@invalid@date
+ \ifnum#2<\@ne\ST@invalid@date\fi
+ \ifnum#2>12 \ST@invalid@date\fi
+ \ifnum#1<\@ne\ST@invalid@date\fi
+ \ifnum#1>\ifcase#2\or31\or29\or31\or30\or31\or30\or31\or31\or30\or31\or30\or31\fi\ST@invalid@date\fi
+ \ifnum#3<\@ne\ST@invalid@date\fi% on va s'arrêter à JC quand même :-)
+}
+
+% Transforme une date anglaise longue du type «July 14, 1789» en un nombre
+\def\ST@func@englongdatetonum#1#2{% #1=sc contenant la date longue #2=sc recevant le résultat
+ \ST@analyse@text@engdate#1\ST@@@day\ST@@@month\ST@@@year
+ \STdatetonum#2\ST@@@day\ST@@@month\ST@@@year
+}
+
+\def\ST@analyse@text@engdate#1#2#3#4{% #1=texte représentant la date #2=jour #3=n° mois #4=année
+ \ST@remove@firST@spaces#1%
+ \def\ST@today{\today}%
+ \ifx#1\ST@today
+ \edef#2{\number\day}\edef#3{\number\month}\edef#4{\number\year}%
+ \else
+ \ST@left#1\space#3%
+ \ST@removespaces#3%
+ \lowercase\expandafter{\expandafter\def\expandafter#3\expandafter{#3}}%
+ \IfStrEqCase#3{%
+ {january}{\def#3{1}}%
+ {february}{\def#3{2}}%
+ {march}{\def#3{3}}%
+ {april}{\def#3{4}}%
+ {may}{\def#3{5}}%
+ {june}{\def#3{6}}%
+ {july}{\def#3{7}}%
+ {august}{\def#3{8}}%
+ {september}{\def#3{9}}%
+ {october}{\def#3{10}}%
+ {november}{\def#3{11}}%
+ {december}{\def#3{12}}%
+ }[\def#3{-1}]%
+ \ST@right#1\space#2%
+ \ST@Ifinstr#2,{\ST@split#2,#2#4}{\ST@split#2{ }#2#4}%
+ \IfInteger#2{}{\edef#2{\number\integerpart}}%
+ \ST@removespaces#4%
+ \ST@teST@date@validity#2#3#4%
+ \fi
+}
+
+% Transforme une date anglaise longue du type «14 juillet 1789» en un nombre
+\def\ST@func@frlongdatetonum#1#2{% #1=sc contenant la date longue #2=sc recevant le résultat
+ \ST@analyse@text@frdate#1\ST@@@day\ST@@@month\ST@@@year
+ \STdatetonum#2\ST@@@day\ST@@@month\ST@@@year
+}
+
+\def\ST@utfencoding{utf8}
+
+\def\ST@analyse@text@frdate#1#2#3#4{% #1=texte représentant la date #2=jour #3=n° mois #4=année
+ \ST@remove@firST@spaces#1%
+ \def\ST@today{\today}%
+ \ifx#1\ST@today
+ \edef#2{\number\day}\edef#3{\number\month}\edef#4{\number\year}%
+ \else
+ \ST@split#1{ }#2#3%
+ \IfInteger#2{}{\edef#2{\number\integerpart}}%
+ \ST@split#3{ }#3#4%
+ \ST@removespaces#3%
+ \def\ST@e{^^e9}\def\ST@u{^^fb}% é et û en latin1
+ \ifdefined\inputencodingname\ifx\ST@utfencoding\inputencodingname
+ \def\ST@e{^^c3^^a9}\def\ST@u{^^c3^^bb}% é et û en utf8
+ \fi\fi
+ \expandafter\ST@subst\expandafter#3\expandafter{\ST@e}e\ST@subst#3\'{}%
+ \expandafter\ST@subst\expandafter#3\expandafter{\ST@u}u\ST@subst#3\^{}%
+ \expandafter\lowercase\expandafter{\expandafter\def\expandafter\ST@temp@a\expandafter{#3}}%
+ \IfStrEqCase#3{%
+ {janvier}{\def#3{1}}{fevrier}{\def#3{2}}{mars}{\def#3{3}}%
+ {avril}{\def#3{4}}{mai}{\def#3{5}}{juin}{\def#3{6}}%
+ {juillet}{\def#3{7}}{aout}{\def#3{8}}{septembre}{\def#3{9}}%
+ {octobre}{\def#3{10}}{novembre}{\def#3{11}}{decembre}{\def#3{12}}%
+ }
+ [\def#3{-1}]%
+ \ST@teST@date@validity#2#3#4%
+ \fi
+}
+
+\def\ST@func@tag#1#2{%
+ \let#2\@empty
+ \ifcsname ST@@\detokenize\expandafter{#1}\endcsname
+ \PackageWarning\STname{The tag "\detokenize\expandafter{#1}" already exists, previous is lost.}%
+ \fi
+ \expandafter\edef\csname ST@@\detokenize\expandafter{#1}\endcsname{\number\ST@colcount,\number\ST@rowcount}%
+ \ST@expadd@tomacro\ST@tag@list{%
+ \expandafter\let\csname ST@celltag@\detokenize\expandafter{#1}\expandafter\endcsname\csname formula@\number\ST@colcount @\number\ST@rowcount\endcsname}%
+ \expandafter\ST@coord@toref\csname ST@@\detokenize\expandafter{#1}\endcsname
+}
+
+\def\ST@func@cell#1#2{%
+ \unless\ifcsname ST@@\detokenize\expandafter{#1}\endcsname\ST@unknown@tag\fi
+ \edef#2{\csname ST@@\detokenize\expandafter{#1}\endcsname}%
+}
+
+\def\ST@func@row#1#2{%
+ \unless\ifcsname ST@@\detokenize\expandafter{#1}\endcsname\ST@unknown@tag\fi
+ \edef#2{\expandafter\expandafter\expandafter\@gobble\csname ST@@\detokenize\expandafter{#1}\endcsname}%
+}
+
+\def\ST@func@col#1#2{%
+ \unless\ifcsname ST@@\detokenize\expandafter{#1}\endcsname\ST@unknown@tag\fi
+ \edef#2{%
+ \number\numexpr
+ \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+ `\expandafter\expandafter\expandafter\@car\csname ST@@\detokenize\expandafter{#1}\endcsname\@nil-64}%
+}
+
+\def\ST@func@value#1#2{%
+ \ifcsname ST@celltag@\detokenize\expandafter{#1}\endcsname
+ \ST@cslet#2{ST@celltag@\detokenize\expandafter{#1}}%
+ \else
+ \PackageWarning\ST@package@name{The tag "\detokenize\expandafter{#1}" does not exists, have you defined it?}%
+ \def#2{0}% use 0 if tag undefined
+ \fi
+}
+% \def\ST@func@timetosec#1#2{%
+% \ST@left{#1}:\ST@nb@hours
+% \ST@right{#1}:\ST@nb@min
+% \ST@Ifinstr\ST@nb@min:%
+% {\ST@right\ST@nb@min:\ST@nb@sec
+% \ST@left\ST@nb@min:\ST@nb@min
+% }%
+% {\def\ST@nb@sec{0}}%
+% \STeval#2{\ST@nb@sec+60*\ST@nb@min+3600*\ST@nb@hours}%
+% \STclip#2#2%
+% }
+%
+% \def\ST@func@sectotime#1#2{%
+% \STeval\ST@nb@hours{trunc(#1/3600,0)}\STclip\ST@nb@hours\ST@nb@hours
+% \STeval\ST@nb@min{trunc((#1-\ST@nb@hours*3600)/60,0)}\STclip\ST@nb@min\ST@nb@min
+% \STeval\ST@nb@sec{#1-3600*\ST@nb@hours-60*\ST@nb@min}\STclip\ST@nb@sec\ST@nb@sec
+% \edef#2{%
+% \ST@nb@hours
+% :\ifnum\ST@nb@min<10 0\fi\ST@nb@min
+% \ifnum\ST@nb@sec>\z@:\ifnum\ST@nb@sec<10 0\fi\ST@nb@sec\fi}%
+% }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%% Construction du tableau à afficher %%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\ST@search@lastshowcol{% cherche le numéro de la dernière colonne non masquée
+ \ST@colcount\ST@total@colnumber% on commence par la fin
+ \ST@search@lastshowcol@i
+}
+
+\def\ST@search@lastshowcol@i{%
+ \ST@Ifinstr{\ST@col@skiplist}{\expandafter(\number\ST@colcount)}%
+ {\advance\ST@colcount\m@ne\ST@search@lastshowcol@i}%
+ {\edef\ST@lastshowcol{\number\ST@colcount}}%
+}
+
+% cherche "<<ref>>" dans la sc #1 et remplace toutes ces occurences par le champ numérique de "ref"
+\def\ST@displaynumfields#1{%
+ \StrBehind#1\ST@startdisplay[\ST@dipslaycell]%
+ \StrBefore\ST@dipslaycell\ST@enddisplay[\ST@dipslaycell]%
+ \let\ST@next\@gobble% à priori, on ne reboucle pas
+ \unless\ifx\@empty\ST@dipslaycell% si ce qui a entre les marqueurs n'est pas vide
+ \edef\ST@current@colnumber{\number\ST@colcount}\edef\ST@current@rownumber{\number\ST@rowcount}%
+ \ST@ifref\ST@dipslaycell% et si c'est une référence valide
+ {\let\ST@next\ST@startdisplay
+ \ST@expadd@tomacro\ST@next\ST@dipslaycell
+ \ST@expadd@tomacro\ST@next\ST@enddisplay
+ \ST@cslet\ST@dipslaycell{formula@\ST@temp@formula}% alias pour la formule distante
+ \unless\ifx\ST@decsep\ST@decsepfp\ST@substdecsep\ST@dipslaycell\fi% subsitution du séparateur décimal s'il y a lieu
+ \StrSubstitute#1\ST@next\ST@dipslaycell[#1]% on substitue <<ref>> par le champ numérique de la formule distante
+ \let\ST@next\ST@displaynumfields
+ }
+ {}%
+ \fi
+ \ST@next#1%
+}
+
+\def\ST@build@tab{%
+ \ST@rowcount\@ne\ST@colcount\@ne
+ \expandafter\ST@expadd@tomacro\expandafter\ST@tab\csname endrow@0\endcsname% la (ou les) éventuelle ligne supérieure du tableau
+ \ST@build@tab@i
+}
+
+\def\ST@build@tab@i{% reconstitue le tableau à partir des valeurs calculées et des cellules
+ \ifnum\ST@rowcount>\ST@total@rownumber
+ \let\ST@nextcell\relax
+ \else
+ \let\ST@nextcell\ST@build@tab@i
+ \ST@Ifinstr\ST@row@skiplist{\expandafter(\number\ST@rowcount)}% la ligne fait partie de la skiplist ?
+ {\advance\ST@rowcount\@ne}% on passe à la ligne suivante
+ {%
+ \ST@Ifinstr\ST@col@skiplist{\expandafter(\number\ST@colcount)}% la colonne fait partie de la skiplist ?
+ \ST@hiddencoltrue
+ {%
+ \ST@hiddencolfalse
+ \ST@ifvalid@csname{text@\number\ST@colcount @\number\ST@rowcount}% si la cellule existe
+ {\ST@cslet\ST@temp@b{text@\number\ST@colcount @\number\ST@rowcount}% on créé un alias pour le texte
+ \exploregroups
+ \ifnum\csname code@\number\ST@colcount @\number\ST@rowcount\endcsname=\tw@% si la cellule contient un champ numérique
+ \ST@cslet\ST@temp@a{formula@\number\ST@colcount @\number\ST@rowcount}% alias pour la valeur
+ \unless\ifx\ST@decsep\ST@decsepfp\ST@substdecsep\ST@temp@a\fi% et si le "." doit être remplacé par "," on substitue
+ \StrSubstitute[1]\ST@temp@b\STnumericfieldmarker{\expandafter\STprintnum\expandafter{\ST@temp@a}}[\ST@temp@a]% on remplace le flag de formule par la valeur calculée
+ \else% si la cellule ne contient pas de champ numérique
+ \StrDel[1]\ST@temp@b\STnumericfieldmarker[\ST@temp@a]% on enlève l'éventuel marqueur
+ \fi
+ \ST@displaynumfields\ST@temp@a% affiche les champs numériques des cellules entre << et >>
+ \noexploregroups
+ \ST@expadd@tomacro\ST@tab\ST@temp@a% on ajoute la cellule au tableau
+ }
+ {}%
+ }%
+ \advance\ST@colcount\@ne% on passe à la colonne suivante !
+ \ST@ifvalid@csname{code@\number\ST@colcount @\number\ST@rowcount}% y a t-il encore un code défini ensuite ?
+ {\ifnum\csname code@\number\ST@colcount @\number\ST@rowcount\endcsname<\z@% on est dans une cellule contenant \multicol ?
+ \expandafter\ST@firstarg@after\csname text@\number\numexpr\ST@colcount-1@\number\ST@rowcount\endcsname\multicolumn\STmulticol@number% combien de cellules ?
+ \advance\ST@colcount\STmulticol@number% on va voir après le multicol en sautant toutes les valeurs des colonnes intermédiaires
+ \advance\ST@colcount\m@ne
+ \ST@ifvalid@csname{code@\number\ST@colcount @\number\ST@rowcount}% y a t-il un code défini après le multicol ?
+ {\STadd@tomacro\ST@tab&}% on ajoute la tabulation
+ {}%
+ \else% pas de \multicolumn
+ \unless\ifST@hiddencol% si la cellule n'est pas masquée
+ \unless\ifnum\ST@colcount>\ST@lastshowcol% si ce n'est pas la dernière cellule affichée
+ \STadd@tomacro\ST@tab&%on ajoute la tabulation
+ \fi
+ \fi
+ \fi}%
+ {\ST@ifvalid@csname{endrow@\number\ST@rowcount}%
+ {\expandafter\ST@expadd@tomacro\expandafter\ST@tab\csname endrow@\number\ST@rowcount\endcsname}% ajoute la fin de la ligne
+ {}%
+ \ST@colcount\@ne% on remet la colonne à 1
+ \advance\ST@rowcount\@ne% on passe à la ligne suivante
+ }%
+ }%
+ \fi
+ \ST@nextcell
+}
+
+% format des lettres et nombres représentant les coordonnées (helvetica gras très petit)
+\def\ST@debugformat@headers{\usefont{T1}{phv}{b}{n}}
+
+% format utilisé pour les cellules
+\def\ST@debug@format@cells{\usefont{T1}{lmtt}{m}{n}}
+
+\def\ST@colorcell{\ifST@colortblloaded\noexpand\cellcolor[gray]{.6}\fi}
+
+\def\STdebug#1{%
+ \ST@debugmodetrue% on se met en mode débogage
+ \begingroup
+ \def\ST@debuginfo{#1}%
+ \ifmmode\scriptscriptstyle\else\scriptsize\fi
+ \def\ST@temp@a{formula}% pour n'afficher les fins de ligne que dans ce cas
+ \IfStrEqCase\ST@debuginfo{%
+ {formula}{}%
+ {text}{}%
+ {code}{}%
+ }[\ST@illegaldebugcommand]%
+ \ST@debug@format@cells
+ \tabcolsep0.3em
+ \ST@rowcount\@ne\ST@colcount\@ne
+ \edef\ST@debugtab{%
+ \noexpand\begin{tabular}{r|*{\number\numexpr\ST@lastshowcol+1}{c|}}%
+ \noexpand\multicolumn1{c}{\ST@colorcell}&%
+ }%
+ \loop
+ \ST@edefadd@tomacro\ST@debugtab{\noexpand\multicolumn1c{\ST@colorcell\noexpand\ST@debugformat@headers\@Alph\ST@colcount}}%
+ \ifnum\ST@colcount<\ST@lastshowcol
+ \advance\ST@colcount\@ne
+ \STadd@tomacro\ST@debugtab&%
+ \repeat
+ \ST@colcount\@ne
+ \ST@edefadd@tomacro\ST@debugtab{%
+ &% passe à la dernière colonne de la première ligne
+ \noexpand\multicolumn1l{%
+ \ifx\ST@temp@a\ST@debuginfo
+ \ST@ifvalid@csname{endrow@\number\ST@rowcount}%
+ {\detokenize\expandafter\expandafter\expandafter{\csname endrow@0\endcsname}}%
+ {}%
+ \fi}%
+ \noexpand\\\noexpand\cline{2-\number\numexpr\ST@lastshowcol+1}%
+ }%
+ \ST@debug@tab@i
+}
+
+\def\ST@debug@tab@i{% affiche le tableau de débobage
+ \ifnum\ST@rowcount>\ST@total@rownumber
+ \ST@edefadd@tomacro\ST@debugtab{\noexpand\cline{2-\number\numexpr\ST@lastshowcol+1}\noexpand\end{tabular}}%
+ \ST@debugtab% affichage du tableau de débogage
+ \ifmmode\\[0.5ex]\else\par\smallskip\fi% retour à la ligne
+ \expandafter\endgroup
+ \else
+ \ifnum\ST@colcount=\@ne
+ \ST@edefadd@tomacro\ST@debugtab{%
+ \noexpand\multicolumn1{c|}{\ST@colorcell\noexpand\ST@debugformat@headers\number\ST@rowcount}&}%
+ \fi
+ \ifcsname\ST@debuginfo @\number\ST@colcount @\number\ST@rowcount\endcsname% si l'info existe pour la cellule concernée
+ \ifx\ST@temp@a\ST@debuginfo
+ \expandafter\ST@subst\csname\ST@debuginfo @\number\ST@colcount @\number\ST@rowcount\endcsname|{}%
+ \fi
+ \ST@edefadd@tomacro\ST@debugtab{\detokenize\expandafter\expandafter\expandafter{\csname\ST@debuginfo @\number\ST@colcount @\number\ST@rowcount\endcsname}}% on ajoute la cellule au tableau que l'on a detokenisée au préalable
+ \fi
+ \advance\ST@colcount\@ne% on passe à la colonne suivante !
+ \ifnum\ST@colcount>\ST@lastshowcol% si c'est la dernière cellule affichée
+ \ST@edefadd@tomacro\ST@debugtab{%
+ &\noexpand\multicolumn1l{%
+ \ifx\ST@temp@a\ST@debuginfo
+ \ST@ifvalid@csname{endrow@\number\ST@rowcount}%
+ {\detokenize\expandafter\expandafter\expandafter{\csname endrow@\number\ST@rowcount\endcsname}}%
+ {}%
+ \fi}%
+ \noexpand\\\noexpand\cline{2-\number\numexpr\ST@lastshowcol+1}}%
+ \ST@colcount\@ne% on remet la colonne à 1
+ \advance\ST@rowcount\@ne% on passe à la ligne suivante
+ \else% il reste encore des cellules dans la ligne
+ \STadd@tomacro\ST@debugtab&% on ajoute la tabulation
+ \fi
+ \expandafter\ST@debug@tab@i
+ \fi
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%% Environnement spreadtab et macros publiques %%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% définit quelle sera le séquence de conytrôle qui finira les lignes
+% dans les tableaux de spreadtab
+\def\STeol#1{\def\ST@eol{#1}}
+\STeol\\
+
+% renvoie la valeur numérique de la cellule de tag #1
+\def\STtag#1{%
+ \ifcsname ST@celltag@\detokenize\expandafter{#1}\endcsname\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
+ {\csname ST@celltag@\detokenize\expandafter{#1}\endcsname}
+ {\PackageError\STname{Tag "#1" is unknown, have you defined it?}\STseedoc@i
+ }%
+}
+
+\def\STmakegtag#1{\STmakegtag@i#1,\STmakegtag@i,}
+\def\STmakegtag@i#1,{%
+ \ifx\STmakegtag@i#1%
+ \else
+ \def\ST@temp@a{#1}%
+ \ifx\@empty\ST@temp@a
+ \PackageWarning\STname{An empty tag is ignored.}%
+ \else
+ \ifcsname ST@celltag@\detokenize\expandafter{#1}\endcsname
+ \global\expandafter\let\csname ST@celltag@\detokenize\expandafter{#1}\expandafter\endcsname
+ \csname ST@celltag@\detokenize\expandafter{#1}\endcsname
+ \else
+ \PackageError\STname{Tag "#1" is unknown, have you defined it?}\STseedoc@i
+ \fi
+ \fi
+ \expandafter\STmakegtag@i
+ \fi
+}
+
+% définit le séparateur décimal
+\def\STsetdecimalsep#1{\def\ST@decsep{#1}}
+\def\ST@decsepfp{.}% le séparateur décimal donné par fp
+\STsetdecimalsep.% le point par défaut
+
+\STmessage{true}% affiche les messages par défaut
+
+\newif\ifST@clipround
+\def\STautoround{\@ifstar{\ST@cliproundfalse\ST@autoround}{\ST@cliproundtrue\ST@autoround}}
+\def\ST@autoround#1{\def\STrounddigit{#1}}
+\STautoround{}% pas d'arrondi par défaut
+
+\def\STsavecell#1#2{% met dans la sc #1 la valeur du champ numérique de la cellule spécifiée par sa référence ABSOLUE
+ \def\ST@temp@ref{#2}%
+ \ST@ifref\ST@temp@ref{}\ST@illegal@ref
+ \ST@Ifinstr\ST@temp@ref[\ST@illegal@ref{}%
+ \ST@cslet#1{formula@\ST@temp@formula}% le nombre est assigné à #1
+ \unless\ifx\ST@decsep\ST@decsepfp\ST@substdecsep#1\fi% et si le "." doit être remplacé par "," on substitue
+ \global\let#1#1% on rend l'assignation globale
+}
+
+\long\def\ST@get@body@env#1\end{\expandafter\def\expandafter\ST@tab\expandafter{\ST@tab#1}\ST@find@end}
+
+\def\ST@find@end#1{%
+ \def\ST@temp@a{#1}%
+ \ifx\ST@temp@a\STname
+ \expandafter\spreadtab@i
+ \else
+ \STadd@tomacro\ST@tab{\end{#1}}%
+ \expandafter\ST@get@body@env
+ \fi
+}
+
+\long\def\ST@get@body@cs#1\endspreadtab{\def\ST@tab{#1}\spreadtab@i}
+
+\newcommand*\spreadtab[2][]{%
+ \ifx\STname\@currenvir% on vient d'un \begin{spreadtab} ?
+ \endgroup
+ \let\ST@get@body\ST@get@body@env
+ \else
+ \let\ST@get@body\ST@get@body@cs
+ \fi
+ \let\ST@FPmessages\ifFPmessages
+ \if@STfpactive\ifST@message\FPmessagesfalse\fi\fi% pas de message de calcul de FP
+ \saveexpandmode\expandarg% 1-développement des arguments (réglages de xstring)
+ \saveexploremode\noexploregroups% pas d'exploration des groupes (réglages de xstring)
+ \edef\ST@catocde@saved{\catcode`:=\the\catcode`:\relax\catcode`;=\the\catcode`;\relax}%
+ \@makeother\:\@makeother\;% changer les catcodes pour éviter les incompatibilités avec frenchb
+ \def\ST@tab@preamble{#2}% préambule du tableau
+ \StrChar{\@empty#2}\@ne[\ST@tab@name]%
+ \def\ST@optcode{#1}%
+ \let\ST@copylist\@empty
+ \let\ST@row@skiplist\@empty
+ \let\ST@col@skiplist\@empty
+ \def\ST@laST@skipcol{0}%
+ \if@STfpactive
+ \edef\ST@previous@seed{\number\FPseed}% sauvegarde de la graine
+ \STseed% graine variable
+ \fi
+ \ST@emit@message{^^JNew spreadtab: \string\begin\detokenize{#2}^^J* reading tab:}%
+ \let\ST@tab\@empty
+ \ST@get@body% met le code du tableau dans \ST@tab
+}
+
+\def\spreadtab@i{%
+ \let\ST@tag@list\@empty
+ \let\ST@ref@found\@empty
+ \ST@read@tab% analyse le tableau contenu dans \ST@tab
+ \ST@emit@message{ok^^J}%
+ \ST@search@lastshowcol% cherche la dernière colonne affichée
+ \ST@debugmodefalse% à priori, on n'est pas en mode débogage
+ \let\ST@savecell\STsavecell
+ \let\STsavecell\@gobbletwo
+ \let\STdisplaytab\relax
+ \ST@optcode% exécute l'argument optionnel en ne tenant compte que de \STdebug
+ \let\STdebug\@gobble
+ \def\STdisplaytab{%
+ \ST@debugmodefalse
+ \ST@emit@message{\space\space\space\space\space Debug mode: display final tab^^J}%
+ \let\STdisplaytab\relax
+ }%
+ \ST@optcode% exécute l'argument optionnel en ne tenant compte que de \STdisplaytab s'il y figure
+ \unless\ifST@debugmode% si on doit afficher le tableau, on fait le boulot
+ \ST@emit@message{* computing formulas:^^J}%
+ \STeval@tab
+ \let\STsavecell\ST@savecell
+ \ST@optcode% exécute l'argument optionnel en ne tenant compte que de \STsavecell
+ \expandafter\def\expandafter\ST@tab\expandafter{\expandafter\begin\ST@tab@preamble}%
+ \ST@emit@message{* building tab:}%
+ \ST@build@tab
+ \ST@emit@message{ok^^J}%
+ \ST@expadd@tomacro\ST@tab{\expandafter\end\ST@tab@name}%
+ \expandafter\ST@tab% affiche le tableau
+ \fi
+ \ST@emit@message{End of spreadtab: \string\end\detokenize\expandafter{\ST@tab@name}^^J^^J}%
+ \if@STfpactive\FPseed\ST@previous@seed\fi% restauration de la graine
+ \let\ifFPmessages\ST@FPmessages
+ \restoreexpandmode\restoreexploremode
+ \ST@catocde@saved
+ \ST@tag@list
+ \ST@sanitize@cs
+}
+
+\def\ST@sanitize@cs{%
+ \ST@letname{endrow@0}\ST@undef@content
+ \ST@sanitize@cs@i1}
+
+\def\ST@sanitize@cs@i#1{%
+ \unless\ifnum#1>\ST@total@rownumber
+ \def\ST@temp@a{#1}%
+ \ST@letname{endrow@#1}\ST@undef@content
+ \ST@sanitize@cs@ii1%
+ \expandafter\ST@sanitize@cs@i\expandafter{\number\numexpr#1+1\expandafter}%
+ \fi
+}
+
+\def\ST@sanitize@cs@ii#1{%
+ \unless\ifnum#1>\ST@total@colnumber
+ \ST@letname{formula@#1@\ST@temp@a}\ST@undef@content
+ \ST@letname{code@#1@\ST@temp@a}\ST@undef@content
+ \ST@letname{text@#1@\ST@temp@a}\ST@undef@content
+ \expandafter\ST@sanitize@cs@ii\expandafter{\number\numexpr#1+1\expandafter}%
+ \fi
+}
+
+\def\ST@undef@content{\ST@undef@content}
+
+\endinput
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Historique %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+v0.1alpha avril 2009
+-------------------------------------------------------------------------------
+v0.1beta1 2009/06/06
+-------------------------------------------------------------------------------
+v0.1beta2 2009/06/07
+ 1 Une valeur négative dans une cellule provoque un bug.
+ Les valeurs négatives sont désormais mises entre parenthèses
+ 2 Espaces supprimés en début de formules.
+-------------------------------------------------------------------------------
+v0.1beta3 2009/06/12
+ 1 Espaces laissés dans les formules pour pouvoir utiliser la notation
+ postfixée de fp.
+ 2 Les références ne sont plus «@(B4)» mais indifféremment «b4» ou
+ «B4».
+ 3 Références relatives possibles par [x,y] ou x et y sont les
+ décalages de la colonne et de la ligne par rapport à la cellule
+ où est la formule.
+ 4 Bugs corrigés pour rendre le package compatible avec tabularx ou
+ tabulary (entre autres).
+-------------------------------------------------------------------------------
+v0.1beta4 2009/06/21
+ 1 Les espaces sont supprimés au début de chaque cellule, cela
+ créait un bug lorsque la cellule commençait par un nombre négatif.
+ 2 Mise en place de la compatibilité avec la commande
+ \multicolumn{nbre}{type}{contenu} du package éponyme
+ 3 Possibilité de masquer des lignes ou des colonnes entières avec les
+ commandes \SThiderow et \SThidecol
+ Seule condition : aucune colonne masquée ne doit se trouver dans les
+ colonnes impliquées dans un \multicolum à moins de prendre de
+ grandes précautions et savoir les conséquences que cela occasionne.
+-------------------------------------------------------------------------------
+v0.1beta5 2009/06/29
+ 1 Amélioration des messages d'erreur et d'information
+ 2 Suppression de tests superflus
+ 3 Redéfinition de \STtextcell en «@» qui est plus simple
+ 4 Implémentation de \STsavecell
+ 5 écriture de la documentation provisoire en français
+-------------------------------------------------------------------------------
+v0.1beta6 2009/08/23
+ 1 Correction d'un bug : dans une cellule, on ne pouvait pas écrire
+ plusieurs fois la même référence.
+ 2 Correction d'un bug avec \multicolumn : cette commande était mal
+ gérée lorsqu'employée avec une cellule de texte.
+ 3 Implémentation de macro-fonctions avec différenciation selon le
+ type d'argument et le type de donnée renvoyée.
+ 4 Possibilité d'imbrication des macro-fonctions.
+ 5 Mise en place d'un environnement « spreadtab »
+ 6 Nombreuses optimisations pour une meilleure vitesse d'exécution
+-------------------------------------------------------------------------------
+v0.1pre 2009/09/02
+ 1 Mise au point des messages d'erreurs et des arrêts de compilation
+ selon les erreurs rencontrées.
+ 2 Correction d'un bug dans \ST@coord@toref
+ 3 Les cellules vides, textuelles ou jointes par un \multicolumn sont
+ ignorées dans les plages de cellules concernées par les fonctions
+ sum et sumprod
+ 4 Les noms de mois accentués et \today sont désormais permis en
+ argument de la fonction frlongdatetonum
+ 5 somprod corrigé en sumprod, plus anglais !
+ 6 La macro fonction rnd, trop complexe est supprimée au profit de rand
+ et randint
+ 7 Améliorations et optimisations
+-------------------------------------------------------------------------------
+v0.1 2009/11/03 Première version publique sur le CTAN
+-------------------------------------------------------------------------------
+v0.2 2010/01/24
+ 1 On peut définir le séparateur décimal par la macro
+ \STsetdecimalsep{<caractère>}
+ 2 Il est possible de copier une formule dans le tableau à l'aide de
+ \STcopy{>a,vb}{formule} où a et b sont les nombres de cellules
+ horizontaux et verticaux vers lesquels la formule sera copiée.
+ 3 Désormais, spreadtab est entièrement compatible avec toutes les
+ commandes du package booktabs
+ 4 La commande \noalign et son argument est prise en compte lorsqu'elle se
+ trouve après un \\
+ 5 Suppression d'espaces indésirables
+ 6 Mise en place d'un mode débogage où l'on peut visualiser les champs
+ numériques, les champs textuels ou les codes des cellules du tableau
+-------------------------------------------------------------------------------
+v0.2a 2010/02/02
+ 1 Ajout de la traduction en vietnamien et correction d'erreurs dans la
+ documentation française.
+ 2 Implementation beta et donc non visible des macros fonctions gcd, lcm
+ Ces macro-fonctions ne sont pas encore documentées.
+-------------------------------------------------------------------------------
+v0.3 2010/03/28
+ 1 La macro \STautoround{x} admet une version étoilée pour laquelle
+ les nombres sont arrondis et formatés pour avoir x chiffres après
+ la virgule en rajoutant des 0 inutiles si besoin
+ 2 La valeur sauvegardée par \STsavecell tient désormais compte du
+ séparateur décimal
+ 3 Macro fonctions "gcd" (PGCD), "lcm" (PPCM) et "scitodec" pour convertir
+ une écriture scientifique en une écriture décimale
+ 4 Dans le champ textuel d'une cellule, on peut désormais afficher le
+ champ numérique d'une cellule avec <<ref>>
+ 5 Amélioration de l'algorithme pour \STcopy : enleve une formule de
+ \ST@copylist lorsqu'on a dépassé la dernière ligne de la plage
+ où elle doit être copiée
+ 6 Correction d'un bug lorsque la macro-fonction admettant un argument
+ textuel a un argument faisant référence à une autre cellule :
+ enlever ":=" si besoin
+ 7 Correction d'un bug dans xstring qui changeait les catcodes des tokens
+ de \@xs@afterinteger lorsqu'on appelle \IfInteger
+ 8 Correction d'un bug dans \ST@build@tab@i pour prendre en compte les
+ cellules de code 0 dans lesquelles ":=" doit être supprimé
+-------------------------------------------------------------------------------
+v0.3a 2010/05/15
+ 1 Correction d'un bug dans \ST@gobble@remain : ce qui reste à manger
+ peut contenir des tokens de catcode 1 ou 2 ce qui fait que
+ l'utilisation d'arguments délimités ne fonctionnerait pas dans ces
+ cas.
+-------------------------------------------------------------------------------
+v0.3b 2010/06/06
+ 1 Correction d'un bug concernant les macro-fonctions renvoyant un texte.
+ Lorsque leur argument contenait une référence, celle-ci devenait
+ une cellule texte.
+ 2 Correction d'un bug sur la macro \ST@stackcall : il faut y enlever
+ toutes les occurrences de la cellule en train d'être calculée
+ 3 Modification de l'ordre de calcul des cellules concernées par les
+ macro fonctions sum et somprod
+ 4 Correction d'un bug dans la façon dont sont produites les skiplist
+ \ST@row@skiplist et \STcol@skiplist
+ 5 Implémentation de la macro fonction "id"
+-------------------------------------------------------------------------------
+v0.3c 2011/04/08
+ 1 Correction d'un gros bug lors de la substitution d'une référence de
+ type <lettre><nbre> lorsque nbre>10 : a10 était vu comme "a1" suivi
+ de 0, et même pour tous les nbre>10 !
+ 2 Macro \STprintnum
+-------------------------------------------------------------------------------
+v0.4 2011/07/04
+ 1 Les calculs se font en dehors d'un groupe pour éviter l'erreur de
+ save-satck
+ 2 Possibilité d'écrire aussi \spreadtab<code tableau>\endspreadtab
+ 3 Macros fonctions tag, cell, row, col et la macro \STtag qui permet de
+ faire appel à la valeur de la cellule marquée par la macro fonction
+ tag. \STmakegtag rend les sauvegardes globales.
+ 4 La commande \STeol permet de choisir quel est le marqueur de
+ fin de ligne dans les tableau de spreadtab
+ 5 dans une cellule mixte, les macro fonctions renvoyant du texte ont leur
+ résultat qui prend la place de :={<formule>}
+-------------------------------------------------------------------------------
+v0.4a 2011/08/11
+ 1 Un bug corrigé dans \ST@search@hline@i
+-------------------------------------------------------------------------------
+v0.4b 2012/05/13
+ 1 Un bug corrigé dans \ST@func@sum
+-------------------------------------------------------------------------------
+v0.4c 2014/11/06
+ 1 Un bug corrigé dans \ST@analyse@text@frdate et
+ \ST@analyse@text@engdate : si #1 commence par un espace parasite,
+ celui-ci est désormais retiré.
+ 2 Bug corrigé dans \ST@displaynumfields : les macros
+ \ST@current@colnumber et \ST@current@rownumber sont définies avant
+ d'appeler \ST@ifref
+-------------------------------------------------------------------------------
+v0.4d 2018/01/02
+ 1 Bug corrigé dans \STeval@cell : le \edef\ST@dependance@tree corrige
+ le \def !
+ 2 Ajout d'un message d'erreur si une la fonction sum a une plage qui
+ contient la cellule courante elle-même
+ 3 Nouvelle macro fonction "value"
+ 4 Nettoyage du code
+ -------------------------------------------------------------------------------
+v0.5 2019/02/27
+ 1 Choix du moteur de calcul : fp ou xfp \ No newline at end of file