summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2009-04-25 08:04:43 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2009-04-25 08:04:43 +0000
commit4efb9f5021d5bbb11a16ffe52de1c3cc5b05e1d9 (patch)
tree15aefc679e432ac292e41112b31be2e1c38fedeb /Master/texmf-dist
parent8db463317016335cd456246a0b8b4c94c7978755 (diff)
tabularcalc v0.2
git-svn-id: svn://tug.org/texlive/trunk@12817 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/tabularcalc/README2
-rw-r--r--Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.pdfbin158426 -> 186196 bytes
-rw-r--r--Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.tex651
-rw-r--r--Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.pdfbin160898 -> 193253 bytes
-rw-r--r--Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.tex677
-rw-r--r--Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_vn.pdfbin0 -> 548016 bytes
-rw-r--r--Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_vn.tex888
-rw-r--r--Master/texmf-dist/tex/latex/tabularcalc/tabularcalc.sty380
8 files changed, 2032 insertions, 566 deletions
diff --git a/Master/texmf-dist/doc/latex/tabularcalc/README b/Master/texmf-dist/doc/latex/tabularcalc/README
index e7041fc558c..d81e380a690 100644
--- a/Master/texmf-dist/doc/latex/tabularcalc/README
+++ b/Master/texmf-dist/doc/latex/tabularcalc/README
@@ -1,7 +1,7 @@
_________________
tabularcalc package
- v0.1
+ v0.2
_________________
Given a list of numbers and one (or more) formulas, this package allows
diff --git a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.pdf b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.pdf
index b9946dc23c1..70af542a502 100644
--- a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.pdf
+++ b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.tex b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.tex
index 3c80ac6e3d0..a698e07fb72 100644
--- a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.tex
+++ b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_en.tex
@@ -20,16 +20,15 @@
\usepackage[T1]{fontenc}
\usepackage[a4paper,dvips,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,bookmarks=false,pdfauthor={Christian TELLECHEA},pdftitle={tabularcalc},pdfsubject={package for tables of values},pdfkeywords={tabularcalc},pdfcreator={LaTeX}]{hyperref}
\usepackage[a4paper,dvips,margin=2.75cm]{geometry}
-\usepackage{amsmath}
\usepackage[autolanguage]{numprint}
+\usepackage{amsmath}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{lmodern}
\usepackage{xspace}
\usepackage{listings}
-\usepackage{fp}
-\usepackage{pgfmath}
\usepackage{tabularcalc}
+\usepackage[bottom]{footmisc}
\usepackage[frenchb,english]{babel}
\makeatletter
\definecolor{tc@bckgcolor}{rgb}{1,1,0.875}
@@ -39,9 +38,8 @@
\definecolor{tc@comments}{rgb}{0.5,0.5,0.5}
\lstset{%
language=[AlLaTeX]TeX,%
- morekeywords={numexpr},%
float=hbp,%
- basicstyle=\small\ttfamily,%
+ basicstyle=\footnotesize\ttfamily,%
identifierstyle=\color{tc@arguments},%
keywordstyle=\color{tc@keywordslatex},%
commentstyle=\itshape\color{tc@comments},%
@@ -66,22 +64,24 @@
morekeywords={% les macros et commandes de tabularcalc
tccol,tclin,%
htablecalc,vtablecalc,%
- noshowmark,startline,resetcellcode,edefcellcode,defcellcode,%
- sethrule,resethrule,setcoltype,resetcoltype,%
- printvalue,printresult,numberletter,listsep,%
- tc@evalexpr,tc@currentresult},%
+ tcnoshowmark,tcatbeginrow,tcresetcellcode,edefcellcode,defcellcode,%
+ tcsethrule,tcresethrule,tcsetcoltype,tcresetcoltype,%
+ tcprintvalue,tcprintresult,tclistsep,%
+ tc@evalexpr,tc@currentresult,%
+ tcprintroundresult,tcprintroundvalue,%
+ tcuseinfix,tcusepostfix,tcwritetofile},%
keywordstyle=\color{tc@keywordstc},%
classoffset=0}
\makeatother
\newcommand\guill[1]{\og{}#1\fg{}}
\newcommand\argu[1]{$\langle$\textit{#1}$\rangle$}
-\newcommand\ARGU[1]{\texttt{\color{black}\{}\argu{#1}\texttt{\color{black}\}}}
-\newcommand\arguC[1]{\texttt{\color{black}[}\argu{#1}\texttt{\color{black}]}}
+\newcommand\ARGU[1]{\texttt{\{}\argu{#1}\texttt{\}}}
+\newcommand\arguC[1]{\texttt{[}\argu{#1}\texttt{]}}
\newcommand\tbcalc{\textsf{tabularcalc}\xspace}
\newcommand\verbinline{\lstinline[breaklines=false,basicstyle=\normalsize\ttfamily]}
-\newcommand\mywidth{0.75\linewidth}
+\newcommand\mywidth{0.85\linewidth}
\begin{document}
\selectlanguage{english}
@@ -111,11 +111,12 @@
\hfill\textbf{\textit{Abstract}}\hfill{}\medskip\par
Given a list of numbers and one (or more) formulas, this package allows with an easy syntax to build a table of values, i.e a tables in which the first row contains the list of numbers, and the other rows contain the \emph{calculated} values of the formulas for each number of the list:
\begin{center}
- \sethrule{\hline}{\hline\hline}{\hline}
- \def\printvalue#1{\IfInteger{#1}{\nprounddigits{0}}{}\numprint{#1}}
- \def\printresult#1#2{\IfInteger{#1}{\nprounddigits{0}}{}\numprint{#1}}
- \setcoltype{|c|}{>{\centering\arraybackslash}m{1.25cm}|}
- \htablecalc[3]{$x$}{-4,-2,0,2.25,7}{$f(x)=2x-3$}{2*x-3}{$x^2$}{x*x}{$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ \tcsethrule{\hline}{\hline\hline}{\hline}
+ \tcsetcoltype{|c|}{>{\centering\arraybackslash}m{1.5cm}|}
+ \htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
The table can be built either horizontally or vertically, and it is fully customizable (height of rows, columns and lines types). Moreover, the content of any cell can be easily hidden.\smallskip
@@ -128,35 +129,84 @@
\tableofcontents
\bigskip
-\textbf{Attention}: this manual is the laboured\footnote{Indeed, I \textbf{do not speak english}, and I did my best to achieve this translation. Please, be indulgent, and try to take my place and imagine what it would be for you if you had to translate a manual into french, with some old poor school knowledge!} translation of the french manual.
+\textbf{Attention}: this manual is the laboured\footnote{Indeed, I \textbf{do not speak english}, and I did my best to achieve this translation. Please, be indulgent, and try to take my place and imagine what it would be for you if you had to translate a manual into french, with some old poor school knowledge!} translation of the french manual.\medskip
+
+Many thanks to Derek~\textsc{O'Connor} for the interest he brought to this package and the tests he made on beta versions. His pertinent suggestions of new features have been very useful. Without his advice, \tbcalc would not be what it is.\medskip
+
+My thanks also to Le \textsc{Huu Dien Khue} who offered the translation of this manual into Vietnamese.
\section{Introduction}
-This package needs \LaTeX$2\varepsilon$, and if it has not been done before, loads the following packages: \href{http://www.ctan.org/tex-archive/graphics/pgf/base/latex/pgf/math/}{\texttt{\textbf{pgfmath}}}, \href{http://www.ctan.org/tex-archive/macros/latex/contrib/xstring/}{\texttt{\textbf{xstring}}} and \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}}. It makes easily possible to build tables of calculated results coming from formulas for a given list of values. Tables are displayed using the standard \verb|tabular|\footnote{For the moment, the \texttt{tabular} environment is hard coded, but it will probably be possible in the next version to let the user choose another table environment: \texttt{tabularx}, \texttt{tabulary}, \texttt{supertabular}, etc.} environment.
+\subsection{Presentation}
+This package provides commands which make easy possible to build tables of calculated results coming from formulas for a given list of values. Tables are displayed using the standard \verb|tabular| environment.
-The package is called with the usual command \verbinline|\usepackage{tabularcalc}|\smallskip
+\tbcalc needs \LaTeX$2\varepsilon$ and requires \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\texttt{\textbf{fp}}}, \href{http://www.ctan.org/tex-archive/macros/latex/contrib/xstring/}{\texttt{\textbf{xstring}}} and \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} packages.\medskip
-This package is not intended to compete with the excellent \href{http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/}{\texttt{\textbf{pgfplotstable}}} package of Christian \textsc{Feuers\"anger} which has much more extended features, but in compensation, has a difficult to learn syntax. \tbcalc is meant to be more modest and gives priority to customization and easy syntax.\medskip
+This package is not intended to compete with the excellent \href{http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/}{\texttt{\textbf{pgfplotstable}}} package of Christian \textsc{Feuers\"anger} which has much more extended customization features, but in compensation, has a difficult to learn syntax. \tbcalc is meant to be more modest and gives priority to customization and easy syntax.\medskip
-For calculation, the computation of an arithmetic expression such as \verb|2*x*x-5*x+7| when \hbox{\verb|x = 2.7|} is with \TeX{}, a very complex thing that \tbcalc does not make. It leaves this task to a computation engine: "pgfmath" by default. This is why \href{http://www.ctan.org/tex-archive/graphics/pgf/base/latex/pgf/math/}{\texttt{\textbf{pgfmath}}} is loaded. It is possible to choose an other computation engine, see page~\pageref{changemoteurcalcul}.\smallskip
-To display decimal numbers, in my view, nothing is better than the \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} package. This is why it is loaded. The engine used to display decimal numbers can be changed or customized, see page~\pageref{persoaffichage}.\medskip
+To display decimal numbers, in my view, nothing is better than the \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} package. The engine used to display decimal numbers can be changed or customized, see page~\pageref{persoaffichage}.\medskip
-To define vocabulary for later use, in the simple tables below, red numbers are the "{\color{red}values}", blue numbers are the "{\color{blue}results}" and brown texts are the "{\color{brown}labels}". The cell on the up-left corner is the "cell(0,0)":
+\subsection{The {\ttfamily fp} package}
+For calculation, the computation of an expression such as \verb|2*x*x-5*x+7| when \hbox{\verb|x = 2.7|} is, with \TeX{}, a very complex thing that \tbcalc does not make. It leaves this task to a math engine provided by the \verb=fp= package. It provides all usual arithmetic, trigonometric and scientific operations. Moreover, infix and postfix notation are available: see the \href{http://www.ctan.org/get/macros/latex/contrib/fp/README}{\texttt{\textbf{README}}} file for the list of functions available for each notation.\medskip
+I fixed 2 issues in the macro \verb=\FPpow= of the \verb=fp= package\footnote{I did not warn the author of {\ttfamily fp} and I did not ask his permission beacuse he does not maintain his package for a long time now.}. This macro is in charge of power calculation such as $a^b$.
+\parindent2em
+\begin{itemize}
+ \item first of all a spurious space appears when a power is computed. This space is fixed by \tbcalc
+ \item but there is another annoying issue: when \verb=fp= computes $a^b$ it uses this formula $a^b=\mathrm{e}^{b\ln a}$. There is an issue when $b$ is an integer and $a$ is negative. For example: $(-3)^2=\mathrm{e}^{2\ln(-3)}$. The logarithm of a negative number is undefined and \verb=fp= is unable to compute this simple calculation. This bug is fixed and \verb=fp= now computes this kind of calculation properly.
+\end{itemize}\smallskip\parindent0pt
+
+To enable \tbcalc fix these issues, the option "\verb=fixFPpow=" can be declared when calling the package:
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\usepackage[fixFPpow]{tabularcalc}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+
+\subsection{What is new?}
+Unfortunaltely, there are some incompatibilities with other packages because the name of macros of \tbcalc was already used. I decided with a heavy heart to rename almost all the public macros, risking a probable incompatibility with the previous version. I apologize for this inconvenience. I rename them with "\verb=tc=" at their begining:
+\begin{center}
+ \begin{tabular}{rl}
+ Old name&New name\\\hline
+ \verb=\noshowmark=&\verb=\tcnoshowmark= \\
+ \verb=\startline=&\verb=\tcatbeginrow=\\
+ \verb=\resetcellcode=&\verb=\tcresetcellcode=\\
+ \verb=\listsep=&\verb=\tclistsep=\\
+ \verb=\printvalue=&\verb=\tcprintvalue=\\
+ \verb=\printresult=&\verb=\tcprintresult=\\
+ \verb=\sethrule=&\verb=\tcsethrule=\\
+ \verb=\resethrule=&\verb=\tcresethrule=\\
+ \verb=\setcoltype=&\verb=\tcsetcoltype=\\
+ \verb=\resetcoltype=&\verb=\tcresetcoltype=
+ \end{tabular}
+\end{center}
+
+Here is the other new features for the users of the previous version:
+\parindent3em
+\begin{itemize}
+ \item calculation is made with \verb=fp= since \verb=pgfmath= has a poor precision;
+ \item values can be computed;
+ \item the code of a table can be exported in a file.
+\end{itemize}\parindent0pt
+
+\subsection{Vocabulary}
+To define vocabulary for later use, in the simple tables below, red numbers are the "{\color{red}values}", blue numbers are the "{\color{blue}results}" and brown texts are the "{\color{brown}labels}". The cell on the up-left corner is the "cell(0,0)":
\begin{minipage}{0.5\linewidth}
\begin{center}
{\scriptsize Horizontal table}\par\nobreak\smallskip
-\def\printvalue#1{\color{red}$#1$}
-\def\printresult#1#2{\color{blue}\IfInteger{#1}{$\number\integerpart$}{$#1$}}
-\htablecalc[3]{cell (0,0)}{-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
+\def\tcprintvalue#1{\color{red}$#1$}
+\def\tcprintresult#1#2{\color{blue}$#1$}
+\htablecalc[3]{cellule (0,0)}{x=-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
\end{center}
\end{minipage}%
\begin{minipage}{0.5\linewidth}
\begin{center}
{\scriptsize Vertical table}\par\nobreak\smallskip
-\def\printvalue#1{\color{red}$#1$}
-\def\printresult#1#2{\color{blue}\IfInteger{#1}{$\number\integerpart$}{$#1$}}
-\vtablecalc[3]{cell (0,0)}{-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
+\def\tcprintvalue#1{\color{red}$#1$}
+\def\tcprintresult#1#2{\color{blue}$#1$}
+\vtablecalc[3]{cellule (0,0)}{x=-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
\end{center}
\end{minipage}
@@ -164,8 +214,8 @@ To define vocabulary for later use, in the simple tables below, red numbers are
\subsection{Horizontal tables}
The macro \verbinline|\htablecalc| builds horizontal table whose first row contains the "values" and the other rows the "results". The syntax is:\smallskip
-\setbox0=\hbox{\verbinline|\htablecalc|\arguC{number}}
-\verbinline|\htablecalc|\arguC{number}\ARGU{cell (0,0)}\ARGU{value list}\par
+\setbox0=\hbox{\verbinline|\htablecalc|\arguC{n}}
+\verbinline|\htablecalc|\arguC{n}\ARGU{cell (0,0)}\ARGU{variable=list of values}\par
\hskip\wd0\ARGU{label 1}\ARGU{formula 1}\par
\hskip\wd0\ARGU{label 2}\ARGU{formula 2}\par
\hskip\wd0\ldots\par
@@ -173,43 +223,39 @@ The macro \verbinline|\htablecalc| builds horizontal table whose first row conta
where :\parindent1.5em
\begin{itemize}
- \item \argu{number} is the number of formulas (1 by default);
+ \item \argu{n} is the number of formulas (1 by default);
\item \argu{cell (0,0)} is the content of the cell (0,0);
- \item \argu{value list} is the list of values, separated with a comma. Two consecutive commas make an empty column;
- \item \argu{label i} is the i${}^\text{th}$ label;
- \item \argu{formula i} is the $i^\text{th}$ formula, used to calculate the reults of the $i^\text{th}$ row. In formulas, \verb|x| is the variable.
+ \item \argu{variable} is the dummy variable in \argu{formula i} used to compute the results;
+ \item \argu{list of values} is the list of values, separated with a comma. Two consecutive commas make an empty column;
+ \item \argu{label i} is the $i{}^\text{th}$ label;
+ \item \argu{formula i} is the $i^\text{th}$ formula, used to calculate the reults of the $i^\text{th}$ row.
\end{itemize}\parindent0em
\medskip
-
-The variable "\verb|x|" is the expansion of \verbinline|\numberletter|, and at any moment, it is possible to redefine it to another letter, "\verb|y|" for example with a \verbinline|\def\numberletter{y}|.\smallskip
-
-In the list of values, a comma separate values by default. This comma is the expansion of \verbinline|\listsep|, and can be changed to "|" for example with \verbinline=\def\listsep{|}=\medskip
+In the list of values, a comma separates values by default. This comma is the expansion of \verbinline|\tclistsep|, and can be changed to "|" for example with \verbinline=\def\tclistsep{|}=\medskip
For a first example, here is a try to obtain the table of the first page:
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
-\smallskip
\end{minipage}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
-This table is not strictly the same than the table of the first page: integer results have a "0" as decimal part, columns containing results do not have the same width and the line at the bottom of the first row is different.
+This table is not strictly the same than the table of the first page: columns containing results do not have the same width and the line at the bottom of the first row is different. We will see later how to customize this.
\subsection{Vertical tables}
The macro \verbinline|\vtablecalc| builds vertical table whose first column contains the "values" and the other rows the "results". The syntax is:\smallskip
-
-\setbox0=\hbox{\verbinline|\vtablecalc|\arguC{number}}
-\verbinline|\vtablecalc|\arguC{number}\ARGU{cell (0,0)}\ARGU{value list}\par
+\setbox0=\hbox{\verbinline|\vtablecalc|\arguC{n}}
+\verbinline|\vtablecalc|\arguC{n}\ARGU{cell (0,0)}\ARGU{variable=list of values}\par
\hskip\wd0\ARGU{label 1}\ARGU{formula 1}\par
\hskip\wd0\ARGU{label 2}\ARGU{formula 2}\par
\hskip\wd0\ldots\par
@@ -217,10 +263,12 @@ The macro \verbinline|\vtablecalc| builds vertical table whose first column cont
where :\parindent1.5em
\begin{itemize}
- \item \argu{number} is the number of formulas (1 by default);
- \item \argu{value list} is the list of values, separated with a comma;
- \item \argu{label i} is the $i^\text{th}$ label;
- \item \argu{formula i} is the $i^\text{th}$ formula, used to calculate the reults of the $i^\text{th}$ column.
+ \item \argu{n} is the number of formulas (1 by default);
+ \item \argu{cell (0,0)} is the content of the cell (0,0);
+ \item \argu{variable} is the dummy variable in \argu{formula i} used to compute the results;
+ \item \argu{list of values} is the list of values, separated with a comma. Two consecutive commas make an empty column;
+ \item \argu{label i} is the $i{}^\text{th}$ label;
+ \item \argu{formula i} is the $i^\text{th}$ formula, used to calculate the reults of the $i^\text{th}$ row.
\end{itemize}\parindent0em
\medskip
@@ -228,20 +276,20 @@ Here is the previous table, but vertically built:\par\nobreak
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\vtablecalc[3]{$x$}{-4,-2,0,2.25,7}
- {$f(x)=2x-3$}{2*x-3}
- {$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+\vtablecalc[3]{$x$}{y=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*y-3}
+ {$x^2$}{y*y}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,y*y+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\vtablecalc[3]{$x$}{-4,-2,0,2.25,7}
- {$f(x)=2x-3$}{2*x-3}
- {$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+
+\vtablecalc[3]{$x$}{y=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*y-3}
+ {$x^2$}{y*y}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,y*y+1),6)}
\end{center}
-\subsection{How to hide numbers}
+\subsection{How to hide numbers}\label{masquercellules}
The content of any cell can be hidden, as well as in a horizontal or vertical table.
\subsubsection{Hide a value}
@@ -249,21 +297,21 @@ In the list of values, a "\verb|@|" before a value hides it. In the following ex
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\htablecalc[3]{$x$}{-4,@-2,0,2.25,@7}
+\htablecalc[3]{$x$}{x=-4,@-2,0,2.25,@7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\htablecalc[3]{$x$}{-4,@-2,0,2.25,@7}
+
+\htablecalc[3]{$x$}{x=-4,@-2,0,2.25,@7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
\medskip
-Behind the scene, the "\verb|@|" token is the expansion of \verbinline|\noshowmark|. To change this token to "=", this simple code does the job: \verbinline|\def\noshowmark{=}|
+Behind the scene, the "\verb|@|" token is the expansion of \verbinline|\tcnoshowmark|. To change this token to "=", this simple code does the job: \verbinline|\def\tcnoshowmark{=}|
\subsubsection{Hide a result}
If a value is followed by $[a_1][a_2]\ldots[a_n]$ where the numbers $a_i$ are increasing, the results number $a_1,a_2,\ldots,a_n$ will be hidden. If a number $a_j=0$, all the others $a_k$ where $k>j$ will be ignored and the results following the previous hidden result will be hidden.\medskip
@@ -280,51 +328,51 @@ In the example, with the list of values "\verb|-4[2],-2,0[1][3],2.25[0],7[2][0]|
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\htablecalc[3]{$x$}{-4[2],-2,0[1][3],2.25[0],7[2][0]}
+\htablecalc[3]{$x$}{x=-4[2],-2,0[1][3],2.25[0],7[2][0]}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\htablecalc[3]{$x$}{-4[2],-2,0[1][3],2.25[0],7[2][0]}
+
+\htablecalc[3]{$x$}{x=-4[2],-2,0[1][3],2.25[0],7[2][0]}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
This feature can be mixed with "\verb|@|" to hide a value and results.
\subsection{Height of rows}
-At the begining of a row, when it is displayed, the macro \verbinline|\startline| runs.
+At the begining of a row, when it is displayed, the macro \verbinline|\tcatbeginrow| runs.
-By default, this command is defined by: \verbinline|\def\startline{\rule[-1.2ex]{0pt}{4ex}}|. Its expansion is a "strut" which adjusts the height of the row. Here is this strut, made visible before the lettre "a": \rule[-1.2ex]{2pt}{4ex}a\medskip
+By default, this command is defined by: \verbinline|\def\tcatbeginrow{\rule[-1.2ex]{0pt}{4ex}}|. Its expansion is a "strut" which adjusts the height of the row. Here is this strut, made visible before the lettre "a": \rule[-1.2ex]{2pt}{4ex}a\medskip
Any other action, or another strut can be defined:
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\def\startline{%
+\def\tcatbeginrow{%
{\bfseries\number\tclin)\ }%
}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\def\startline{%
+
+\def\tcatbeginrow{%
{\bfseries\number\tclin)\ }%
}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
Here, no strut is defined (the lines recover their natural height), and at line 2 of the code, the number of the row (contained in the counter \verbinline|\tclin|) is displayed with bold chars.
\subsection{Horizontal lines}
-\tbcalc allows to define 3 types of horizontal lines. The macro \verbinline|\sethrule| has 3 arguments:
+\tbcalc allows to define 3 types of horizontal lines. The macro \verbinline|\tcsethrule| has 3 arguments:
\parindent1.5em
\begin{itemize}
@@ -334,7 +382,7 @@ Here, no strut is defined (the lines recover their natural height), and at line
\end{itemize}\parindent0em
Here is the syntax:
-\verbinline|\sethrule|\ARGU{line 0}\ARGU{line 1}\ARGU{other lines}
+\verbinline|\tcsethrule|\ARGU{line 0}\ARGU{line 1}\ARGU{other lines}
\medskip
By default, the three arguments contain \verbinline|\hline|.\medskip
@@ -343,26 +391,26 @@ This is an example in which the "line 1" is a double line, and the "other lines"
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\sethrule{\hline}{\hline\hline}{}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\tcsethrule{\hline}{\hline\hline}{}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{lstlisting}
\end{minipage}
-\smallskip
-\sethrule{\hline}{\hline\hline}{}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+
+\tcsethrule{\hline}{\hline\hline}{}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{center}
-The command \verbinline|\resethrule| resets the defined lines and restores the default lines.
+The command \verbinline|\tcresethrule| resets the defined lines and restores the default lines.
\subsection{Customizing columns}
\subsubsection{Vertical lines}
-2 types of column can be defined: the type of the left one and the type of others columns. The command \verbinline|\setcoltype| has an optionnal argument and 2 mandatory arguments:
+2 types of column can be defined: the type of the left one and the type of others columns. The command \verbinline|\tcsetcoltype| has an optionnal argument and 2 mandatory arguments:
\begin{itemize}
\item the optional argument, empty by default, defines the vertical lines at the right of the table;
\item the "type 1" of the first column, set to "\verb-|c|-" by default;
@@ -370,28 +418,28 @@ The command \verbinline|\resethrule| resets the defined lines and restores the d
\end{itemize}\medskip
The syntax of the command is:\par\nobreak
-\verbinline|\setcoltype|\arguC{right lines}\ARGU{type 1}\ARGU{type 2}\medskip
+\verbinline|\tcsetcoltype|\arguC{right lines}\ARGU{type 1}\ARGU{type 2}\medskip
In this example, a double line is displayed at the right of the table (\verb=[||]=), and on the edges of the first column (\verb=||c||=). The other columns do not have vertical lines (\verb|c|):
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\setcoltype[||]{||c||}{c}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\tcsetcoltype[||]{||c||}{c}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{lstlisting}
\end{minipage}
-\smallskip
-\setcoltype[||]{||c||}{c}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+
+\tcsetcoltype[||]{||c||}{c}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{center}
-\verbinline|\resetcoltype| restores the default vertical lines.
+\verbinline|\tcresetcoltype| restores the default vertical lines.
\subsubsection{Width of columns}
Instead of the usual column type "\verb|c|" used until now, other types of column can be specified: for example, the "\verb|m|" type of the \href{http://www.ctan.org/tex-archive/graphics/pgf/base/latex/pgf/basiclayer/}{\texttt{\textbf{array}}} package allows to set the width of columns this way: \verb|m{1.5cm}|.\medskip
@@ -401,29 +449,124 @@ In this example, the first column is right aligned, and the other columns are ce
\begin{minipage}{\mywidth}
\begin{lstlisting}
\usepackage{array}
-\setcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\tcsetcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\setcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+
+\tcsetcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{center}
+
+\section{How to compute the values?}
+When values can be calculated with a math formula, it may be more simple to write the formula than all the values. This code:
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[2]{$x$}{x=-3,-1,1,3,5,7,9,11,13}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+can be replaced by this shorter oneo:
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[2]{$x$}{x=a;a=-3:13[2]}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+The presence of a "\verb=;=" changes the analysis of the argument: on the right of "\verb=;=" we say that the dummy variable "\verb=a=" varies between $-3$ and 13 with a step of 2. Therefore is an \emph{odd} integer. On the left of "\verb=;=" we say that the dummy variable --~here \verb=x=~-- involved in the formulas used to compute the results is equal to \verb=a= and consequently the values are odd integers between $-3$ and 13.
+
+These values could have been generated with this argument \verb|{x=2*a+1:a=-2:6}| (the step is 1 by default) or this other one \verb|{x=2*a-3;a=0:8}|, or another one because there are several way to generate a set of values.\bigskip
+
+When using an argument with "\verb=;=", the feature enabling to hide cells (see page~\pageref{masquercellules}) is not available. Moreover, the user should be aware of the number of generated values to avoid huge tables.\medskip
+
+With a "\verb=;=", the syntax of the argument is:\par\smallskip\nobreak
+\hfill\argu{variable 1}\verb|=|\argu{formula}\verb|;|\argu{variable 2}\verb|=|\argu{min}\verb|:|\argu{max}\arguC{step}\hfill{}\smallskip
+
+where:
+\begin{itemize}
+ \item \argu{variable 1} is the dummy variable involved in the formulas used to compute the results;
+ \item \argu{variable 2} is the dummy variable involved in the formulas used to compute the values; it must be different from \argu{variable 1};
+ \item \argu{formula} is the formula used to compute the values. The variable in this formula is \argu{variable 2};
+ \item \argu{min}\verb|:|\argu{max} is the interval in which \argu{variable 2} varies;
+ \item \argu{step} is the step added to \argu{variable 2} until it reaches \argu{max} or more. It is optional and its defaul value is 1. It must be different from 0.
+\end{itemize}\parindent0em
+\medskip
+
+There are many different ways to generate the same set of values.
+
+For example, the values \texttt{\{0,1,2,3,4,5,6,7,8,9,10\}} can be generated with:
+
+\parindent2em
+\begin{itemize}
+ \item \verb|{z=x;x=0:10}| and \og\verb=z=\fg{} will be the dummy variable in formulas;
+ \item \verb|{n=2*a;a=0:5[0.5]}| and \og\verb=n=\fg{} will be the dummy variable in formulas;
+ \item \verb|{x=y/10;y=0:100[10]}| and \og\verb=x=\fg{} will be the dummy variable in formulas;
+\end{itemize}
+\parindent0pt\medskip
+
+The value of \argu{step} and \argu{min}\verb|:|\argu{max} must be coherent: \verb|0:10[-1]| will provoke an error message from \tbcalc!\medskip
+
+This is an example using the trigonometric functions of \verb|fp|:
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[6]{$x$\ [deg]}{x=a;a=15:75[15]}
+ {$\sin x$}{round(sin(x*pi/180),6)}
+ {$\cos x$}{round(cos(x*pi/180),6)}
+ {$\tan x$}{round(tan(x*pi/180),6)}
+ {$\sin^2x$}{round(sin(x*pi/180)^2,6)}
+ {$\cos^2x$}{round(cos(x*pi/180)^2,6)}
+ {$\tan^2x$}{round(tan(x*pi/180)^2,6)}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc[6]{$x$\ [deg]}{x=a;a=15:75[15]}
+ {$\sin x$}{round(sin(x*pi/180),6)}
+ {$\cos x$}{round(cos(x*pi/180),6)}
+ {$\tan x$}{round(tan(x*pi/180),6)}
+ {$\sin^2x$}{round(sin(x*pi/180)^2,6)}
+ {$\cos^2x$}{round(cos(x*pi/180)^2,6)}
+ {$\tan^2x$}{round(tan(x*pi/180)^2,6)}
+\end{center}
+\medskip
+
+And here is another table displaying powers of 10, their decimal logarithm, their square root and their inverse:
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[3]{Power of 10}{x=round(10^n,4);n=-3:3}
+ {Decimal logarithm}{ln(x)/ln(10)}
+ {Square root}{round(root(2,x),3)}
+ {Inverse}{1/x}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc[3]{Power of 10}{x=round(10^n,4);n=-3:3}
+ {Decimal logarithm}{ln(x)/ln(10)}
+ {Square root}{round(root(2,x),3)}
+ {Inverse}{1/x}
\end{center}
\section{Advanced customization}
-\subsection{How to execute a code in a cell}
+\subsection{Put a code in a cell}
The command \verbinline|\defcellcode| allows to execute any code in a unique cell, or in every cells of a row or in every cells of a column. Cells have the following coordinates:
\begin{center}
- \def\printvalue#1{}\def\printresult#1#2{}
+ \def\tcprintvalue#1{}\def\tcprintresult#1#2{}
\edefcellcode{}{}{(\number\tclin,\number\tccol)}
- \htablecalc[3]{}{1,2,3,4,5}{}{}{}{}{}{}
+ \htablecalc[3]{}{x=1,2,3,4,5}{}{x}{}{x}{}{x}
\end{center}
\medskip
@@ -456,23 +599,23 @@ In this example, with the package \verb|xcolor|, the cell (2~,~3) is colored in
\defcellcode{2}{3}{\color{blue}}
\defcellcode{1}{}{\color{red}}
\defcellcode{}{4}{\color{brown}}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{lstlisting}
\end{minipage}
-\smallskip
+
\defcellcode{2}{3}{\color{blue}}
\defcellcode{1}{}{\color{red}}
\defcellcode{}{4}{\color{brown}}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{center}
-Notice that the cell (1~,~4) whose content is {\color{brown}\numprint{2.0}} has been colored in red (line 3 of the code) \emph{and then} in brown (line 4 of the code).\bigskip
+Notice that the cell (1~,~4) whose content is {\color{brown}\numprint{2}} has been colored in red (line 3 of the code) \emph{and then} in brown (line 4 of the code).\bigskip
Another similar command is provided to execute code in a cell: \verbinline|\edefcellcode|. With this command, the code is expanded a first time with an \verbinline|\edef|\footnote{If a command must not be expanded at this time, a \texttt{\string\noexpand} must be put before it.} when cell is built: at this time, the counter \verbinline|\tccol| does contain the number of the column. Then, the expansion obtained is runned a second time when cell is displayed.\medskip
@@ -483,16 +626,16 @@ In this example, text is blue if the column number is greater than 2:
\usepackage{color}
\edefcellcode{}{}{%
\ifnum\tccol>2 \noexpand\color{blue}\fi}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{lstlisting}
\end{minipage}
-\smallskip
+
\edefcellcode{}{}{%
\ifnum\tccol>2 \noexpand\color{blue}\fi}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
@@ -500,210 +643,250 @@ In this example, text is blue if the column number is greater than 2:
\subsection{Customizing the number display}
\subsubsection{Macros {\ttfamily\textbackslash printvalue} and {\ttfamily\textbackslash printresult}}\label{persoaffichage}
-To display a value, the macro \verbinline|\printvalue| is called. It requires one argument: the number to display which comes from \verb|pgfcalc|. This argument has a raw format: \verb|12345.6789| for "\numprint{12345.6789}".
+To display a value, the macro \verbinline|\tcprintvalue| is called. It requires one argument: the number to display which comes from \verb|pgfcalc|. This argument has a raw format: \verb|12345.6789| for "\numprint{12345.6789}".
-By default, \verbinline|\printvalue| is defined with this code:\par\nobreak\smallskip
-\hfill\verbinline|\def\printvalue#1{\numprint{#1}}|\hfill{}
+By default, \verbinline|\tcprintvalue| is defined with this code:\par\nobreak\smallskip
+\hfill\verbinline|\def\tcprintvalue#1{\numprint{#1}}|\hfill{}
\smallskip
Notice that the macro \verb|\numprint| is called to print the number.\bigskip
-To display a result, the macro \verbinline|\printresult| is called. It requires \textbf{two} arguments: the first is the number to display in raw format coming from \verb|pgfcalc| and the second is the value used to compute the result.
+To display a result, the macro \verbinline|\tcprintresult| is called. It requires \textbf{two} arguments: the first is the number to display in raw format coming from \verb|pgfcalc| and the second is the value used to compute the result.
-By default, \verbinline|\printresult| is defined with this code:\par\nobreak\smallskip
-\hfill\verbinline|\def\printresult#1#2{\numprint{#1}}|\hfill{}
+By default, \verbinline|\tcprintresult| is defined with this code:\par\nobreak\smallskip
+\hfill\verbinline|\def\tcprintresult#1#2{\numprint{#1}}|\hfill{}
\smallskip
-Notice that the argument \verb|#2| (the value) is ignored by \verbinline|\printresult|. But it is easy to imagine an example in which it would not be. In this example, a red "\verb|X|" is printed if the lenght of the square (which is argument \verb|#2|) is negative. If not, the result with the unit is printed. For the pleasure of customization, any result less than 10 is printed in blue:\par\nobreak
+Notice that the argument \verb|#2| (the value) is ignored by \verbinline|\tcprintresult|. But it is easy to imagine an example in which it would not be. In this example, a red "\verb|X|" is printed if the lenght of the square (which is argument \verb|#2|) is negative. If not, the result with the unit is printed. For the pleasure of customization, any result less than 10 is printed in blue:\par\nobreak
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
\usepackage{color}
-\def\printresult#1#2{%
+\def\tcprintresult#1#2{%
\ifdim#1pt<10pt\color{blue}\fi
\ifdim#2pt<0pt
\color{red}\texttt{X}%
\else
\numprint[cm^2]{#1}%
\fi}
-\htablecalc{length}{0.7,-10,3,-2,5,12}
+\htablecalc{length}{x=0.7,-10,3,-2,5,12}
{Area of square}{x*x}
\end{lstlisting}
\end{minipage}
\smallskip
-\def\printresult#1#2{%
+\def\tcprintresult#1#2{%
\ifdim#1pt<10pt\color{blue}\fi
\ifdim#2pt<0pt
\color{red}\texttt{X}%
\else
\numprint[cm^2]{#1}%
\fi}
-\htablecalc{length}{0.7,-10,3,-2,5,12}{Area of square}{x*x}
+\htablecalc{length}{x=0.7,-10,3,-2,5,12}{Area of square}{x*x}
\end{center}
-A remark: when the length is \numprint[cm]{0.7}, the result is slightly wrong. It should be \numprint[cm^2]{0.49} instead of \numprint[cm^2]{0.48999}! The \verb|pgfmath| package is not suitable for scientific computation as it is inteded to compute coordinates for drawing purposes. This is why its precision is $\frac{1}{\numprint{100000}}$ and sometimes leads to results including rounding errors such as this one.
-
\subsubsection{How to control the rounding of numbers}
-With integer results, the \verb|pgfmath| package, though excellent, has a annoying drawback: when the result of the computation is an integer, the returned number has a decimal part "\verb|0|" (see table above). To avoid this, the result can be tested with \verb|\IfInteger| of \verb|xstring| package, and if it is an integer, give to \verb|\numprint| the value of the \verb|\integerpart| counter (see xtring donumentation):
+Results of calculation coming from \verb=fp= have a good precision, and decimal resultas have often many digits. Here is, for example the decimal value of $\sqrt{10}$, computed by \verb=fp=:
+\begin{center}\FPeval\truc{root(2,10)}\numprint\truc\end{center}
+The first 11 digits are right, the 12${}^{\text{th}}$ is rounded.\medskip
+
+To display results, the \verb|round(number,precision)| of \verb=fp= can be used. To avoid writing many times \verb|round(number,precision)| in the code, \tbcalc provides \verbinline|\tcprintroundresult|. Its mandatory argument is the precision of the decimal part. The starred macro \verbinline|\tcprintroundresult*| fills the decimal part with "0" if necessary. If the argument is empty, no rounding is done (default behaviour).
+\begin{center}
+\begin{minipage}{0.5\linewidth}
\begin{center}
-\begin{minipage}{\mywidth}
\begin{lstlisting}
-\def\printresult#1#2{%
- \IfInteger{#1}%
- {\numprint{\number\integerpart}}%
- {\numprint{#1}}%
-}
-\htablecalc{$x$}{-3,1.56,2.5,3.608}{$2x$}{2*x}
+\tcprintroundresult{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{lstlisting}
+\tcprintroundresult{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{center}
+\end{minipage}%
+\begin{minipage}{0.5\linewidth}
+\begin{center}
+\begin{lstlisting}
+\tcprintroundresult*{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
\end{lstlisting}
+\tcprintroundresult*{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{center}
\end{minipage}
-\smallskip
-\def\printresult#1#2{%
- \IfInteger{#1}%
- {\numprint{\number\integerpart}}%
- {\numprint{#1}}%
-}
-\htablecalc{$x$}{-3,1.56,2.5,3.608}{$2x$}{2*x}
\end{center}
-It is also possible to force \verb|numprint| to round its argument with the command \verb|\nprounddigits| whose argument is the number of figures of the decimal part. Unfortunately, if needed, unnecessary \verb|0| are added to fill the decimal part to match the number of figures.
+To round values, it is not adviced to use the \verb|round| function of \verb=fp= since the rounded values will be used to compute the results, and rounding errors may add up. In this example, the values (square roots of integers) are the are rounded at $10^{-2}$, and the results are the square of values:
+\begin{center}
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\htablecalc{squre roots}{x=round(root(2,k),2);k=2:4}
+ {square}{x*x}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc{squre roots}{x=round(root(2,k),2);k=2:4}
+ {square}{x*x}
+\end{center}
+It is obvious that rounding errors are taken into account to compute results.
+
+It is better to use \verbinline|\tcprintroundvalue| which works like \verbinline|\tcprintroundresult|:
+\begin{center}
+\begin{lstlisting}
+\tcprintroundvalue{2}
+\htablecalc{squre roots}{x=root(2,k);k=2:4}
+ {square}{x*x}
+\end{lstlisting}
+\tcprintroundvalue{2}
+\htablecalc{squre roots}{x=root(2,k);k=2:4}
+ {square}{x*x}
+\end{center}
+The results --~which are not rounded~-- are much nearer the expected integers.
\subsubsection{For the fun}
-Other uses of this package can be designed, such as the drawing of a chess board which squares are \numprint[cm]{0.5} long:\par\nobreak\parindent1.5em
+Other uses of this package can be designed, such as the drawing of a chess board whose squares are \numprint[cm]{0.5} long:\par\nobreak\parindent1.5em
\begin{itemize}
- \item on line 2, the separators of the table are initialzes at \verb|0pt| to obtain the length of \numprint[cm]{0.5};
- \item the display of values and results is cancelled at line 3;
- \item horizontal lines of the top and bottom of the table are drawn (line 4), and vertical lines of the left and right (line 5);
- \item a strut \numprint[cm]{0.5} height is defined to be displayed at the begining of every row (line 6);
- \item finally, if the sum of the row number and the column number is odd, the square is filled of gray (line 8 and 9).
+ \item on line 1, the separators of the table are initialzes at \verb|0pt| to obtain the length of \numprint[cm]{0.5};
+ \item the display of values and results is cancelled at line 2;
+ \item horizontal lines of the top and bottom of the table are drawn (line 3), and vertical lines of the left and right (line 4);
+ \item a strut \numprint[cm]{0.5} height is defined to be displayed at the begining of every row (line 5);
+ \item finally, if the sum of the row number and the column number is odd, the square is filled of gray (line 7 and 8).
\end{itemize}\parindent0em
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\usepackage{colortbl,xcolor}
\arraycolsep=0pt\tabcolsep=0pt
-\def\printvalue#1{}\def\printresult#1#2{}
-\sethrule{\hline}{}{}
-\setcoltype[|]{|m{0.5cm}}{m{0.5cm}}
-\def\startline{\rule[-0.2cm]{0pt}{0.3cm}}
+\def\tcprintvalue#1{}\def\tcprintresult#1#2{}
+\tcsethrule{\hline}{}{}
+\tcsetcoltype[|]{|m{0.5cm}}{m{0.5cm}}
+\def\tcatbeginrow{\rule[-0.2cm]{0pt}{0.3cm}}
\edefcellcode{}{}{%
\ifodd\numexpr\tccol+\tclin\relax
\noexpand\cellcolor{lightgray}\fi
}
-\htablecalc[7]{}{ , , , , , , }
- {}{}{}{}{}{}{}{}{}{}{}{}{}{}
+\htablecalc[7]{}{x=1,2,3,4,5,6,7}
+ {}{x}{}{x}{}{x}{}{x}{}{x}{}{x}{}{x}
\end{lstlisting}
\end{minipage}
-\smallskip
+
\arraycolsep=0pt\tabcolsep=0pt
-\def\printvalue#1{}\def\printresult#1#2{}
-\sethrule{\hline}{}{}
-\setcoltype[|]{|m{0.5cm}}{m{0.5cm}}
-\def\startline{\rule[-0.2cm]{0pt}{0.3cm}}
+\def\tcprintvalue#1{}\def\tcprintresult#1#2{}
+\tcsethrule{\hline}{}{}
+\tcsetcoltype[|]{|m{0.5cm}}{m{0.5cm}}
+\def\tcatbeginrow{\rule[-0.2cm]{0pt}{0.3cm}}
\edefcellcode{}{}{%
\ifodd\numexpr\tccol+\tclin\relax
\noexpand\cellcolor{lightgray}\fi
}
-\htablecalc[7]{}{ , , , , , , }
- {}{}{}{}{}{}{}{}{}{}{}{}{}{}
+\htablecalc[7]{}{x=1,2,3,4,5,6,7}
+ {}{x}{}{x}{}{x}{}{x}{}{x}{}{x}{}{x}
\end{center}
-\section{How to change the computation engine}\label{changemoteurcalcul}
-\verb|pgfmath| is the computation engine used by default, but it can be changed though there is not many other choices: as far as I know, \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\texttt{\textbf{fp}}} and \href{http://www.ctan.org/tex-archive/macros/generic/xlop/}{\texttt{\textbf{xlop}}} are able to compute math expression under \LaTeX. Both have drawbacks, this is why they are not used by default:\par\nobreak\parindent1.5em
-\begin{itemize}
- \item "\verb|fp|" uses the Reverse Polish Notation (RPN). It is possible to use the infix notation but the opposite sign "${}-{}$" before a number is not accepted: very annoying for negative values!
- \item "\verb|xlop|" is not really a computation package as it also prints its results. And unfortunately, only arithmetic calculation is possible.
-\end{itemize}\parindent0em
-\medskip
+\section{Export a table in a file}
+No matter how customizable \tbcalc is, some tables need fine adjustments by the user at the keyboard. The \verbinline=\tcwritetofile=\ARGU{filename} has a mandatory argument which is the name of a file without extension. The next \verbinline=\htablecalc= or \verbinline=\vtablecalc= after this command will not display the tables, but a file named \argu{filename}\verb|.tex| will be written in the current directory, and its content will be the code of the table.\medskip
-The macro \verbinline|\tc@evalexpr| is in charge of computation. It has no argument and it works like this: it expands \verbinline|\tc@currentresult| whose expansion is the math expression to compute (for example "\verb|4*2.5*2.5-3*2.5-7|"). It calls the computation engine to achieve the calculation (in this example, it would be \verb|10.5|), and finally it assigns this result to \verbinline|\tc@currentresult|.
-
-By default, the macro \verbinline|\tc@evalexpr| is defined with this code:\par\nobreak
+Here is an example:
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\def\tc@evalexpr{%
- \expandafter\pgfmathparse
- \expandafter{\tc@currentresult}%
- \let\tc@currentresult\pgfmathresult}
+\tcwritetofile{mytable}
+\defcellcode{}{2}{\color{blue}}
+\htablecalc[2]{$x$}{x=k;k=0:4}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\tcresetcellcode
\end{lstlisting}
\end{minipage}
\end{center}
-
-Let us suppose we want to to use the \verb|fp| package for the computation. Let us redefine \verbinline|\tc@evalexpr|:\par\nobreak
+\tcwritetofile{mytable}
+\defcellcode{}{2}{\color{blue}}
+\htablecalc[2]{$x$}{x=k;k=0:4}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\tcresetcellcode
+
+A file \og\verb=mytable.tex=\fg{} is created in the current directory and its content is the code of the table:
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\makeatletter
-\def\tc@evalexpr{%
- \expandafter\FPeval\expandafter
- \tc@currentresult\expandafter{\tc@currentresult}%
- \FPclip\tc@currentresult\tc@currentresult
-}
-\makeatother
+\begin {tabular}{|c|*{5}{c|}}\hline
+\tcatbeginrow $x$&\tcprintvalue {0}&\color {blue}\tcprintvalue {1}&\tcprintvalue {2}&\tcprintvalue {3}&\tcprintvalue {4}\\\hline
+\tcatbeginrow $2x$&\tcprintresult {0}{0}&\color {blue}\tcprintresult {2}{1}&\tcprintresult {4}{2}&\tcprintresult {6}{3}&\tcprintresult {8}{4}\\ \hline
+\tcatbeginrow $x^2$&\tcprintresult {0}{0}&\color {blue}\tcprintresult {1}{1}&\tcprintresult {4}{2}&\tcprintresult {9}{3}&\tcprintresult {16}{4}\\ \hline
+\end {tabular}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+The user can modify this code, and then this file can be included in the \LaTeX{} code with:
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\input{mytable.tex}
\end{lstlisting}
\end{minipage}
\end{center}
+and here is the result:
+\begin{center}
+\input{mytable.tex}
+\end{center}
+
+\section{Use infix or postfix notation}
+Infix or postfix notation can be used since \verb=\FPeval= accepts both. In this exaple, the same table is generated with each notation. The result is exactly the same since only notation changes while math engine is the same:
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\tcprintroundvalue{6}
+\tcprintroundresult{6}
+With infix notation\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=10^k;k=-3:3}
+ {$\log x$}{ln(x)/ln(10)}
+ {$\sqrt{x}$}{root(2,x)}
+ {$\frac{1}{x}$}{1/x}
-The command \verb|\FPclip| removes unnecessary \verb|0| from the result (see \verb|fp| documentation).
+\medskip
+With postfix notation\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=k 10 pow;k=-3:3}
+ {$\log x$}{x ln 10 ln div}
+ {$\sqrt{x}$}{2 x root}
+ {$\frac{1}{x}$}{1 x div}
+\end{lstlisting}
+\end{minipage}
-We have done it: the computation engine of \tbcalc is now \verb|fp|:\par\nobreak
+\tcprintroundvalue{6}
+\tcprintroundresult{6}
+With infix notation\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=10^k;k=-3:3}
+ {$\log x$}{ln(x)/ln(10)}
+ {$\sqrt{x}$}{root(2,x)}
+ {$\frac{1}{x}$}{1/x}
+
+\medskip
+With postfix notation\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=k 10 pow;k=-3:3}
+ {$\log x$}{x ln 10 ln div}
+ {$\sqrt{x}$}{2 x root}
+ {$\frac{1}{x}$}{1 x div}
+\end{center}
+If possible and if the user is used to it, the postfix notation should be prefered beacuse it often saves computation times. Indeed, to compute $\cos x(1-\cos x)$, here is the infix notation:
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\usepackage{fp}
-\htablecalc{$x$}{0.5,1,2.5,10}
- {$2x^2-\frac{1}{2}$}{2*x*x-0.5}
+cos(x)*(1-cos(x))
\end{lstlisting}
\end{minipage}
-\smallskip
-\makeatletter
-\def\tc@evalexpr{%
- \expandafter\FPeval\expandafter
- \tc@currentresult\expandafter{\tc@currentresult}%
- \FPclip\tc@currentresult\tc@currentresult
-}
-\makeatother
-\htablecalc{$x$}{0.5,1,2.5,10}
- {$2x^2-\frac{1}{2}$}{2*x*x-0.5}
\end{center}
+Obviously, $\cos x$ is unnecessarily computed twice which slows down the compilation.\smallskip
-An issue remains: as \verb|fp| does not understand the opposite "${}-{}$" sign before numbers, and a value like "\verb|-3|" would have provoked an error! To circumvent this, the RPN can be used, but \verbinline|\tc@evalexpr| must be modified to tell it that the computation has to be done using the RPN (this is why \verb|\FPupn| is used). Also, \verbinline|\printvalue| must be modified to make it compute with \verb|\FPupn| the values also written in RPN (\verb|3 neg| in the list of values instead of \verb|-3|):\par\nobreak
+With the postfix notation, it is computed once:
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\usepackage{fp}
-\makeatletter
-\def\tc@evalexpr{%
- \expandafter\FPupn\expandafter
- \tc@currentresult\expandafter{\tc@currentresult}%
- \FPclip\tc@currentresult\tc@currentresult
-}
-\makeatother
-\def\printvalue#1{%
- \FPupn\tempval{#1}%
- \FPclip\tempval\tempval
- \numprint\tempval
-}
-\htablecalc{$x$}{3 neg,0.5,1,2.5,10}
- {$2x^2-\frac{1}{2}$}{x x mul 2 mul 0.5 sub}
+x cos copy 1 swap sub mul
\end{lstlisting}
\end{minipage}
-\makeatletter
-\def\tc@evalexpr{%
- \expandafter\FPupn\expandafter
- \tc@currentresult\expandafter{\tc@currentresult}%
- \FPclip\tc@currentresult\tc@currentresult
-}
-\makeatother
-\def\printvalue#1{%
- \FPupn\tempval{#1}%
- \FPclip\tempval\tempval
- \numprint\tempval
-}
-\htablecalc{$x$}{3 neg,0.5,1,2.5,10}
- {$2x^2-\frac{1}{2}$}{x x mul 2 mul 0.5 sub}
\end{center}
-\bigskip\bigskip
+\bigskip
\begin{center}
$\star$\par
$\star$\quad$\star$
diff --git a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.pdf b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.pdf
index 7f0dad6d9b4..6130101a0fe 100644
--- a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.pdf
+++ b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.tex b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.tex
index e0f695812db..738e11c4039 100644
--- a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.tex
+++ b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_fr.tex
@@ -18,7 +18,7 @@
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
-\usepackage[a4paper,dvips,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,bookmarks=false,pdfauthor={Christian TELLECHEA},pdftitle={tabularcalc},pdfsubject={package pour construction d'un tableau de valeurs},pdfkeywords={tabularcalc},pdfcreator={LaTeX}]{hyperref}
+\usepackage[a4paper,dvips,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,bookmarks=false,pdfauthor={Christian TELLECHEA},pdftitle={tabularcalc},pdfsubject={extension pour construction d'un tableau de valeurs},pdfkeywords={tabularcalc},pdfcreator={LaTeX}]{hyperref}
\usepackage[a4paper,dvips,margin=2.75cm]{geometry}
\usepackage[autolanguage]{numprint}
\usepackage{colortbl}
@@ -26,9 +26,8 @@
\usepackage{lmodern}
\usepackage{xspace}
\usepackage{listings}
-\usepackage{fp}
-\usepackage{pgfmath}
\usepackage{tabularcalc}
+\usepackage[bottom]{footmisc}
\usepackage[frenchb]{babel}
\makeatletter
\definecolor{tc@bckgcolor}{rgb}{1,1,0.875}
@@ -38,9 +37,8 @@
\definecolor{tc@comments}{rgb}{0.5,0.5,0.5}
\lstset{%
language=[AlLaTeX]TeX,%
- morekeywords={numexpr},%
float=hbp,%
- basicstyle=\small\ttfamily,%
+ basicstyle=\footnotesize\ttfamily,%
identifierstyle=\color{tc@arguments},%
keywordstyle=\color{tc@keywordslatex},%
commentstyle=\itshape\color{tc@comments},%
@@ -65,22 +63,22 @@
morekeywords={% les macros et commandes de tabularcalc
tccol,tclin,%
htablecalc,vtablecalc,%
- noshowmark,startline,resetcellcode,edefcellcode,defcellcode,%
- sethrule,resethrule,setcoltype,resetcoltype,%
- printvalue,printresult,numberletter,listsep,%
- tc@evalexpr,tc@currentresult},%
+ tcnoshowmark,tcatbeginrow,tcresetcellcode,edefcellcode,defcellcode,%
+ tcsethrule,tcresethrule,tcsetcoltype,tcresetcoltype,%
+ tcprintvalue,tcprintresult,tclistsep,%
+ tcprintroundresult,tcprintroundvalue,tcwritetofile},%
keywordstyle=\color{tc@keywordstc},%
classoffset=0}
\makeatother
\newcommand\guill[1]{\og{}#1\fg{}}
\newcommand\argu[1]{$\langle$\textit{#1}$\rangle$}
-\newcommand\ARGU[1]{\texttt{\color{black}\{}\argu{#1}\texttt{\color{black}\}}}
-\newcommand\arguC[1]{\texttt{\color{black}[}\argu{#1}\texttt{\color{black}]}}
+\newcommand\ARGU[1]{\texttt{\{}\argu{#1}\texttt{\}}}
+\newcommand\arguC[1]{\texttt{[}\argu{#1}\texttt{]}}
\newcommand\tbcalc{\textsf{tabularcalc}\xspace}
\newcommand\verbinline{\lstinline[breaklines=false,basicstyle=\normalsize\ttfamily]}
-\newcommand\mywidth{0.75\linewidth}
+\newcommand\mywidth{0.85\linewidth}
\begin{document}
\setlength{\parindent}{0pt}
@@ -106,13 +104,14 @@
\begin{minipage}{0.85\linewidth}
\noindent
\hfill\textbf{\textit{Résumé}}\hfill{}\medskip\par
- Étant donné une liste de nombres et une ou plusieurs formules à une variable, cette extention, à l'aide d'une syntaxe simple, construit un tableau de valeurs, c'est-à-dire un tableau dont la première ligne contient les nombres les autres lignes les résultats pris par la (ou les) formules pour chacun des nombres de la liste :
+ Étant donné une liste de nombres et une ou plusieurs formules à une variable, cette extension, à l'aide d'une syntaxe simple, construit un tableau de valeurs, c'est-à-dire un tableau dont la première ligne contient les nombres les autres lignes les résultats pris par la (ou les) formules pour chacun des nombres de la liste :
\begin{center}
- \sethrule{\hline}{\hline\hline}{\hline}
- \def\printvalue#1{\IfInteger{#1}{\nprounddigits{0}}{}\numprint{#1}}
- \def\printresult#1#2{\IfInteger{#1}{\nprounddigits{0}}{}\numprint{#1}}
- \setcoltype{|c|}{>{\centering\arraybackslash}m{1.25cm}|}
- \htablecalc[3]{$x$}{-4,-2,0,2.25,7}{$f(x)=2x-3$}{2*x-3}{$x^2$}{x*x}{$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ \tcsethrule{\hline}{\hline\hline}{\hline}
+ \tcsetcoltype{|c|}{>{\centering\arraybackslash}m{1.5cm}|}
+ \htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
Le tableau peut être construit horizontalement ou verticalement, et il est entièrement personnalisable, autant du point de vue des filets, que de la hauteur des lignes ou que des types de colonnes. De plus, le contenu de n'importe quelle cellule du tableau peut être masqué.\smallskip
@@ -124,33 +123,87 @@
\tableofcontents
-\section{Présentation}
-Ce package \tbcalc nécessite \LaTeX, et charge les packages \href{http://www.ctan.org/tex-archive/graphics/pgf/base/latex/pgf/math/}{\texttt{\textbf{pgfmath}}}, \href{http://www.ctan.org/tex-archive/macros/latex/contrib/xstring/}{\texttt{\textbf{xstring}}} et \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} si ce n'a pas été le cas. Il permet de construire facilement des tableaux de résultats en évaluant des formules dont la variable prend une liste donnée de valeurs. Les tableaux sont affichés avec l'environement standard \verb|tabular|\footnote{Pour l'instant, l'environement \texttt{tabular} est codé en dur dans le package. Rien n'empêchera par la suite de laisser le choix de l'environnement à l'utilisateur \texttt{tabularx}, \texttt{tabulary}, \texttt{supertabular}, etc.}. L'affichage des résultats se fait sous forme décimale.
+\bigskip
+J'adresse mes remerciements à Derek~\textsc{O'Connor} pour l'intérêt qu'il a porté à cette extension et pour les tests qu'il a effecté sur les versions beta que je lui ai envoyées. Ses suggestions ---~pertinentes~--- de nouvelles fonctionnalités m'ont été précieuses. Sans ses conseils, \tbcalc ne serait pas ce qu'il est.\medskip
-Le package est appelé avec la traditionnelle instruction \verbinline|\usepackage{tabularcalc}|\smallskip
+Merci également à Le \textsc{Huu Dien Khue} qui m'a gentiment proposé de traduire ce manuel en viet-namien.
-Ce package n'est pas du tout destiné à entrer en concurrence avec \href{http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/}{\texttt{\textbf{pgfplotstable}}}, l'excellent package de Christian~\textsc{Feuers\"anger}. Ce dernier est en effet bien plus personnalisable que \tbcalc et ses possibilités sont largement plus étendues, au prix cependant d'une syntaxe et d'une difficulté d'utilisation plus grande. \tbcalc se veut plus modeste et privilégie la facilité d'utilisation combinée à des possibilités de personnalisation aisément accessibles (du moins pour les personnalisations cosmétiques).\medskip
+\section{Introduction}
+\subsection{Présentation}
+Cette extension permet de construire facilement des tableaux de résultats en évaluant des formules dont la variable prend des valeurs données dans une liste. Les tableaux sont affichés avec l'environnement standard \verb|tabular|. L'affichage des nombres se fait sous forme décimale.
-Du côté des calculs, l'évaluation d'une expression numérique comme \verb|2*x*x-5*x+7| lorsque \hbox{\verb|x = 2.7|} est, avec \TeX{}, une chose complexe que le package \tbcalc ne réalise pas. Pour cette tâche, il fait appel à un moteur de calcul qui est \og pgfmath\fg par défaut. C'est pourquoi \href{http://www.ctan.org/tex-archive/graphics/pgf/base/latex/pgf/math/}{\texttt{\textbf{pgfmath}}} est chargé s'il ne l'a pas été auparavant. On peut cependant changer de moteur de calcul, voir page~\pageref{changemoteurcalcul}.\smallskip
+\tbcalc fonctionne sous \LaTeX{} et charge les extensions \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\texttt{\textbf{fp}}}, \href{http://www.ctan.org/tex-archive/macros/latex/contrib/xstring/}{\texttt{\textbf{xstring}}} et \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} si ce n'a pas été le cas.
-En ce qui concerne l'affichage des nombres décimaux dans le tableau, de l'avis de l'auteur, rien ne le fait mieux que le package \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}}, ce package est donc également requis. On peut changer le moteur d'affichage des nombres décimaux et/ou entièrement personnaliser l'affichage des nombres (voir page~\pageref{persoaffichage}).\medskip
+Cette extension n'est pas du tout destinée à entrer en concurrence avec \href{http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/}{\texttt{\textbf{pgfplotstable}}}, l'excellente extension de Christian~\textsc{Feuers\"anger}. Cette dernière est en effet bien plus personnalisable que \tbcalc au prix cependant d'une syntaxe et d'une difficulté d'utilisation plus grande. \tbcalc se veut plus modeste et privilégie la facilité d'utilisation combinée à des possibilités de personnalisation aisément accessibles.\medskip
+En ce qui concerne l'affichage des nombres décimaux dans le tableau, de l'avis de l'auteur, rien ne le fait mieux que l'extension \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} qui est donc également requise. On peut changer le moteur d'affichage des nombres décimaux et/ou entièrement personnaliser l'affichage des nombres (voir page~\pageref{persoaffichage}).
+
+\subsection{L'extension \ttfamily fp}
+Du côté des calculs, l'évaluation d'une expression numérique comme \verb|2*x*x-5*x+7| lorsque \hbox{\verb|x = 2.7|} est, avec \TeX{}, une chose complexe que \tbcalc ne réalise pas. Pour cette tâche, il fait appel à un moteur de calcul fourni par l'extension \og\verb=fp=\fg qui offre toutes les fonctions arithmétiques, scientifiques et trigonométriques habituelles.\medskip
+
+On peut utiliser indifféremment la syntaxe infixée ou postfixée. Consulter le fichier \href{http://www.ctan.org/get/macros/latex/contrib/fp/README}{\texttt{\textbf{README}}} de l'extension \verb=fp= pour la liste exhaustive des fonctions disponibles selon la notation employée.\medskip
+
+Sans demander l'autorisation de l'auteur ni même l'en informer\footnote{Je crois que l'auteur a depuis longtemps délaissé le monde de \LaTeX{}.}, je me suis permis de corriger 2 problèmes de l'extension \verb=fp=, tous deux dans la macro \verb=\FPpow=, s'occupant du calcul des puissances :
+\parindent2em
+\begin{itemize}
+ \item tout d'abord, un espace indésirable était ajouté lors du calcul d'une puissance par \verb=fp=;
+ \item il y a plus gênant puisque pour calculer $a^b$, \verb=fp= utilise la formule $\mathrm{e}^{b\ln a}$. Il y a un petit problème lorsque $b$ est entier et $a$ est négatif puisqu'alors : $(-3)^2=\mathrm{e}^{2\ln(-3)}$ et le logarithme d'un nombre négatif est indéfini.
+\end{itemize}\smallskip
+
+\parindent0pt
+Pour laisser \tbcalc corriger ces 2 problèmes, on peut passer l'option \og\verb=fixFPpow=\fg{} au package :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\usepackage[fixFPpow]{tabularcalc}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+
+\subsection{Ce qui est nouveau}
+Hélas, on m'a fait part d'incompatibilité avec d'autres packages car le nom de certaines macros de \tbcalc était déjà utilisé. J'ai donc décidé ---~la mort dans l'âme~--- de renommer les macros publiques, au risque certain de créer une incompatibilite avec la version 0.1; que les utilisateurs m'excusent pour ce désagrément !
+
+Pour éviter tout nouveau risque, je mets donc \og\verb-tc-\fg{} (comme \tbcalc\footnote{Je préfère préciser qu'il s'agit d'un racourci pour \tbcalc et non de mes initiales : je ne suis pas narcissique à ce point !}) devant le nom de presque toutes les macros publiques. Pour ceux qui utilisent déjà \tbcalc, voici tous les changements de nom :
+\begin{center}
+ \begin{tabular}{rl}
+ Ancien nom&Nouveau nom \\\hline
+ \verb=\noshowmark=&\verb=\tcnoshowmark=\\
+ \verb=\startline=&\verb=\tcatbeginrow=\\
+ \verb=\resetcellcode=&\verb=\tcresetcellcode=\\
+ \verb=\listsep=&\verb=\tclistsep=\\
+ \verb=\printvalue=&\verb=\tcprintvalue=\\
+ \verb=\printresult=&\verb=\tcprintresult=\\
+ \verb=\sethrule=&\verb=\tcsethrule=\\
+ \verb=\resethrule=&\verb=\tcresethrule=\\
+ \verb=\setcoltype=&\verb=\tcsetcoltype=\\
+ \verb=\resetcoltype=&\verb=\tcresetcoltype=
+ \end{tabular}
+\end{center}
+
+Autres nouveautés pour ceux qui sont familiers avec cette extension :\parindent2em
+\begin{itemize}
+ \item les calculs effectués par \verb=pgfmath= étant beaucoup trop imprécis, cette extension est abandonnée au profit de \verb=fp= qui offre une précision bien plus grande;
+ \item les valeurs peuvent maintenant être calculées;
+ \item on peut désormais écrire le code correspondant à un tableau dans un fichier pour le modifier à la main.
+\end{itemize}\parindent0pt
+
+\subsection{Vocabulaire}
Pour que des points de vocabulaire soient clairs par la suite, dans les tableaux triviaux ci-dessous, les nombres en rouge sont les \og{\color{red}valeurs}\fg{}, les nombres en bleu sont les \og{\color{blue}résultats}\fg{}, et les textes en brun sont les \og{\color{brown}labels}\fg{}. La cellule en haut à gauche est la \guill{cellule (0,0)}. Ce vocabulaire sera employé ensuite.
\begin{minipage}{0.5\linewidth}
\begin{center}
{\scriptsize Tableau horizontal}\par\nobreak\smallskip
-\def\printvalue#1{\color{red}$#1$}
-\def\printresult#1#2{\color{blue}\IfInteger{#1}{$\number\integerpart$}{$#1$}}
-\htablecalc[3]{cellule (0,0)}{-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
+\def\tcprintvalue#1{\color{red}$#1$}
+\def\tcprintresult#1#2{\color{blue}$#1$}
+\htablecalc[3]{cellule (0,0)}{x=-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
\end{center}
\end{minipage}%
\begin{minipage}{0.5\linewidth}
\begin{center}
{\scriptsize Tableau vertical}\par\nobreak\smallskip
-\def\printvalue#1{\color{red}$#1$}
-\def\printresult#1#2{\color{blue}\IfInteger{#1}{$\number\integerpart$}{$#1$}}
-\vtablecalc[3]{cellule (0,0)}{-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
+\def\tcprintvalue#1{\color{red}$#1$}
+\def\tcprintresult#1#2{\color{blue}$#1$}
+\vtablecalc[3]{cellule (0,0)}{x=-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
\end{center}
\end{minipage}
@@ -158,109 +211,109 @@ Pour que des points de vocabulaire soient clairs par la suite, dans les tableaux
\subsection{Tableaux horizontaux}
La commande \verbinline|\htablecalc| permet de construire un tableau de valeur horizontal, dont la 1\iere{} ligne contiendra les valeurs, et les lignes suivantes les résultats. La syntaxe est :\smallskip
-\setbox0=\hbox{\verbinline|\htablecalc|\arguC{nombre}}
-\verbinline|\htablecalc|\arguC{nombre}\ARGU{cellule (0,0)}\ARGU{liste val}\par
+\setbox0=\hbox{\verbinline|\htablecalc|\arguC{n}}
+\verbinline|\htablecalc|\arguC{n}\ARGU{cellule (0,0)}\ARGU{variable=liste val}\par
\hskip\wd0\ARGU{label 1}\ARGU{formule 1}\par
\hskip\wd0\ARGU{label 2}\ARGU{formule 2}\par
\hskip\wd0\ldots\par
\hskip\wd0\ARGU{label n}\ARGU{formule n}\medskip
-où :\parindent1.5em
+où :\parindent2em
\begin{itemize}
- \item \argu{nombre} est le nombre de formules à évaluer. Ce nombre vaut 1 par défaut;
- \item \argu{cell(0,0)} est le contenu de la cellule (0,0);
- \item \argu{liste val} est la liste des valeurs, séparées par une virgule. Noter que les valeurs décimales doivent avoir le point comme séparateur décimal. Si deux virgules se suivent, une colonne vide est affiché;
+ \item \argu{n} est le nombre de formules à évaluer. Ce nombre vaut 1 par défaut;
+ \item \argu{cellule(0,0)} est le contenu de la cellule (0,0);
+ \item \argu{variable} est la variable qui interviendra dans les \argu{formules i} servant à calculer les résultats.
+ \item \argu{liste val} est la liste des valeurs, séparées par une virgule. Noter que les valeurs décimales doivent avoir le point comme séparateur décimal;
\item \argu{label i} est le i\ieme{} label;
- \item \argu{formule i} est la i\ieme{} formule qui servira à évaluer les résultats de la i\ieme{} ligne. Dans les formules, \verb|x| est la variable.
+ \item \argu{formule i} est la i\ieme{} formule qui servira à évaluer les résultats de la i\ieme{} ligne.
\end{itemize}\parindent0em
\medskip
-La lettre \verb|x| qui représente la variable dans les formules est le développement de \verbinline|\numberletter| et pour changer la variable dans les formules en \verb|y|, il suffit d'écrire : \verbinline|\def\numberletter{y}|.\smallskip
-
-Dans la liste de valeurs, le séparateur par défaut est la virgule qui est le développement de \verbinline|\listsep|, et pour changer ce séparateur en \guill{|} par exemple, il faut écrire : \verbinline=\def\listsep{|}=\medskip
+Dans la liste de valeurs, le séparateur par défaut est la virgule qui est le développement de \verbinline|\tclistsep|, et pour changer ce séparateur en \guill{|} par exemple, il faut écrire : \verbinline=\def\tclistsep{|}=\medskip
À titre d'exemple, voici un premier essai pour obtenir le tableau de la première page :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
-\smallskip
\end{minipage}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
-On peut observer que le tableau n'est pas strictement identique à celui de la permière page : les résultats entiers comportent une décimale nulle, les colonnes contenant les résultats ne sont pas toutes de la même largeur et le filet sous la 1\iere{} ligne est différent. Nous verrons comment personnaliser tout cela plus loin.
+On peut observer que le tableau n'est pas strictement identique à celui de la première page : les colonnes contenant les résultats ne sont pas toutes de la même largeur et le filet sous la 1\iere{} ligne est différent. Nous verrons comment personnaliser tout cela plus loin.
\subsection{Tableaux verticaux}
La commande \verbinline|\vtablecalc| permet de construire un tableau de valeur vertical, dont la 1\iere{} colonne contiendra les valeurs, et les colonnes suivantes les résultats. La syntaxe est :\smallskip
-\setbox0=\hbox{\verbinline|\vtablecalc|\arguC{nombre}}
-\verbinline|\vtablecalc|\arguC{nombre}\ARGU{cellule (0,0)}\ARGU{liste val}\par
+\setbox0=\hbox{\verbinline|\vtablecalc|\arguC{n}}
+\verbinline|\vtablecalc|\arguC{n}\ARGU{cellule (0,0)}\ARGU{variable=liste val}\par
\hskip\wd0\ARGU{label 1}\ARGU{formule 1}\par
\hskip\wd0\ARGU{label 2}\ARGU{formule 2}\par
\hskip\wd0\ldots\par
\hskip\wd0\ARGU{label n}\ARGU{formule n}\medskip
-où :\parindent1.5em
+où :\parindent2em
\begin{itemize}
- \item \argu{nombre} est le nombre de formules à évaluer. Ce nombre vaut 1 par défaut;
+ \item \argu{n} est le nombre de formules à évaluer. Ce nombre vaut 1 par défaut;
+ \item \argu{cellule(0,0)} est le contenu de la cellule (0,0);
+ \item \argu{variable} est la variable qui interviendra dans les \argu{formules i} servant à calculer les résultats;
\item \argu{liste val} est la liste des valeurs, séparées par une virgule. Noter que les valeurs décimales doivent avoir le point comme séparateur décimal;
\item \argu{label i} est le i\ieme{} label;
- \item \argu{formule i} est la i\ieme{} formule qui servira à évaluer les résultats de la i\ieme{} colonne. Dans les formules, \verb|x| est la variable.
+ \item \argu{formule i} est la i\ieme{} formule qui servira à évaluer les résultats de la i\ieme{} ligne.
\end{itemize}\parindent0em
\medskip
-À titre d'exemple, voici le tableau précédent présenté verticalement :\par\nobreak
+À titre d'exemple, voici le tableau précédent présenté verticalement, mais où l'on prend la variable des formules comme étant \verb=y= :\par\nobreak
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\vtablecalc[3]{$x$}{-4,-2,0,2.25,7}
- {$f(x)=2x-3$}{2*x-3}
- {$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+\vtablecalc[3]{$x$}{y=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*y-3}
+ {$x^2$}{y*y}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,y*y+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\vtablecalc[3]{$x$}{-4,-2,0,2.25,7}
- {$f(x)=2x-3$}{2*x-3}
- {$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+
+\vtablecalc[3]{$x$}{y=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*y-3}
+ {$x^2$}{y*y}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,y*y+1),6)}
\end{center}
-\subsection{Masquer des cellules}
-On peut masquer le contenu de n'importe quelle celule, aussi bien dans un tableau horizontal que vertical.
+\subsection{Masquer des cellules}\label{masquercellules}
+On peut masquer le contenu de n'importe quelle cellule, aussi bien dans un tableau horizontal que vertical.
\subsubsection{Masquer une valeur}
Si on veut masquer une valeur, il suffit de la faire précéder d'un \og\verb|@|\fg dans la liste. Dans l'exemple suivant, on masque la 2\ieme{} et la 5\ieme{} valeur :\smallskip
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\htablecalc[3]{$x$}{-4,@-2,0,2.25,@7}
+\htablecalc[3]{$x$}{x=-4,@-2,0,2.25,@7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\htablecalc[3]{$x$}{-4,@-2,0,2.25,@7}
+
+\htablecalc[3]{$x$}{x=-4,@-2,0,2.25,@7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
\medskip
-Le token \og\verb|@|\fg est en réalité le développement de la commande \verbinline|\noshowmark|. Pour changer le token qui masque une valeur, il suffit de redéfinir cette macro. Par exemple, pour faire tenir ce rôle au signe \og=\fg : \verbinline|\def\noshowmark{=}|
+Le token \og\verb|@|\fg est en réalité le développement de la commande \verbinline|\tcnoshowmark|. Pour changer le token qui masque une valeur, il suffit de redéfinir cette macro. Par exemple, pour faire tenir ce rôle au signe \og=\fg, on écrirait \verbinline|\def\tcnoshowmark{=}|
\subsubsection{Masquer un résultat}
Pour une valeur donnée, si on veut masquer les résultats numéro $a_1,a_2,\ldots,a_n$, il suffit de faire suivre cette valeur par $[a_1][a_2]\ldots[a_n]$ où les nombres $a_i$ sont dans l'ordre croissant. Si un des nombres $a_j$ vaut 0, tous les autres $a_k$ où $k>j$ sont ignorés et tous les résultats qui suivront le précédent résultat masqué seront masqués.\medskip
-Dans l'exemple qui suit, on va :\parindent1.5em
+Dans l'exemple qui suit, on va :\parindent2em
\begin{itemize}
\item masquer le 2\ieme{} résultat de la première valeur avec \og\verb|-4[2]|\fg
\item laisser tous les résultats de la 2\ieme{} valeur avec \og\verb|-2|\fg
@@ -272,53 +325,53 @@ Dans l'exemple qui suit, on va :\parindent1.5em
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\htablecalc[3]{$x$}{-4[2],-2,0[1][3],2.25[0],7[2][0]}
+\htablecalc[3]{$x$}{x=-4[2],-2,0[1][3],2.25[0],7[2][0]}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\htablecalc[3]{$x$}{-4[2],-2,0[1][3],2.25[0],7[2][0]}
+
+\htablecalc[3]{$x$}{x=-4[2],-2,0[1][3],2.25[0],7[2][0]}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
On peut combiner cette syntaxe avec \verb|@| pour masquer à la fois la valeur et certains résultats.
\subsection{Hauteur des lignes}
-Au début de chaque ligne, lors de son affichage, la commande \verbinline|\startline| est exécutée.
+Au début de chaque ligne, lors de son affichage, la commande \verbinline|\tcatbeginrow| est exécutée.
-Par défaut, cette commande est définie par : \verbinline|\def\startline{\rule[-1.2ex]{0pt}{4ex}}|. Cette commande se développe donc par défaut en un \guill{strut} qui fixe la hauteur de la ligne. Voici ce strut, rendu visible devant la lettre a : \rule[-1.2ex]{2pt}{4ex}a\medskip
+Par défaut, cette commande est définie par : \verbinline|\def\tcatbeginrow{\rule[-1.2ex]{0pt}{4ex}}|. Cette commande se développe donc par défaut en un \guill{strut} qui fixe la hauteur de la ligne. Voici ce strut, rendu visible devant la lettre a : \rule[-1.2ex]{2pt}{4ex}a\medskip
On peut donc faire exécuter un autre strut ou tout autre action au début d'une ligne :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\def\startline{%
+\def\tcatbeginrow{%
{\bfseries\number\tclin)\ }%
}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\def\startline{%
+
+\def\tcatbeginrow{%
{\bfseries\number\tclin)\ }%
}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{center}
-Ici, on supprime le strut (on donne aux lignes leur hauteur naturelles) et on affiche en gras le numéro de la ligne en cours (qui est contenue dans le compteur \verbinline|\tclin|) à la ligne 2 du code.
+Ici, on ne définit aucun strut (on redonne donc aux lignes leur hauteur naturelles) et on affiche en gras le numéro de la ligne en cours (qui est contenue dans le compteur \verbinline|\tclin|) à la ligne 2 du code.
\subsection{Filets horizontaux}
-\tbcalc permet de définir 3 types de filets horizontaux. Pour cela, la commande \verbinline|\sethrule| admet 3 arguments :
+\tbcalc permet de définir 3 types de filets horizontaux. Pour cela, la commande \verbinline|\tcsethrule| admet 3 arguments :
-\parindent1.5em
+\parindent2em
\begin{itemize}
\item le \guill{filet 0} affiché en haut et en bas du tableau;
\item le \guill{filet 1} affiché sous la première ligne;
@@ -326,31 +379,31 @@ Ici, on supprime le strut (on donne aux lignes leur hauteur naturelles) et on af
\end{itemize}\parindent0em
Voici la syntaxe :
-\verbinline|\sethrule|\ARGU{filet 1}\ARGU{filet 2}\ARGU{autres filets}
+\verbinline|\tcsethrule|\ARGU{filet 0}\ARGU{filet 1}\ARGU{autres filets}
\medskip
Par défaut, les 3 arguments valent \verbinline|\hline|.\medskip
-Voici un exemple où le filet sous la premiere ligne est double et les autres filets sont supprimés :
+Voici un exemple où le filet sous la première ligne est double et les autres filets sont supprimés :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\sethrule{\hline}{\hline\hline}{}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\tcsethrule{\hline}{\hline\hline}{}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{lstlisting}
\end{minipage}
-\smallskip
-\sethrule{\hline}{\hline\hline}{}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+
+\tcsethrule{\hline}{\hline\hline}{}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{center}
-La commande \verbinline|\resethrule| permet de revenir aux filets horizontaux définis par défaut.
+La commande \verbinline|\tcresethrule| permet de revenir aux filets horizontaux définis par défaut.
\subsection{Personnalisation des colonnes}
\subsubsection{Filets verticaux}
@@ -362,50 +415,144 @@ La commande \verbinline|\resethrule| permet de revenir aux filets horizontaux d
\end{itemize}\medskip
La syntaxe est :\par\nobreak
-\verbinline|\setcoltype|\arguC{filets de droite}\ARGU{type 1}\ARGU{type 2}\medskip
+\verbinline|\tcsetcoltype|\arguC{filets de droite}\ARGU{type 1}\ARGU{type 2}\medskip
Voici un exemple :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\setcoltype[||]{||c||}{c}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\tcsetcoltype[||]{||c||}{c}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{lstlisting}
\end{minipage}
-\smallskip
-\setcoltype[||]{||c||}{c}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+
+\tcsetcoltype[||]{||c||}{c}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{center}
-La commande \verbinline|\resetcoltype| permet de revenir aux types de colonne définis par défaut.
+La commande \verbinline|\tcresetcoltype| permet de revenir aux types de colonne définis par défaut.
\subsubsection{Largeur des colonnes}
-Au lieu de l'habituel spécificateur de colonne \guill{c} que nous avons utilisé jusqu'à présent, on peut spécifier la largeur des colonnes avec le spécificateur \guill{m} du package \href{http://www.ctan.org/tex-archive/graphics/pgf/base/latex/pgf/basiclayer/}{\texttt{\textbf{array}}} de cette façon : \og\verb|m{1.5cm}|\fg{}.\medskip
+Au lieu de l'habituel spécificateur de colonne \guill{c} que nous avons utilisé jusqu'à présent, on peut spécifier la largeur des colonnes avec le spécificateur \guill{m} de l'extension \href{http://www.ctan.org/tex-archive/graphics/pgf/base/latex/pgf/basiclayer/}{\texttt{\textbf{array}}} de cette façon : \og\verb|m{1.5cm}|\fg{}.\medskip
Voici un exemple où la 1\iere{} colonne est centrée à droite, les colonnes de résultats sont centrées et mesurent \numprint[cm]{1.5} de large :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
\usepackage{array}
-\setcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+\tcsetcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
\end{lstlisting}
\end{minipage}
-\smallskip
-\setcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
-\htablecalc[3]{$x$}{-4,-2,0,2.25,7}
+
+\tcsetcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
{$f(x)=2x-3$}{2*x-3}
{$x^2$}{x*x}
- {$h(x)=\sqrt{x^2+1}$}{sqrt(x*x+1)}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{center}
+
+\section{Calculer les valeurs}
+Lorsque les valeurs sont assez nombreuses et suivent une règle mathématique, il peut être plus simple de saisir la formule que toutes les valeurs. Ainsi la syntaxe :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[2]{$x$}{x=-3,-1,1,3,5,7,9,11,13}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+peut être saisie ainsi :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[2]{$x$}{x=a;a=-3:13[2]}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+La présence du \og\verb=;=\fg{} change la façon d'analyser l'argument contenant les valeurs : on exprime à droite du signe \og\verb=;=\fg{} que la variable muette \og\verb=a=\fg{} va parcourir l'intervalle $-3\ldots13$ avec un incrément de 2. Les valeurs seront donc des entiers \emph{impair}. À gauche de \og\verb=;=\fg{}, on exprime que la variable intervenant dans les formules ---~ ici \verb=x=~--- va être égale à \verb=a= donc prendra elle aussi les valeurs impaires de $-3$ à 13.
+
+On aurait pu aussi générer l'argument \verb|{x=-3,-1,1,3,5,7,9,11,13}| avec \verb|{x=2*a+1:a=-2:6}|. Cette fois-ci l'incrément vaut 1 par défaut. Il y plusieurs façons de parvenir à ces mêmes valeurs, celle-ci par exemple : \verb|{x=2*a-3;a=0:8}|\bigskip
+
+Lorsqu'on utilise un argument avec \og\verb=;=\fg{}, on perd la possibilité de masquer des cellules comme vu à la page~\pageref{masquercellules}. Il faut aussi prendre garde au nombres de valeurs générées afin que le tableau ne devienne pas gigantesque.\medskip
+
+Avec cette syntaxe, l'argument contenant les valeurs se présente sous cette forme :\par\smallskip\nobreak
+\hfill\argu{variable 1}\verb|=|\argu{formule}\verb|;|\argu{variable 2}\verb|=|\argu{min}\verb|:|\argu{max}\arguC{incrément}\hfill{}\smallskip
+
+où :
+\parindent2em
+\begin{itemize}
+ \item \argu{variable 1} est la variable intervenant dans les formules servant à évaluer les résultats;
+ \item \argu{variable 2} est la variable intervenant dans les formules servant à évaluer les valeurs. Elle doit être différente de \argu{variable 1}.
+ \item \argu{formule} est la formule qui va évaluer les différentes valeurs. La variable intervenant dans cette formule est \argu{variable 2};
+ \item \argu{min}\verb|:|\argu{max} représentent l'intervalle dans lequel doit varier la \argu{variable 2};
+ \item \argu{incrément} est le pas d'incrémentation, il est facultatif et vaut \verb=1= par défaut. Il ne doit pas être nul.
+\end{itemize}\parindent0em
+\medskip
+
+Comme on l'a vu, il y a de plusieurs façons différentes de générer les mêmes valeurs. Ainsi, les valeurs \texttt{\{0,1,2,3,4,5,6,7,8,9,10\}} sont générées par :
+
+\parindent2em
+\begin{itemize}
+ \item \verb|{z=x;x=0:10}| et \og\verb=z=\fg{} sera la variable des formules;
+ \item \verb|{n=2*a;a=0:5[0.5]}| et \og\verb=n=\fg{} sera la variable des formules;
+ \item \verb|{x=y/10;y=0:100[10]}| et \og\verb=x=\fg{} sera la variable des formules;
+\end{itemize}
+\parindent0pt\medskip
+
+Il va sans dire que l'intervalle et l'incrément doivent être cohérents entre-eux. Un argument \verb|0:10[-1]| va provoquer message d'erreur de \tbcalc !\medskip
+
+À titre d'exemple, voici un tableau utilisant les fonctions trigonométriques de \verb|fp|:
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[6]{$x$\ [deg]}{x=a;a=15:75[15]}
+ {$\sin x$}{round(sin(x*pi/180),6)}
+ {$\cos x$}{round(cos(x*pi/180),6)}
+ {$\tan x$}{round(tan(x*pi/180),6)}
+ {$\sin^2x$}{round(sin(x*pi/180)^2,6)}
+ {$\cos^2x$}{round(cos(x*pi/180)^2,6)}
+ {$\tan^2x$}{round(tan(x*pi/180)^2,6)}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc[6]{$x$\ [deg]}{x=a;a=15:75[15]}
+ {$\sin x$}{round(sin(x*pi/180),6)}
+ {$\cos x$}{round(cos(x*pi/180),6)}
+ {$\tan x$}{round(tan(x*pi/180),6)}
+ {$\sin^2x$}{round(sin(x*pi/180)^2,6)}
+ {$\cos^2x$}{round(cos(x*pi/180)^2,6)}
+ {$\tan^2x$}{round(tan(x*pi/180)^2,6)}
+\end{center}
+\medskip
+
+Et un autre tableau qui affiche des puissances de 10, leur logarithme décimal, leur racine carrée et leur inverse :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[3]{Puissances de 10}{x=round(10^n,4);n=-3:3}
+ {Logarithme d\'ecimal}{ln(x)/ln(10)}
+ {Racine carr\'ee}{round(root(2,x),3)}
+ {Inverse}{1/x}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc[3]{Puissances de 10}{x=round(10^n,4);n=-3:3}
+ {Logarithme d\'ecimal}{ln(x)/ln(10)}
+ {Racine carr\'ee}{round(root(2,x),3)}
+ {Inverse}{1/x}
\end{center}
\section{Personnalisation avancée}
@@ -413,20 +560,20 @@ Voici un exemple où la 1\iere{} colonne est centrée à droite, les colonnes de
La macro \verbinline|\defcellcode| permet d'exécuter un code donné dans une cellule, une colonne entière ou une ligne entière de son choix. Pour cela, les cellules du tableau sont repérées avec des coordonnées que voici :\smallskip
\begin{center}
- \def\printvalue#1{}\def\printresult#1#2{}
+ \def\tcprintvalue#1{}\def\tcprintresult#1#2{}
\edefcellcode{}{}{(\number\tclin,\number\tccol)}
- \htablecalc[3]{}{1,2,3,4,5}{}{}{}{}{}{}
+ \htablecalc[3]{}{x=1,2,3,4,5}{}{x}{}{x}{}{x}
\end{center}
\medskip
-En interne, la 1\iere{} coordonnée ---~le numéro de la ligne~--- est contenu dans le compteur \verbinline{\tclin}, tandisque le numéro de la colonne est contenu dans le compteur \verbinline{\tccol}.\smallskip
+En interne, la 1\iere{} coordonnée ---~le numéro de la ligne~--- est contenu dans le compteur \verbinline{\tclin}, tandis que le numéro de la colonne est contenu dans le compteur \verbinline{\tccol}.\smallskip
Voici la syntaxe de cette commande :
\verbinline|\defcellcode|\ARGU{nombre 1}\ARGU{nombre 2}\ARGU{code}
\smallskip
-où :\parindent1.5em
+où :\parindent2em
\begin{itemize}
\item \ARGU{nombre 1} est la première coordonnées, le numéro de la ligne;
\item \ARGU{nombre 2} est la deuxième coordonnées, le numéro de la colonne;
@@ -440,7 +587,7 @@ Il faut noter que le code ainsi défini est exécuté \emph{lors de l'affichage
Si la commande \verbinline|\defcellcode| est appelée plusieurs fois pour définir des codes différents, et si plusieurs codes concernent une même cellule, les codes seront exécutés dans l'ordre où ils ont été définis.\medskip
-Voici un exemple où, à l'aide du package \verb|xcolor|, on choisit d'écrire en bleu le contenu de la cellule (2~,~3), d'écrire en rouge le contenu de la ligne 1, et en brun le contenu de la colonne 4.
+Voici un exemple où, à l'aide de l'extension \verb|xcolor|, on choisit d'écrire en bleu le contenu de la cellule (2~,~3), d'écrire en rouge le contenu de la ligne 1, et en brun le contenu de la colonne 4.
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
@@ -448,25 +595,25 @@ Voici un exemple où, à l'aide du package \verb|xcolor|, on choisit d'écrire e
\defcellcode{2}{3}{\color{blue}}
\defcellcode{1}{}{\color{red}}
\defcellcode{}{4}{\color{brown}}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{lstlisting}
\end{minipage}
-\smallskip
+
\defcellcode{2}{3}{\color{blue}}
\defcellcode{1}{}{\color{red}}
\defcellcode{}{4}{\color{brown}}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{center}
-On peut observer que la cellule (1 , 4) qui contient {\color{brown}\numprint{2.0}} a été colorée en brun. En effet, elle a d'abord été colorée en rouge (ligne 3 du code) \emph{puis} colorée en brun (ligne 4 du code).\bigskip
+On peut observer que la cellule (1 , 4) qui contient {\color{brown}\numprint{2}} a été colorée en brun. En effet, elle a d'abord été colorée en rouge (ligne 3 du code) \emph{puis} colorée en brun (ligne 4 du code).\bigskip
-Il existe une autre commande similaire qui exécute du code qui est \verbinline|\edefcellcode| : cette fois-ci, le code est exécuté une première fois lors de la construction de la cellule, alors que le compteur \verbinline|\tccol| contient bien le numéro de la colonne de la cellule. Lors de cette première exécution, le code est développé au maximum avec un \verbinline|\edef|\footnote{Il convient de mettre un \texttt{\string\noexpand} devant les commandes que l'on ne veut pas développer à ce moment là.}. Le développement obtenu est exécuté une seconde fois lors de l'affichage de la cellule.\medskip
+Il existe une autre commande similaire qui exécute du code qui est \verbinline|\edefcellcode| : cette fois ci, le code est exécuté une première fois lors de la construction de la cellule, alors que le compteur \verbinline|\tccol| contient bien le numéro de la colonne de la cellule. Lors de cette première exécution, le code est développé au maximum avec un \verbinline|\edef|\footnote{Il convient de mettre un \texttt{\string\noexpand} devant les commandes que l'on ne veut pas développer à ce moment là.}. Le développement obtenu est exécuté une seconde fois lors de l'affichage de la cellule.\medskip
Voici un exemple où le texte dans toutes les colonnes supérieures à la colonne \no{}2 est coloré en bleu :
\begin{center}
@@ -475,16 +622,16 @@ Voici un exemple où le texte dans toutes les colonnes supérieures à la colonn
\usepackage{color}
\edefcellcode{}{}{%
\ifnum\tccol>2 \noexpand\color{blue}\fi}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
\end{lstlisting}
\end{minipage}
-\smallskip
+
\edefcellcode{}{}{%
\ifnum\tccol>2 \noexpand\color{blue}\fi}
-\htablecalc[3]{$x$}{-2,-1,0,1,2,3}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
{$2x$}{2*x}
{$3x$}{3*x}
{$4x$}{4*x}
@@ -492,217 +639,261 @@ Voici un exemple où le texte dans toutes les colonnes supérieures à la colonn
\subsection{Personnaliser l'affichage}
\subsubsection{Les macros {\ttfamily\textbackslash printvalue} et {\ttfamily\textbackslash printresult}}\label{persoaffichage}
-Pour afficher une valeur, la commande \verbinline|\printvalue| est appelée. Elle admet un argument qui est le nombre décimal à afficher qui provient de \verb|pgfcalc| et se présente sous forme brute c'est-à-dire \verb|12345.6789| par exemple pour \numprint{12345.6789}.
+Pour afficher une valeur, la commande \verbinline|\tcprintvalue| est appelée. Elle admet un argument qui est le nombre décimal à afficher qui provient de \verb|fp| et se présente sous forme brute c'est-à-dire \verb|12345.6789| par exemple pour \numprint{12345.6789}.
-Par défaut, \verbinline|\printvalue| est définie par le code suivant :\par\nobreak\smallskip
-\hfill\verbinline|\def\printvalue#1{\numprint{#1}}|\hfill{}
+Par défaut, \verbinline|\tcprintvalue| est définie par le code suivant :\par\nobreak\smallskip
+\hfill\verbinline|\def\tcprintvalue#1{\numprint{#1}}|\hfill{}
\smallskip
On voit que la commande \verb|\numprint| est appelée pour donner un affichage soigné.\bigskip
-Pour afficher un résultat, la commande \verbinline|\printresult| est appelée. Elle admet \textbf{deux} arguments; le premier est le résultat provenant de \verb|pgfcalc| et le deuxième est la valeur qui a servi à calculer le résultat, telle qu'elle a été saisie dans la liste de valeurs.
+Pour afficher un résultat, la commande \verbinline|\tcprintresult| est appelée. Elle admet \textbf{deux} arguments; le premier est le résultat provenant de \verb|fp| et le deuxième est la valeur qui a servi à calculer le résultat, telle qu'elle a été saisie dans la liste de valeurs.
-Par défaut, \verbinline|\printresult| est définie par le code suivant :\par\nobreak\smallskip
-\hfill\verbinline|\def\printresult#1#2{\numprint{#1}}|\hfill{}
+Par défaut, \verbinline|\tcprintresult| est définie par le code suivant :\par\nobreak\smallskip
+\hfill\verbinline|\def\tcprintresult#1#2{\numprint{#1}}|\hfill{}
\smallskip
-On peut observer que l'argument \verb|#2| (la valeur) n'est pas exploitée par \verbinline|\printresult|. On peut cependant imaginer un exemple où elle le serait. Sur cet exemple, on affiche un \verb|X| rouge lorsque la dimension du côté du carré (qui est l'argument \verb|#2|) est négative. Sinon, on affiche le résultat avec l'unité. En plus, on affiche en bleu tout résultat inférieur à 10 :\par\nobreak
+On peut observer que l'argument \verb|#2| (la valeur) n'est pas exploitée par \verbinline|\tcprintresult|. On peut cependant imaginer un exemple où elle le serait. Sur cet exemple, on affiche un \verb|X| rouge lorsque la dimension du côté du carré (qui est l'argument \verb|#2|) est négative. Sinon, on affiche le résultat avec l'unité. En plus, on affiche en bleu tout résultat inférieur à 10 :\par\nobreak
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
\usepackage{color}
-\def\printresult#1#2{%
+\def\tcprintresult#1#2{%
\ifdim#1pt<10pt\color{blue}\fi
\ifdim#2pt<0pt
\color{red}\texttt{X}%
\else
\numprint[cm^2]{#1}%
\fi}
-\htablecalc{longueur}{0.7,-10,3,-2,5,12}
+\htablecalc{longueur}{x=0.7,-10,3,-2,5,12}
{aire du carr\'e}{x*x}
\end{lstlisting}
\end{minipage}
-\smallskip
-\def\printresult#1#2{%
+
+\def\tcprintresult#1#2{%
\ifdim#1pt<10pt\color{blue}\fi
\ifdim#2pt<0pt
\color{red}\texttt{X}%
\else
\numprint[cm^2]{#1}%
\fi}
-\htablecalc{longueur}{0.7,-10,3,-2,5,12}{aire du carr\'e}{x*x}
+\htablecalc{longueur}{x=0.7,-10,3,-2,5,12}{aire du carr\'e}{x*x}
\end{center}
-Une remarque : l'aire du carré de \numprint[cm]{0.7} de côté est légèrement fausse et devrait être \numprint[cm^2]{0.49} au lieu de \numprint[cm^2]{0.48999}! Le package \verb|pgfmath| n'est pas destiné à faire du calcul scientifique mais du dessin ce qui explique pourquoi la précision est des résultats est limitée au $\frac{1}{\numprint{100000}}$, et les résultats sont souvent entâchés d'erreurs d'arrondis comme celui-ci.
-
\subsubsection{Gérer les arrondis}
-En ce qui concerne l'affichage des nombres entiers, le package \verb|pgfmath| quoiqu'excellent, mais il a un défaut irritant : lorsque le résultat du calcul est un entier, il renvoie un nombre brut ayant 1 décimale nulle, comme on le voit dans le tableau ci-dessus. On peut donc tester si le résultat est un entier dans \verbinline|\printresult|. Pour cela, on peut par exemple se servir de la commande \verb|\IfInteger| du package \verb|xstring| et ne transmettre à \verb|\numprint| la valeur du compteur \verb|\integerpart| qui est la partie entière du nombre testé :
+Les calculs faits par \verb|fp| ont une grande précision $\left(10^{-12}\right)$ et les développements décimaux ont parfois beaucoup de chiffres après la virgule. Voici par exemple $\sqrt{10}$ calculé par \verb=fp= :
+\begin{center}\FPeval\truc{root(2,10)}\numprint\truc\end{center}
+Les 11 premiers chiffres sont exacts, le 12\ieme{} est arrondi.\medskip
+
+Pour les résultats, on peut utiliser la fonction \verb|round(nombre,precision)| de \verb|fp|. Si l'on ne veut pas alourdir la syntaxe des formules, on peut aussi utiliser la commande \verbinline|\tcprintroundresult| offerte par \tbcalc. Son argument est le nombre de chiffres après la virgule que l'on veut voir affichés. La macro étoilée \verbinline|\tcprintroundresult*| complète le nombre avec des 0 inutiles si nécessaire. Si l'argument est vide, la macro est neutralisée, et aucun arrondi n'est fait (comprtement par défaut).
+\begin{center}
+\begin{minipage}{0.5\linewidth}
+\begin{center}
+\begin{lstlisting}
+\tcprintroundresult{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{lstlisting}
+\tcprintroundresult{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{center}
+\end{minipage}%
+\begin{minipage}{0.5\linewidth}
+\begin{center}
+\begin{lstlisting}
+\tcprintroundresult*{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{lstlisting}
+\tcprintroundresult*{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{center}
+\end{minipage}
+\end{center}
+
+En ce qui concerne les valeurs calculées, il est \textbf{déconseillé} d'utiliser la fonction \verb|round| puisque si tel était le cas, la valeur arrondie serait utilisée pour le calculs des résultats. En voici la démonstration sur cet exemple où l'on prend comme valeurs les valeurs arrondies à $10^{-2}$ les racines carrées des entiers de 2 à 4 que l'on élève ensuite au carré :
+\begin{center}
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\htablecalc{racines}{x=round(root(2,k),2);k=2:4}
+ {carr\'e}{x*x}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc{racines}{x=round(root(2,k),2);k=2:4}
+ {carr\'e}{x*x}
+\end{center}
+Les erreurs d'arrondis des valeurs se retrouvent dans les résultats.
+
+Il convient donc d'utiliser \verbinline|\tcprintroundvalue| dont le fonctionnement et la syntaxe sont les mêmes que \verbinline|\tcprintroundresult| :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\def\printresult#1#2{%
- \IfInteger{#1}%
- {\numprint{\number\integerpart}}%
- {\numprint{#1}}%
-}
-\htablecalc{$x$}{-3,1.56,2.5,3.608}{$2x$}{2*x}
+\tcprintroundvalue{2}
+\htablecalc{racines}{x=root(2,k);k=2:4}
+ {carr\'e}{x*x}
\end{lstlisting}
\end{minipage}
-\smallskip
-\def\printresult#1#2{%
- \IfInteger{#1}%
- {\numprint{\number\integerpart}}%
- {\numprint{#1}}%
-}
-\htablecalc{$x$}{-3,1.56,2.5,3.608}{$2x$}{2*x}
+
+\tcprintroundvalue{2}
+\htablecalc{racines}{x=root(2,k);k=2:4}
+ {carr\'e}{x*x}
\end{center}
+Les résultats ---~non arrondis, eux!~--- sont bien plus proches des entiers attendus.
-On peut toujours demander à \verb|numprint| d'afficher un certain nombre de chiffres après la virgule avec la commande \verb|\nprounddigits| dont l'argument est le nombre de chiffres de la partie décimale. Mais des 0 inutiles sont rajoutés si nécessaire.
\subsubsection{Pour le fun}
-On peut imaginer des détournements de ce package, comme par exemple afficher un échiquier dont les cases mesurent \numprint[cm]{0.5} de côté :\par\nobreak\parindent1.5em
+On peut imaginer des détournements de \tbcalc, comme par exemple afficher un échiquier dont les cases mesurent \numprint[cm]{0.5} de côté :\par\nobreak\parindent2em
\begin{itemize}
- \item on initailise à \verb|0pt| les séparateurs du tableau à la ligne 2 pour ne pas fausser la dimension voulue de \numprint[cm]{0.5};
- \item l'affichage de toutes les valeurs et résultats est neutralisé à la ligne 3;
- \item ensuite on ne dessine que les filets horizontaux du haut et du bas du tableau (ligne 4), et les filets de gauche et droite (ligne 5);
- \item on définit un strut de hauteur \numprint[cm]{0.5} au début de chaque ligne (ligne 6);
- \item et on teste si la somme de la ligne et de la colonne en cours est impaire (ligne 8) auquel cas, on colore la case en gris (ligne 9).
+ \item on initialise à \verb|0pt| les séparateurs du tableau à la ligne 1 pour ne pas fausser la dimension voulue de \numprint[cm]{0.5};
+ \item l'affichage de toutes les valeurs et résultats est neutralisé à la ligne 2;
+ \item ensuite on ne dessine que les filets horizontaux du haut et du bas du tableau (ligne 3), et les filets de gauche et droite (ligne 4);
+ \item on définit un strut de hauteur \numprint[cm]{0.5} au début de chaque ligne (ligne 5);
+ \item et on teste si la somme de la ligne et de la colonne en cours est impaire (ligne 7) auquel cas, on colore la case en gris (ligne 8).
\end{itemize}\parindent0em
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\usepackage{colortbl,xcolor}
\arraycolsep=0pt\tabcolsep=0pt
-\def\printvalue#1{}\def\printresult#1#2{}
-\sethrule{\hline}{}{}
-\setcoltype[|]{|m{0.5cm}}{m{0.5cm}}
-\def\startline{\rule[-0.2cm]{0pt}{0.3cm}}
+\def\tcprintvalue#1{}\def\tcprintresult#1#2{}
+\tcsethrule{\hline}{}{}
+\tcsetcoltype[|]{|m{0.5cm}}{m{0.5cm}}
+\def\tcatbeginrow{\rule[-0.2cm]{0pt}{0.3cm}}
\edefcellcode{}{}{%
\ifodd\numexpr\tccol+\tclin\relax
\noexpand\cellcolor{lightgray}\fi
}
-\htablecalc[7]{}{ , , , , , , }
- {}{}{}{}{}{}{}{}{}{}{}{}{}{}
+\htablecalc[7]{}{x=1,2,3,4,5,6,7}
+ {}{x}{}{x}{}{x}{}{x}{}{x}{}{x}{}{x}
\end{lstlisting}
\end{minipage}
-\smallskip
+
\arraycolsep=0pt\tabcolsep=0pt
-\def\printvalue#1{}\def\printresult#1#2{}
-\sethrule{\hline}{}{}
-\setcoltype[|]{|m{0.5cm}}{m{0.5cm}}
-\def\startline{\rule[-0.2cm]{0pt}{0.3cm}}
+\def\tcprintvalue#1{}\def\tcprintresult#1#2{}
+\tcsethrule{\hline}{}{}
+\tcsetcoltype[|]{|m{0.5cm}}{m{0.5cm}}
+\def\tcatbeginrow{\rule[-0.2cm]{0pt}{0.3cm}}
\edefcellcode{}{}{%
\ifodd\numexpr\tccol+\tclin\relax
\noexpand\cellcolor{lightgray}\fi
}
-\htablecalc[7]{}{ , , , , , , }
- {}{}{}{}{}{}{}{}{}{}{}{}{}{}
+\htablecalc[7]{}{x=1,2,3,4,5,6,7}
+ {}{x}{}{x}{}{x}{}{x}{}{x}{}{x}{}{x}
\end{center}
-\section{Changer de moteur de calcul}\label{changemoteurcalcul}
-\verb|pgfmath|, le moteur de calcul mathématique de \verb|pgf| est utilisé par défaut, mais on peut en choisir un autre, bien qu'il n'y ait pas grand choix : à ma connaissance, il existe les packages \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\texttt{\textbf{fp}}} et \href{http://www.ctan.org/tex-archive/macros/generic/xlop/}{\texttt{\textbf{xlop}}} qui effectuent des calculs mathématiques sous \LaTeX{}. Ils ont chacun des inconvénients, c'est pour cela qu'ils ne sont pas sélectionnés par défaut :\par\nobreak\parindent1.5em
-\begin{itemize}
- \item \og\verb|fp|\fg{} utilise la notation polonaise inverse ce qui est peu habituel. On peut cependant utiliser la notation infixe mais le signe d'opposé \og${}-{}$\fg{} devant un nombre n'est pas géré : très embêtant pour les valeurs négatives;
- \item \og\verb|xlop|\fg{} n'est pas seulement un package de calcul, il affiche aussi les résultats. De plus, il ne dispose pour l'instant que des opérations arithmétiques.
-\end{itemize}\parindent0em
-\medskip
-
-La macro \verbinline|\tc@evalexpr| est chargé d'effectuer les calculs. Elle n'admet pas d'argument et son fonctionnement est très simple : elle prend \verbinline|\tc@currentresult| dont le développement est une expression numérique à évaluer, par exemple \og\verb|4*2.5*2.5-3*2.5-7|\fg{}. Elle fait appel à un moteur de calcul qui évalue cette expression (ici, cela donnerait \verb|10.5|), et enfin, elle assigne ce résultat à \verbinline|\tc@currentresult|.
+\section{Exporter un tableau dans un fichier}
+Aussi personnalisable qu'il soit, \tbcalc ne peut couvrir tous les cas, et des ajustements fins sont parfois nécessaires dans les tableaux générés. La commande \verbinline=\tcwritetofile=\ARGU{filename} admet un argument obligatoire qui est un nom de fichier sans l'extension. Le première instruction \verbinline=\htablecalc= ou \verbinline=\vtablecalc= qui suit cette commande ne produira pas l'affichage d'un tableau, mais un fichier \argu{filename}\verb|.tex| sera créé dans le répertoire courant dont le contenu sera le code \TeX{} du tableau.\medskip
-Par défaut, la macro \verbinline|\tc@evalexpr| est définie par le code suivant :\par\nobreak
+Voyons ceci sur un exemple :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\def\tc@evalexpr{%
- \expandafter\pgfmathparse
- \expandafter{\tc@currentresult}%
- \let\tc@currentresult\pgfmathresult}
+\tcwritetofile{mytable}
+\defcellcode{}{2}{\color{blue}}
+\htablecalc[2]{$x$}{x=k;k=0:4}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\tcresetcellcode
\end{lstlisting}
\end{minipage}
\end{center}
-
-Mettons que l'on choisisse le package \verb|fp| pour exécuter nos calculs: redéfinissons \verbinline|\tc@evalexpr| :\par\nobreak
+\tcwritetofile{mytable}
+\defcellcode{}{2}{\color{blue}}
+\htablecalc[2]{$x$}{x=k;k=0:4}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\tcresetcellcode
+
+Un fichier \og\verb=mytable.tex=\fg{} est créé dans le répertoire courant et son contenu est le code du tableau qui aurait dû être affiché :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\makeatletter
-\def\tc@evalexpr{%
- \expandafter\FPeval\expandafter
- \tc@currentresult\expandafter{\tc@currentresult}%
- \FPclip\tc@currentresult\tc@currentresult
-}
-\makeatother
+\begin {tabular}{|c|*{5}{c|}}\hline
+\tcatbeginrow $x$&\tcprintvalue {0}&\color {blue}\tcprintvalue {1}&\tcprintvalue {2}&\tcprintvalue {3}&\tcprintvalue {4}\\\hline
+\tcatbeginrow $2x$&\tcprintresult {0}{0}&\color {blue}\tcprintresult {2}{1}&\tcprintresult {4}{2}&\tcprintresult {6}{3}&\tcprintresult {8}{4}\\ \hline
+\tcatbeginrow $x^2$&\tcprintresult {0}{0}&\color {blue}\tcprintresult {1}{1}&\tcprintresult {4}{2}&\tcprintresult {9}{3}&\tcprintresult {16}{4}\\ \hline
+\end {tabular}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+Cela laisse à l'utilisateur le loisir de modifier ce code à sa convenance puis d'inclure ce fichier à tout moment dans le code \LaTeX{} d'un document avec :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\input{mytable.tex}
\end{lstlisting}
\end{minipage}
\end{center}
+et voici le résultat :
+\begin{center}
+\input{mytable.tex}
+\end{center}
-On a utilisé la commande \verb|\FPclip| pour enlever tous les zéros inutiles du résultat (voir la documentation de \verb|fp|).
+\section{Utiliser la notations infixée et postfixée}
+La notation infixée ou postfixée peut-être utilisée indifféremment puisque \tbcalc utilise \verb=\FPeval= qui accepte les deux. Dans cet exemple, le même tableau est généré avec la notation infixée puis avec la notation postfixée. Les résultats obtenus sont évidemment strictement les mêmes puisque le moteur de calcul est le même; seule la notation change :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\tcprintroundvalue{6}
+\tcprintroundresult{6}
+Avec la notation infix\'ee\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=10^k;k=-3:3}
+ {$\log x$}{ln(x)/ln(10)}
+ {$\sqrt{x}$}{root(2,x)}
+ {$\frac{1}{x}$}{1/x}
-Ça y est, le moteur de calcul de \tbcalc est maintenant \verb|fp| :\par\nobreak
+\medskip
+Avec la notation postfix\'ee\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=k 10 pow;k=-3:3}
+ {$\log x$}{x ln 10 ln div}
+ {$\sqrt{x}$}{2 x root}
+ {$\frac{1}{x}$}{1 x div}
+\end{lstlisting}
+\end{minipage}
+
+\tcprintroundvalue{6}
+\tcprintroundresult{6}
+Avec la notation infix\'ee\par\nobreak
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=10^k;k=-3:3}
+ {$\log x$}{ln(x)/ln(10)}
+ {$\sqrt{x}$}{root(2,x)}
+ {$\frac{1}{x}$}{1/x}
+
+\medskip
+Avec la notation postfix\'ee\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=k 10 pow;k=-3:3}
+ {$\log x$}{x ln 10 ln div}
+ {$\sqrt{x}$}{2 x root}
+ {$\frac{1}{x}$}{1 x div}
+\end{center}
+On préfèrera ---~ dans la mesure où on la maîtrise~--- la notation postfixée qui permet bien souvent d'économiser du temps de calcul. Ainsi, le calcul $\cos x(1-\cos x)$ s'écrit ainsi en notation infixée
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\usepackage{fp}
-\htablecalc{$x$}{0.5,1,2.5,10}
- {$2x^2-\frac{1}{2}$}{2*x*x-0.5}
+cos(x)*(1-cos(x))
\end{lstlisting}
\end{minipage}
-\smallskip
-\makeatletter
-\def\tc@evalexpr{%
- \expandafter\FPeval\expandafter
- \tc@currentresult\expandafter{\tc@currentresult}%
- \FPclip\tc@currentresult\tc@currentresult
-}
-\makeatother
-\htablecalc{$x$}{0.5,1,2.5,10}
- {$2x^2-\frac{1}{2}$}{2*x*x-0.5}
\end{center}
+Ce qui fait que $\cos x$ est calculé deux fois inutilement.\smallskip
-Le gros problème est que \verb|fp| ne gère pas les signes ${}-{}$ devant les nombres comme étant un signe d'opposé, et une valeur de \og\verb|-3|\fg{} aurait fait planter \verb|fp| ! On peut éviter cette limitation en utilisant la notation polonaise inverse mais il faut à nouveau modifier \verbinline|\tc@evalexpr| pour lui dire de faire le calcul en notation polonaise inverse (d'où l'utilisation de \verb|\FPupn|), et faire quelques adaptations dans \verbinline|\printvalue| évaluer les valeurs qui sont aussi écrites en notation polonaise inverse (on écrit \verb|3 neg|) pour \verb|-3|) :\par\nobreak
+Avec la notation postfixée, on ne le calcule qu'une seule fois :
\begin{center}
\begin{minipage}{\mywidth}
\begin{lstlisting}
-\usepackage{fp}
-\makeatletter
-\def\tc@evalexpr{%
- \expandafter\FPupn\expandafter
- \tc@currentresult\expandafter{\tc@currentresult}%
- \FPclip\tc@currentresult\tc@currentresult
-}
-\makeatother
-\def\printvalue#1{%
- \FPupn\tempval{#1}%
- \FPclip\tempval\tempval
- \numprint\tempval
-}
-\htablecalc{$x$}{3 neg,0.5,1,2.5,10}
- {$2x^2-\frac{1}{2}$}{x x mul 2 mul 0.5 sub}
+x cos copy 1 swap sub mul
\end{lstlisting}
\end{minipage}
-\makeatletter
-\def\tc@evalexpr{%
- \expandafter\FPupn\expandafter
- \tc@currentresult\expandafter{\tc@currentresult}%
- \FPclip\tc@currentresult\tc@currentresult
-}
-\makeatother
-\def\printvalue#1{%
- \FPupn\tempval{#1}%
- \FPclip\tempval\tempval
- \numprint\tempval
-}
-\htablecalc{$x$}{3 neg,0.5,1,2.5,10}
- {$2x^2-\frac{1}{2}$}{x x mul 2 mul 0.5 sub}
\end{center}
-\bigskip\bigskip
+\bigskip
\begin{center}
$\star$\par
$\star$\quad$\star$
\end{center}
-\bigskip\bigskip
-C'est tout, j'espère que ce package vous sera utile !\par\nobreak
+\bigskip
+C'est tout, j'espère que cette extension vous sera utile !\par\nobreak
Merci de me signaler par \href{mailto:unbonpetit@gmail.com}{\texttt{\textbf{email}}} tout bug ou toute proposition d'amélioration\ldots\par\nobreak\bigskip
Christian \textsc{Tellechea}
\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_vn.pdf b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_vn.pdf
new file mode 100644
index 00000000000..6f75bb4d020
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_vn.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_vn.tex b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_vn.tex
new file mode 100644
index 00000000000..69d1c6b36a3
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/tabularcalc/tabularcalc_doc_vn.tex
@@ -0,0 +1,888 @@
+% This is tabularcalc_doc_vn.tex, the vietnamese manual of tabularcalc
+%
+% Tác giả: Christian Tellechea 2009
+% Email: unbonpetit@gmail.com
+% Dịch bởi: Lê Hữu Điền Khuê
+% Email: huudienkhue.le@gmail.com
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+%
+% http://www.latex-project.org/lppl.txt
+%
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\documentclass[a4paper,10pt]{article}
+\usepackage[utf8]{vietnam}
+%\usepackage{vntex}
+\usepackage[T1,T5]{fontenc}
+\usepackage[unicode,a4paper,dvips,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,bookmarks=true,pdfauthor={Christian TELLECHEA. Translator: Le Huu Dien Khue},pdftitle={tabularcalc},pdfsubject={package pour construction d'un tableau de valeurs},pdfkeywords={tabularcalc},pdfcreator={LaTeX},pdftex]{hyperref}
+\usepackage[a4paper,dvips,margin=2.75cm]{geometry}
+\usepackage[autolanguage]{numprint}
+\usepackage{colortbl}
+\usepackage{xcolor}
+\usepackage{lmodern}
+\usepackage{xspace}
+\usepackage{listings}
+\usepackage{tabularcalc}
+\usepackage[bottom]{footmisc}
+
+\makeatletter
+\definecolor{tc@bckgcolor}{rgb}{1,1,0.875}
+\definecolor{tc@keywordstc}{rgb}{0.7,0,0}
+\definecolor{tc@keywordslatex}{rgb}{0,0,1}
+\definecolor{tc@arguments}{rgb}{0,0,0}
+\definecolor{tc@comments}{rgb}{0.5,0.5,0.5}
+\lstset{%
+ language=[AlLaTeX]TeX,%
+ float=hbp,%
+ basicstyle=\footnotesize\ttfamily,%
+ identifierstyle=\color{tc@arguments},%
+ keywordstyle=\color{tc@keywordslatex},%
+ commentstyle=\itshape\color{tc@comments},%
+ columns=fixed,%
+ tabsize=4,%
+ frame=single,%
+ extendedchars=false,%
+ showspaces=false,%
+ showstringspaces=false,%
+ numbers=left,%
+ numberstyle=\tiny\ttfamily,%
+ breaklines=true,%
+ breakindent=3em,%
+ backgroundcolor=\color{tc@bckgcolor},%
+ breakautoindent=true,%
+ captionpos=t,%
+ xleftmargin=1em,%
+ xrightmargin=1em,%
+ lineskip=0pt,%
+ numbersep=1em,
+ classoffset=1,%
+ morekeywords={% các lệnh và macro của tabularcalc
+ tccol,tclin,%
+ htablecalc,vtablecalc,%
+ tcnoshowmark,tcatbeginrow,tcresetcellcode,edefcellcode,defcellcode,%
+ tcsethrule,tcresethrule,tcsetcoltype,tcresetcoltype,%
+ tcprintvalue,tcprintresult,tclistsep,%
+ tcprintroundresult,tcprintroundvalue,tcwritetofile},%
+ keywordstyle=\color{tc@keywordstc},%
+ classoffset=0}
+\makeatother
+
+\newcommand\guill[1]{\og{}#1\fg{}}
+\newcommand\argu[1]{$\langle$\textit{#1}$\rangle$}
+\newcommand\ARGU[1]{\texttt{\{}\argu{#1}\texttt{\}}}
+\newcommand\arguC[1]{\texttt{[}\argu{#1}\texttt{]}}
+
+\newcommand\tbcalc{\textsf{tabularcalc}\xspace}
+\newcommand\verbinline{\lstinline[breaklines=false,basicstyle=\normalsize\ttfamily]}
+\newcommand\mywidth{0.85\linewidth}
+
+\begin{document}
+\setlength{\parindent}{0pt}
+\begin{titlepage}
+ \null\par\vfill
+ \begin{center}
+ \begin{minipage}{0.75\linewidth}
+ \begin{center}
+ \Huge\bfseries \tbcalc\par\vspace{5pt}
+ \small v\tabularcalcversion\par\vspace{25pt}
+ \normalsize Hướng dẫn sử dụng
+ \end{center}
+ \end{minipage}
+ \end{center}
+ \vspace{1cm}
+ \begin{center}
+ Christian {\sc Tellechea}\par\small
+ \href{mailto:unbonpetit@gmail.com}{\texttt{\textbf{unbonpetit@gmail.com}}}\par\vspace{5pt}
+ Dịch bởi Lê Hữu Điền Khuê\par\small
+ \href{mailto:huudienkhue.le@gmail.com}{\texttt{\textbf{huudienkhue.le@gmail.com}}}\par\vspace{5pt}
+ 20.4.2009
+ \end{center}
+ \vfill\hrulefill
+ \begin{center}
+ \begin{minipage}{0.85\linewidth}
+ \noindent
+ \hfill\textbf{\textit{Tóm tắt}}\hfill{}\medskip\par
+ Được trang bị bởi một danh sách các số và một (hoặc nhiều) công thức (hay hàm số) một biến, \tbcalc giúp chúng ta xây dựng các bảng giá trị bằng các cú pháp rất đơn giản. "Bảng giá trị" ở đây được hiểu là bảng có hàng đầu tiên chứa các giá trị của biến số và các hàng còn lại chứa giá trị của các hàm theo biến số, tương ứng với mỗi giá trị của biến số :
+ \begin{center}
+ \tcsethrule{\hline}{\hline\hline}{\hline}
+ \tcsetcoltype{|c|}{>{\centering\arraybackslash}m{1.5cm}|}
+ \htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+ \end{center}
+ Một bảng có thể được xây dựng theo chiều ngang hay chiều dọc và có thể thay đổi theo ý muốn (chiều cao của một ô, kiểu hàng, kiểu cột,...). Hơn nữa, chúng ta có thể ẩn đi giá trị của một (hay một số) ô bất kì. Ngoài ra, đối với mỗi ô, bất kì dòng lệnh nào của \TeX{} cũng đều có hiệu lực, do đó gói này còn có nhiều chức năng khác nữa, tuỳ theo ý muốn của người sử dụng.
+\smallskip
+ \end{minipage}
+ \end{center}
+ \hrulefill\vfill{}
+\end{titlepage}
+
+\tableofcontents
+
+\bigskip
+Tác giả xin gửi lời cảm ơn đến Derek~\textsc{O'Connor}, người đã thử nghiệm phiên bản bêta và đóng góp rất nhiều ý kiến có giá trị.
+
+\section{Mở đầu}
+\subsection{Giới thiệu}
+Gói \tbcalc cho phép xây dựng rất dễ dàng các bảng giá trị của hàm số một biến ứng với mỗi giá trị của biến. Các bảng được trình bày dưới môi trường chuẩn của \verb|tabular| và các giá trị được hiển thị dưới dạng thập phân.
+
+\tbcalc cần đến \LaTeX và các gói phụ trợ \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\texttt{\textbf{fp}}}, \href{http://www.ctan.org/tex-archive/macros/latex/contrib/xstring/}{\texttt{\textbf{xstring}}} và \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}}.
+
+Gói này được tạo ra hoàn toàn không phải để cạnh tranh với \href{http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/}{\texttt{\textbf{pgfplotstable}}}, một gói rất tuyệt vời của Christian~\textsc{Feuers\"anger}. So với \tbcalc, gói này có thể nói là mạnh hơn nhiều, tuy nhiên các câu lệnh của nó khá phức tạp. Còn \tbcalc, mặc dù khá giản dị, nhưng lại rất dễ sử dụng.\medskip
+
+Về mặt hiển thị kết quả với các chữ số thập phân, theo tác giả gói \href{http://www.ctan.org/tex-archive/macros/latex/contrib/numprint/}{\texttt{\textbf{numprint}}} là tốt nhất, do đó nó cũng được gọi vào theo mặc định. Chúng ta cũng có thể thay đổi gói này bằng một gói khác, hoặc thay đổi cách hiển thị các giá trị theo ý muốn (xem trang~\pageref{persoaffichage}).\medskip
+
+\subsection{Về gói \ttfamily fp}
+Về mặt tính toán, với \TeX{}, \tbcalc không thực hiện việc tính trực tiếp giá trị của các biểu thức, chẳng hạn như \verb|2*x*x-5*x+7| khi \hbox{\verb|x = 2.7|}, mà nó sẽ gọi thêm một "máy tính" phụ trợ là \verb=fp=.\smallskip
+
+Chúng ta có thể sử dụng cú pháp \emph{trung tố} (infix) hoặc \emph{hậu tố} (postfix) để nhập vào các hàm số. Xem thêm tập tin \href{http://www.ctan.org/get/macros/latex/contrib/fp/README}{\texttt{\textbf{README}}} của gói \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fp/}{\texttt{\textbf{fp}}} để hiểu rõ thêm hai khái niệm trên cũng như danh sách đầy đủ các hàm số có thể sử dụng.\medskip
+
+Tuy nhiên, khi làm việc với hàm số mũ, gói này có hai lỗi sau đây :
+\begin{itemize}
+ \item thêm vào một khoảng trống không như ý muốn;
+ \item để tính $a^b$, \verb=fp= sử dụng công thức $a^b=\mathrm{e}^{b\ln a}$. Trong trường hợp $b$ là một số nguyên và $a$ là một số âm, chẳng hạn $(-3)^2=\mathrm{e}^{2\ln(-3)}$, thì rõ ràng nó sẽ không tính được, bởi vì lô-ga-rít của một số âm là không xác định.
+\end{itemize}\smallskip
+Để sửa hai lỗi này, chúng ta cần thêm vào tuỳ chọn \verb=fixFPpow= như sau :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\usepackage[fixFPpow]{tabularcalc}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+
+\subsection{Một số điểm mới}
+Phiên bản trước của \tbcalc không tương thích được với một số gói khác bởi vì tên của một số macro bị trùng. Do vậy, để tránh vấn đề tương tự với phiên bản này, tác giả đã quyết định đổi tên của tất cả các macro bằng cách thêm vào "\verb-tc-" (viết tắt của \textsf{\textbf{t}abular\textbf{c}alc}) ở trước tên cũ, như trong bảng sau :
+\begin{center}
+ \begin{tabular}{rl}
+ Tên cũ&Tên mới \\\hline
+ \verb=\noshowmark=&\verb=\tcnoshowmark=\\
+ \verb=\startline=&\verb=\tcatbeginrow=\\
+ \verb=\resetcellcode=&\verb=\tcresetcellcode=\\
+ \verb=\listsep=&\verb=\tclistsep=\\
+ \verb=\printvalue=&\verb=\tcprintvalue=\\
+ \verb=\printresult=&\verb=\tcprintresult=\\
+ \verb=\sethrule=&\verb=\tcsethrule=\\
+ \verb=\resethrule=&\verb=\tcresethrule=\\
+ \verb=\setcoltype=&\verb=\tcsetcoltype=\\
+ \verb=\resetcoltype=&\verb=\tcresetcoltype=
+ \end{tabular}
+\end{center}
+
+Các điểm mới khác :\parindent2em
+\begin{itemize}
+ \item "máy tính" \verb=pgfmath=, do độ chính xác kém, đã được thay thế bằng \verb=fp=;
+ \item các giá trị của biến có thể được nhập vào một cách tổng quát bằng công thức;
+ \item kể từ bây giờ, chúng ta có thể soạn thảo lệnh của một bảng trong một tập tin riêng, điều này giúp ta sửa đổi dễ dàng các bảng.
+\end{itemize}\parindent0pt
+
+\subsection{Thuật ngữ}
+Trong phần tiếp theo của bài viết, để bạn đọc dễ theo dõi, chúng ta quy ước những số màu đỏ là các "{\color{red}giá trị}" của biến, màu xanh là "{\color{blue}kết quả}" (giá trị cần tính), các biểu thức màu nâu là các "{\color{brown}nhãn}" (biểu thức cần tính) và ô góc trên cùng bên trái của một bảng gọi là "ô (0,0)", chẳng hạn như hai bảng sau đây:
+
+\begin{minipage}{0.5\linewidth}
+\begin{center}
+{\scriptsize Bảng ngang}\par\nobreak\smallskip
+\def\tcprintvalue#1{\color{red}$#1$}
+\def\tcprintresult#1#2{\color{blue}$#1$}
+\htablecalc[3]{ô (0,0)}{x=-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
+\end{center}
+\end{minipage}%
+\begin{minipage}{0.5\linewidth}
+\begin{center}
+{\scriptsize Bảng dọc}\par\nobreak\smallskip
+\def\tcprintvalue#1{\color{red}$#1$}
+\def\tcprintresult#1#2{\color{blue}$#1$}
+\vtablecalc[3]{ô (0,0)}{x=-5,-1,0,3,10}{\color{brown}$x$}{x}{\color{brown}$2x$}{2*x}{\color{brown}$3x$}{3*x}
+\end{center}
+\end{minipage}
+
+\section{Chức năng cơ bản}
+\subsection{Bảng ngang} \label{bangngang}
+Lệnh \verbinline|\htablecalc| cho phép tạo ra một bảng ngang trong đó hàng đầu tiên chứa giá trị của biến và các hàng còn lại chứa các kết quả. Cú pháp:\smallskip
+
+\setbox0=\hbox{\verbinline|\htablecalc|\arguC{nb}}
+\verbinline|\htablecalc|\arguC{nb}\ARGU{ô (0,0)}\argu{biến=danh sách}\par
+\hskip\wd0\ARGU{nhãn 1}\ARGU{công thức 1}\par
+\hskip\wd0\ARGU{nhãn 2}\ARGU{công thức 2}\par
+\hskip\wd0\ldots\par
+\hskip\wd0\ARGU{nhãn n}\ARGU{công thức n}\medskip
+
+trong đó:\parindent1.5em
+\begin{itemize}
+ \item \argu{nb} là số công thức cần tính (bằng 1 theo mặc định);
+ \item \argu{ô (0,0)} là nội dụng của ô (0,0);
+ \item \argu{biến} là tên của biến, tên này sẽ được sử dụng trong các \argu{công thức}.
+ \item \argu{danh sách} là danh sách các giá trị của biến, cách nhau bởi dấu phẩy (Chú ý: dấu phẩy trong các số thập phân phải được thay bằng dấu chấm), nếu có hai dấu phẩy liên tiếp nhau thì sẽ có một cột trống được in ra. Chúng ta có thể thay dấu phẩy bằng một kí tự khác, chẳng hạn với "|", ta dùng lệnh \verbinline=\def\tclistsep{|}=.
+ \item \argu{nhãn i} là nhãn thứ i;
+ \item \argu{công thức i} là công thức thứ i cần tính (tương ứng với hàng thứ i).
+\end{itemize}\parindent0em
+\medskip
+
+Dưới đây là một ví dụ về bảng ở trang đầu tiên của tài liệu :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{lstlisting}
+
+\end{minipage}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{center}
+
+Chúng ta thấy rằng bảng này không hoàn toàn giống với bảng ở trang đầu : độ rộng của các cột không bằng nhau và đường kẻ ngang dưới hàng thứ nhất cũng khác nhau. Chúng ta sẽ tìm hiểu về cách thay đổi các đặc điểm này trong phần sau của tài liệu.
+
+\subsection{Bảng dọc}
+Lệnh \verbinline|\vtablecalc| cho phép tạo ra một bảng dọc trong đó cột đầu tiên là giá trị của biến và các cột còn lại là các kết quả. Cú pháp :\smallskip
+
+\setbox0=\hbox{\verbinline|\vtablecalc|\arguC{nb}}
+\verbinline|\vtablecalc|\arguC{nb}\ARGU{ô (0,0)}\argu{biến=danh sách}\par
+\hskip\wd0\ARGU{nhãn 1}\ARGU{công thức 1}\par
+\hskip\wd0\ARGU{nhãn 2}\ARGU{công thức 2}\par
+\hskip\wd0\ldots\par
+\hskip\wd0\ARGU{nhãn n}\ARGU{công thức n}\medskip
+
+trong đó các khái niệm trong cú pháp trên đều được xác định như trong mục \ref{bangngang} \emph{Bảng ngang}.
+\medskip
+
+Sau đây là ví dụ về một bảng dọc của hai bảng trước, trong đó ta sử dụng tên biến là \verb=y= :\par\nobreak
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\vtablecalc[3]{$x$}{y=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*y-3}
+ {$x^2$}{y*y}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,y*y+1),6)}
+\end{lstlisting}
+\end{minipage}
+
+\vtablecalc[3]{$x$}{y=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*y-3}
+ {$x^2$}{y*y}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,y*y+1),6)}
+\end{center}
+
+\subsection{Ẩn nội dung của một ô} \label{ano}
+Chúng ta có thể giấu đi nội dung của một ô bất kì, trong bảng ngang cũng như bảng dọc.
+
+\subsubsection{Ẩn giá trị}
+Để ẩn đi một giá trị (của biến) nào đó, trong danh sách các biến, chúng ta chỉ cần đặt trước giá trị đó kí tự "\verb|@|". Trong ví dụ sau đây, chúng ta sẽ ẩn đi giá trị thứ 2 và thứ 5: \smallskip
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[3]{$x$}{x=-4,@-2,0,2.25,@7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc[3]{$x$}{x=-4,@-2,0,2.25,@7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{center}
+\medskip
+
+Nếu muốn thay \verb|@| bằng một kí tự khác thì chỉ cần dùng lệnh \verbinline|\def\tcnoshowmark|, chẳng hạn nếu muốn thay \verb|@| bởi \verb|=|, ta dùng \verbinline|\def\tcnoshowmark{=}|.
+
+\subsubsection{Ẩn kết quả}
+Với mỗi giá trị cho trước, chúng ta có thể ẩn các kết quả thứ $a_1,a_2,\ldots,a_n$ bằng cách thêm $[a_1][a_2]\ldots[a_n]$ vào sau giá trị này, trong đó $a_i$ được sắp xếp theo thứ tự tăng dần. Nếu một $a_j$ nào đó bằng 0, tất cả các kết quả thứ $a_k$ với $k>j$ đều được ẩn đi.\medskip
+Trong ví dụ sau đây, chúng ta sẽ:\parindent2em
+\begin{itemize}
+ \item ẩn đi kết quả thứ 2 của giá trị đầu tiên với "\verb|-4[2]|"
+ \item hiển thị tất cả các kết quả của giá trị thứ 2 với "\verb|-2|"
+ \item ẩn đi kết quả thứ nhất và thứ 3 của giá trị thứ 3 với "\verb|0[1][3]|"
+ \item ẩn đi tất cả các kết quả của giá trị thứ 4 với "\verb|2.25[0]|"
+ \item ẩn đi tất cả các kết quả từ thứ 2 trở đi của giá trị thứ 5 với "\verb|7[2][0]|"
+\end{itemize}\parindent0em
+
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[3]{$x$}{x=-4[2],-2,0[1][3],2.25[0],7[2][0]}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc[3]{$x$}{x=-4[2],-2,0[1][3],2.25[0],7[2][0]}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{center}
+Chúng ta cũng có thể kết hợp cú pháp này với \verb|@| để ẩn đi cả giá trị lẫn kết quả nếu muốn.
+
+\subsection{Chiều cao của hàng}
+Khi hiển thị một bảng, \tbcalc sẽ thực hiện lệnh \verbinline|\tcatbeginrow| ở đầu của mỗi hàng. Theo mặc định, lệnh này được định nghĩa bởi \verbinline|\def\tcatbeginrow{\rule[-1.2ex]{0pt}{4ex}}|. Mặc nhiên, lệnh này đã cố định chiều cao của tất cả các hàng bằng cách sử dụng các "cây thước" có bề rộng 0pt. Để dễ hình dung, đây là một "cây thước" với bề rộng 2pt nằm trước chữ "a" : \rule[-1.2ex]{2pt}{4ex}a\medskip
+
+Như vậy chúng ta có thể thay thế "cây thước" này bằng một thứ khác. Ví dụ :
+
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\def\tcatbeginrow{%
+ {\bfseries\number\tclin)\ }%
+}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{lstlisting}
+\end{minipage}
+
+\def\tcatbeginrow{%
+ {\bfseries\number\tclin)\ }%
+}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{center}
+Trong ví dụ này, ở đầu hàng, chúng ta đã hiển thị (và in đậm) số thứ tự của mỗi hàng (số thứ tự này được cung cấp bởi bộ đếm \verbinline|\tclin|).
+
+\subsection{Đường kẻ ngang}
+\tbcalc cung cấp 3 kiểu đường kẻ ngang, tương ứng với 3 tham số của lệnh \verbinline|\tcsethrule| :
+
+\parindent2em
+\begin{itemize}
+ \item "đường 0" là đường kẻ ngang ở trên cùng và dưới cùng của bảng;
+ \item "đường 1" là đường kẻ ngang ngay dưới hàng thứ nhất;
+ \item "các đường khác" là các đường kẻ ngang ngay dưới các hàng kết quả (trừ hàng cuối cùng).
+\end{itemize}\parindent0em
+Đây là cú pháp :
+
+\verbinline|\tcsethrule|\ARGU{đường 0}\ARGU{đường 1}\ARGU{các đường khác}
+\medskip
+
+Theo mặc định, cả ba tham số đều là \verbinline|\hline|.\medskip
+
+Sau đây là một ví dụ trong đó đường kẻ ngang dưới hàng thứ nhất là một đường đôi và các đường khác đều bị xoá :
+
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\tcsethrule{\hline}{\hline\hline}{}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
+ {$2x$}{2*x}
+ {$3x$}{3*x}
+ {$4x$}{4*x}
+\end{lstlisting}
+\end{minipage}
+
+\tcsethrule{\hline}{\hline\hline}{}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
+ {$2x$}{2*x}
+ {$3x$}{3*x}
+ {$4x$}{4*x}
+\end{center}
+
+Lệnh \verbinline|\tcresethrule| cho phép trở lại các kiểu đường kẻ ngang như mặc định.
+
+\subsection{Tuỳ chọn đối với cột}
+\subsubsection{Đường kẻ dọc}
+\tbcalc có hai loại cột : cột đầu tiên (bên trái) và các cột còn lại. Lệnh \verbinline|\setcoltype| sử dụng một tham số tuỳ chọn và hai tham số bắt buộc :
+\begin{itemize}
+ \item tham số tuỳ chọn, trống theo mặc định, xác định đường kẻ dọc "|" cuối cùng (bên phải) của bảng;
+ \item tham số bắt buộc thứ nhất xác định các đường kẻ của cột thứ nhất (nếu không sử dụng \verbinline|\setcoltype| thì nó được mặc định là "|c|";
+ \item tham số bắt buộc thứ hai xác định các đường kẻ của các cột còn lại (nếu không sử dụng \verbinline|\setcoltype| thì nó được mặc định là "c|"
+\end{itemize}\medskip
+
+Cú pháp :\par\nobreak
+\verbinline|\tcsetcoltype|\arguC{tuỳ chọn}\ARGU{tham số 1}\ARGU{tham số 2}\medskip
+
+Sau đây là một ví dụ :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\tcsetcoltype[||]{||c||}{c}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
+ {$2x$}{2*x}
+ {$3x$}{3*x}
+ {$4x$}{4*x}
+\end{lstlisting}
+\end{minipage}
+
+\tcsetcoltype[||]{||c||}{c}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
+ {$2x$}{2*x}
+ {$3x$}{3*x}
+ {$4x$}{4*x}
+\end{center}
+
+Lệnh \verbinline|\tcresetcoltype| cho phép trở lại với các kiểu cột như mặc định.
+
+\subsubsection{Độ rộng của cột}
+Thay vì sử dụng tham số cột "c" như trước đây, chúng ta có thể điều chỉnh độ rộng của tất cả các cột (trừ cột đầu tiên) bằng cách sử dụng tham số "m" của gói \href{http://www.ctan.org/tex-archive/graphics/pgf/base/latex/pgf/basiclayer/}{\texttt{\textbf{array}}}. Trong ví dụ sau đây, chúng ta sẽ canh phải cột thứ nhất, các cột còn lại sẽ được canh giữa và có độ rộng \numprint[cm]{1.5} :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\usepackage{array}
+\tcsetcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{lstlisting}
+\end{minipage}
+
+\tcsetcoltype{|r|}{>{\centering\arraybackslash}m{1.5cm}|}
+\htablecalc[3]{$x$}{x=-4,-2,0,2.25,7}
+ {$f(x)=2x-3$}{2*x-3}
+ {$x^2$}{x*x}
+ {$h(x)=\sqrt{x^2+1}$}{round(root(2,x*x+1),6)}
+\end{center}
+
+\section{Nhập giá trị bằng công thức} \label{nhapbangcongthuc}
+Khi mà số lượng các giá trị của biến nhập vào khá lớn và tuân theo một quy luật toán học nào đó, thay vì nhập vào tất cả các giá trị đó, chúng ta chỉ cần nhập vào công thức của chúng. Ví dụ như cú pháp :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[2]{$x$}{x=-3,-1,1,3,5,7,9,11,13}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+có thể được thay thế bởi :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[2]{$x$}{x=a;a=-3:13[2]}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+Sự xuất hiện của dấu chấm phẩy "\verb=;=" đã thay đổi đã thay đổi cách đọc tham số chứa "danh sách" các giá trị của biến : ta thấy rằng ở phía bên phải của dấu chấm phẩy, biến trung gian "\verb=a=" được gán các giá trị nguyên từ $-3$ đến 13 với gia số bằng 2 : các giá trị là các số \emph{lẻ} liên tiếp; ở bên trái của dấu chấm phẩy, biến chính \verb=x= được gán giá trị của biến trung gian \verb=a= do đó nó cũng sẽ được gán các giá trị là các số nguyên lẻ từ $-3$ đến 13. Từ đây ta còn có nhiều cách viết khác, chẳng hạn \verb|{x=2*a+1:a=-2:6}| hoặc \verb|{x=2*a-3;a=0:8}| (gia số bằng 1 theo mặc định)\bigskip
+
+Khi sử dụng cách viết này, chúng ta không thể ẩn đi giá trị của các ô như đã gặp ở trang~\pageref{ano}.\medskip
+
+Với cú pháp này, tham số chứa các giá trị của biến được viết ở dạng sau :\par\smallskip\nobreak
+\hfill\argu{biến 1}\verb|=|\argu{công thức}\verb|;|\argu{biến 2}\verb|=|\argu{min}\verb|:|\argu{max}\arguC{gia số}\hfill{}\smallskip
+
+trong đó :
+
+\parindent2em
+\begin{itemize}
+ \item \argu{biến 1} là biến chính (chúng ta cần tính giá trị của các công thức theo biến này);
+ \item \argu{biến 2} là biến trung gian (biến được dùng để xác định các giá trị của biến chính), biến này bắt buộc phải khác \argu{biến 1}.
+ \item \argu{công thức} là công thức của \argu{biến 1} theo \argu{biến 2};
+ \item \argu{min}\verb|:|\argu{max} là đoạn (hay khoảng) mà \argu{biến 2} thay đổi (\argu{min} không nhất thiết phải nhỏ hơn \argu{max});
+ \item \argu{gia số} là gia số (của cấp số cộng theo \argu{biến 2}, số hạng đầu tiên là \argu{min} và số hạng cuối phải nhỏ hơn hoặc bằng \argu{max} nếu gia số dương và lớn hơn hoặc bằng \argu{max} nếu gia số âm); gia số này phải khác 0 (bằng \verb=1= theo mặc định).
+\end{itemize}\parindent0em
+\medskip
+
+Như chúng ta đã thấy, có nhiều cách khác nhau để nhập vào các giá trị của biến theo kiểu trên. Dưới đây là một ví dụ khác, nó sẽ nhập vào các giá trị \texttt{\{0,1,2,3,4,5,6,7,8,9,10\}} :
+
+\parindent2em
+\begin{itemize}
+ \item \verb|{z=x;x=0:10}| trong đó \verb=z= là biến chính;
+ \item \verb|{n=2*a;a=0:5[0.5]}| trong đó \verb=n= là biến chính;
+ \item \verb|{x=y/10;y=0:100[10]}| trong đó \verb=x= là biến chính;
+\end{itemize}
+\parindent0pt\medskip
+
+Chú ý : khoảng của biến trung gian và gia số cần phải tương thích với nhau : nếu \argu{min} < \argu{max} thì gia số phải là số dương còn nếu \argu{min} > \argu{max} thì gia số phải là số âm. Ví dụ như với tham số \verb|0:10[-1]|, hệ thống sẽ báo lỗi !\medskip
+
+Sau đây là một ví dụ sử dụng các hàm số lượng giác của \verb|fp|:
+
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[6]{$x$\ [deg]}{x=a;a=15:75[15]}
+ {$\sin x$}{round(sin(x*pi/180),6)}
+ {$\cos x$}{round(cos(x*pi/180),6)}
+ {$\tan x$}{round(tan(x*pi/180),6)}
+ {$\sin^2x$}{round(sin(x*pi/180)^2,6)}
+ {$\cos^2x$}{round(cos(x*pi/180)^2,6)}
+ {$\tan^2x$}{round(tan(x*pi/180)^2,6)}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc[6]{$x$\ [deg]}{x=a;a=15:75[15]}
+ {$\sin x$}{round(sin(x*pi/180),6)}
+ {$\cos x$}{round(cos(x*pi/180),6)}
+ {$\tan x$}{round(tan(x*pi/180),6)}
+ {$\sin^2x$}{round(sin(x*pi/180)^2,6)}
+ {$\cos^2x$}{round(cos(x*pi/180)^2,6)}
+ {$\tan^2x$}{round(tan(x*pi/180)^2,6)}
+\end{center}
+\medskip
+
+Còn bảng sau đây là các luỹ thừa cơ số 10 cùng logarit thập phân, căn bậc hai và nghịch đảo của chúng :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\htablecalc[3]{Lu\-ỹ th\-ừa c\-ơ s\-ố 10}{x=round(10^n,4);n=-3:3}
+ {Logarit th\-ập ph\-ân}{ln(x)/ln(10)}
+ {C\-ă b\-ậc hai}{round(root(2,x),3)}
+ {S\-ố đ\-ảo}{1/x}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc[3]{Luỹ\- thừ\-a cơ\- số\- 10}{x=round(10^n,4);n=-3:3}
+ {Logarit thậ\-p phâ\-n}{ln(x)/ln(10)}
+ {Că\-n bậ\-c hai}{round(root(2,x),3)}
+ {Số\- đả\-o}{1/x}
+\end{center}
+
+\section{Tuỳ chọn nâng cao}
+\subsection{Thi hành lệnh trong một ô}
+Macro \verbinline|\defcellcode| cho phép thi hành lệnh trong một ô, một cột hay một hàng. Các ô của một bảng được đánh số như sau :\smallskip
+
+\begin{center}
+ \def\tcprintvalue#1{}\def\tcprintresult#1#2{}
+ \edefcellcode{}{}{(\number\tclin,\number\tccol)}
+ \htablecalc[3]{}{x=1,2,3,4,5}{}{x}{}{x}{}{x}
+\end{center}
+\medskip
+
+Chỉ số đầu ---~ số thứ tự của hàng~--- là giá trị của bộ đếm \verbinline{\tclin} còn chỉ số thứ hai ---~ số thứ tự của cột~--- là giá trị của bộ đếm \verbinline{\tccol}.\smallskip
+
+Sau đây là cú pháp :
+
+\verbinline|\defcellcode|\ARGU{chỉ số 1}\ARGU{chỉ số 2}\ARGU{code}
+\smallskip
+
+trong đó :\parindent2em
+\begin{itemize}
+ \item \ARGU{chỉ số 1} là số thứ tự của hàng;
+ \item \ARGU{chỉ số 2} là số thứ tự của cột;
+ \item \ARGU{code} là mã sẽ được thực hiện khi hiển thị ô;
+ \item Nếu không nhập \ARGU{chỉ số 1} thì \ARGU{code} sẽ được thi hành đối với tất cả các hàng;
+ \item Nếu không nhập \ARGU{chỉ số 2} thì \ARGU{code} sẽ được thi hành đối với tất cả các cột;
+\end{itemize}\parindent0em
+\smallskip
+
+Cần chú rằng \ARGU{code} chỉ được thực hiện khi \emph{hiển thị ô}, và lúc này, giá trị của bộ đếm \verbinline|\tccol| không còn là số thứ tự của cột nữa, do đó chúng ta không thể sử dụng \verbinline|\tccol| để thay thế cho \ARGU{chỉ số 2} trong lệnh \verbinline|\defcellcode|. Ngược lại, giá trị của bộ đếm \verbinline|\tclin| chính là số thứ tự của hàng được hiển thị.
+
+Nếu lệnh \verbinline|\defcellcode| được thi hành nhiều lần với \ARGU{code} khác nhau trên cùng một ô nào đó, thì chúng sẽ được thi hành theo thứ tự đã viết chúng.\medskip
+
+Sau đây là một ví dụ, nội dung của ô (2~,~3) sẽ được in bằng màu xanh dương, hàng 1 sẽ được in bằng màu đỏ và cột 4 màu nâu.
+
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\usepackage{color}
+\defcellcode{2}{3}{\color{blue}}
+\defcellcode{1}{}{\color{red}}
+\defcellcode{}{4}{\color{brown}}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
+ {$2x$}{2*x}
+ {$3x$}{3*x}
+ {$4x$}{4*x}
+\end{lstlisting}
+\end{minipage}
+
+\defcellcode{2}{3}{\color{blue}}
+\defcellcode{1}{}{\color{red}}
+\defcellcode{}{4}{\color{brown}}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
+ {$2x$}{2*x}
+ {$3x$}{3*x}
+ {$4x$}{4*x}
+\end{center}
+
+Chúng ta thấy rằng số {\color{brown}\numprint{2}} của ô (1 , 4) có màu nâu. Thực ra đầu tiên nó đã được tô màu đỏ (xem dòng thứ 3 của khối lệnh trên) rồi sau đó mới được tô màu nâu (dòng 4).\bigskip
+
+Ngoài ra, chúng ta cũng có thể sử dụng \verbinline|\edefcellcode|. Lúc này, \ARGU{code} sẽ được thực hiện lần đầu tiên với \verbinline|\edef|\footnote{Có thể thêm vào \texttt{\string\noexpand} ở trước lệnh mà ta không muốn thi hành lúc này.} khi xây dựng ô, và giá trị của bộ đếm \verbinline|\tccol| chính là số thứ tự của ô đó. \ARGU{code} sẽ được thực hiện thêm một lần nữa khi hiển thị ô.\medskip
+
+Trong ví dụ sau đây, chúng ta sẽ tô màu xanh dương nội dung của tất cả các cột có số thứ tự lớn hơn 2 :
+
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\usepackage{color}
+\edefcellcode{}{}{%
+ \ifnum\tccol>2 \noexpand\color{blue}\fi}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
+ {$2x$}{2*x}
+ {$3x$}{3*x}
+ {$4x$}{4*x}
+\end{lstlisting}
+\end{minipage}
+
+\edefcellcode{}{}{%
+ \ifnum\tccol>2 \noexpand\color{blue}\fi}
+\htablecalc[3]{$x$}{x=-2,-1,0,1,2,3}
+ {$2x$}{2*x}
+ {$3x$}{3*x}
+ {$4x$}{4*x}
+\end{center}
+
+\subsection{Tuỳ chọn hiển thị}
+\subsubsection{Các macro {\ttfamily\textbackslash printvalue} và {\ttfamily\textbackslash printresult}}\label{persoaffichage}
+Để in ra một giá trị, lệnh \verbinline|\tcprintvalue| sẽ được gọi. Nó chỉ có một tham số là số chữ số thập phân cần in ra (được cho bởi \verb|fp|).
+
+Theo mặc định, \verbinline|\tcprintvalue| được định nghĩa như sau :\par\nobreak\smallskip
+\hfill\verbinline|\def\tcprintvalue#1{\numprint{#1}}|\hfill{}
+\smallskip
+
+Ta thấy rằng lệnh \verb|\numprint| được gọi để in ra đẹp hơn.\bigskip
+
+Để in ra một kết quả, lệnh \verbinline|\tcprintresult| sẽ được gọi. Lệnh này có \textbf{hai} tham số : một là kết quả cho bởi \verb|fp| và hai là giá trị của biến.
+
+Theo mặc định, \verbinline|\tcprintresult| được định nghĩa như sau :\par\nobreak\smallskip
+\hfill\verbinline|\def\tcprintresult#1#2{\numprint{#1}}|\hfill{}
+\smallskip
+
+Như vậy ta thấy rằng tham số \verb|#2| (giá trị của biến) không phụ thuộc vào \verbinline|\tcprintresult|. Tuy nhiên ta cũng có thể thay đổi điều này. Trong ví dụ sau đây, chúng ta sẽ in ra một chữ \verb|X| màu đỏ khi cạnh của hình vuông (chính là tham số \verb|#2|) là một số âm, nếu không ta sẽ in ra kết quả (diện tích hình vuông, tham số \verb|#1|) cùng với đơn vị. Hơn nữa là sẽ tô màu xanh tất cả các kết quả nhỏ hơn 10 :\par\nobreak
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\usepackage{color}
+\def\tcprintresult#1#2{%
+ \ifdim#1pt<10pt\color{blue}\fi
+ \ifdim#2pt<0pt
+ \color{red}\texttt{X}%
+ \else
+ \numprint[cm^2]{#1}%
+ \fi}
+\htablecalc{C\-ạnh c\-ủa h\-ình vu\-ông}{x=0.7,-10,3,-2,5,12}
+ {Di\-ện t\-ích}{x*x}
+\end{lstlisting}
+\end{minipage}
+
+\def\tcprintresult#1#2{%
+ \ifdim#1pt<10pt\color{blue}\fi
+ \ifdim#2pt<0pt
+ \color{red}\texttt{X}%
+ \else
+ \numprint[cm^2]{#1}%
+ \fi}
+\htablecalc{Cạnh của hình vuông}{x=0.7,-10,3,-2,5,12}{Diện tích}{x*x}
+\end{center}
+
+\subsubsection{Điều chỉnh các số làm tròn}
+Các phép tính được tính bởi \verb|fp| có độ chính xác rất cao, đến 12 chữ số thập phân. Ví dụ phép tính $\sqrt{10}$ bởi \verb=fp= sẽ cho ra kết quả :
+\begin{center}\FPeval\truc{root(2,10)}\numprint\truc\end{center}
+11 chữ số thập phân đầu tiên là chính xác, chữ số thứ 12 là làm tròn.\medskip
+
+Đối với các kết quả, chúng ta có thể sử dụng hàm \verb|round(kết quả,số chữ số thập phần)| của \verb|fp| (như đã thấy trong các ví dụ trước). Nhưng nếu muốn đơn giản hoá các câu lệnh chúng ta cũng có thể sử dụng lệnh \verbinline|\tcprintroundresult| của \tbcalc. Tham số của nó là số chữ số thập phân mà ta cần in ra. Nếu thay \verbinline|\tcprintroundresult| bởi \verbinline|\tcprintroundresult*| thì nó sẽ thêm vào (nếu cần) các kết quả chẵn (chính xác) một số chữ số 0 cho đủ số chữ số thập phân cần in ra. Nếu tham số được để trống thì \tbcalc sẽ không làm tròn kết quả.
+
+\begin{center}
+\begin{minipage}{0.5\linewidth}
+\begin{center}
+\begin{lstlisting}
+\tcprintroundresult{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{lstlisting}
+\tcprintroundresult{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{center}
+\end{minipage}%
+\begin{minipage}{0.5\linewidth}
+\begin{center}
+\begin{lstlisting}
+\tcprintroundresult*{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{lstlisting}
+\tcprintroundresult*{3}
+\htablecalc{$x$}{x=2,3,4,5}
+ {$\sqrt{x}$}{root(2,x)}
+\end{center}
+\end{minipage}
+\end{center}
+
+Lưu ý : khi nhập giá trị bằng công thức (xem trang~\pageref{nhapbangcongthuc}), \textbf{không nên} sử dụng hàm số \verb|round| (trong công thức liên hệ giữa biến chính và biến trung gian), bởi vì nó sẽ làm tròn các giá trị của biến chính và do đó các kết quả sẽ không chính xác. Ví dụ :
+\begin{center}
+\begin{minipage}{0.75\linewidth}
+\begin{lstlisting}
+\htablecalc{C\-ăn b\-ậc hai}{x=round(root(2,k),2);k=2:4}
+ {B\-ình ph\-ư\-ơng}{x*x}
+\end{lstlisting}
+\end{minipage}
+
+\htablecalc{Căn bậc hai}{x=round(root(2,k),2);k=2:4}
+ {Bình phương}{x*x}
+\end{center}
+Ta thấy rằng các kết quả đã không còn chính xác. Tốt hơn hết là nên sử dụng \verbinline|\tcprintroundvalue| và \verbinline|\tcprintroundresult| với cùng một tham số :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\tcprintroundvalue{2}
+\htablecalc{C\-ăn b\-ậc hai}{x=root(2,k);k=2:4}
+ {B\-ình ph\-ư\-ơng}{x*x}
+\end{lstlisting}
+\end{minipage}
+
+\tcprintroundvalue{2}
+\htablecalc{Căn bậc hai}{x=root(2,k);k=2:4}
+ {Bình phương}{x*x}
+\end{center}
+Các kết quả, không được làm tròn, là rất gần với các kết quả chính xác.
+
+\subsubsection{Một chút thư giãn}
+Chúng ta sẽ dùng \tbcalc để vẽ một bàn cờ vua trong đó mỗi ô có cạnh bằng \numprint[cm]{0.5} :\par\nobreak\parindent2em
+\begin{itemize}
+ \item dòng 1 cho bằng \verb|0pt| các phân cách của bảng để không ảnh hưởng đến chiều rộng \numprint[cm]{0.5} mà ta sẽ vẽ ở các dòng tiếp theo ngay dưới đây;
+ \item dòng 2 cho phép không in ra bất kì giá trị hay kết quả nào;
+ \item dòng 3 cho phép chỉ có hai đường kẻ ngang là đường trên cùng và dưới cùng của bảng, còn dòng 4 là đường bên trái và bên phải cùng của bảng;
+ \item dòng 5 thiết lập một "cây thước" cao \numprint[cm]{0.5} ở mỗi hàng của bảng;
+ \item dòng 7 kiểm tra tính chẵn lẻ của tổng số thứ tự hàng + số thứ tự cột của mỗi ô, và nếu tổng này là lẻ thì ta sẽ tô màu xám các ô này ở dòng 8.
+\end{itemize}\parindent0em
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\arraycolsep=0pt\tabcolsep=0pt
+\def\tcprintvalue#1{}\def\tcprintresult#1#2{}
+\tcsethrule{\hline}{}{}
+\tcsetcoltype[|]{|m{0.5cm}}{m{0.5cm}}
+\def\tcatbeginrow{\rule[-0.2cm]{0pt}{0.3cm}}
+\edefcellcode{}{}{%
+ \ifodd\numexpr\tccol+\tclin\relax
+ \noexpand\cellcolor{lightgray}\fi
+}
+\htablecalc[7]{}{x=1,2,3,4,5,6,7}
+ {}{x}{}{x}{}{x}{}{x}{}{x}{}{x}{}{x}
+\end{lstlisting}
+\end{minipage}
+
+\arraycolsep=0pt\tabcolsep=0pt
+\def\tcprintvalue#1{}\def\tcprintresult#1#2{}
+\tcsethrule{\hline}{}{}
+\tcsetcoltype[|]{|m{0.5cm}}{m{0.5cm}}
+\def\tcatbeginrow{\rule[-0.2cm]{0pt}{0.3cm}}
+\edefcellcode{}{}{%
+ \ifodd\numexpr\tccol+\tclin\relax
+ \noexpand\cellcolor{lightgray}\fi
+}
+\htablecalc[7]{}{x=1,2,3,4,5,6,7}
+ {}{x}{}{x}{}{x}{}{x}{}{x}{}{x}{}{x}
+\end{center}
+
+\section{Xuất một bảng ra một tập tin}
+Nếu lệnh \verbinline=\tcwritetofile=\ARGU{filename} (với một tham số bắt buộc là tên tập tin không chứa phần mở rộng) đặt trước \verbinline=\htablecalc= hoặc \verbinline=\vtablecalc= thì hai lệnh này sẽ không in ra bảng như thường lệ mà chúng sẽ tạo ra một tập tin \argu{filename}\verb|.tex| (trong cùng thư mục với tập tin tạo ra nó) chứa mã \TeX{} của bảng.\medskip
+
+Sau đây là một ví dụ :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\tcwritetofile{mytable}
+\defcellcode{}{2}{\color{blue}}
+\htablecalc[2]{$x$}{x=k;k=0:4}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\tcresetcellcode
+\end{lstlisting}
+\end{minipage}
+\end{center}
+\tcwritetofile{mytable}
+\defcellcode{}{2}{\color{blue}}
+\htablecalc[2]{$x$}{x=k;k=0:4}
+ {$2x$}{2*x}
+ {$x^2$}{x*x}
+\tcresetcellcode
+
+Một tập tin có tên \verb=mytable.tex= sẽ được tạo ra trong cùng thư mục với tập tin đang được sử dụng và nó chứa mã \TeX{} của bảng trên :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\begin {tabular}{|c|*{5}{c|}}\hline
+\tcatbeginrow $x$&\tcprintvalue {0}&\color {blue}\tcprintvalue {1}&\tcprintvalue {2}&\tcprintvalue {3}&\tcprintvalue {4}\\\hline
+\tcatbeginrow $2x$&\tcprintresult {0}{0}&\color {blue}\tcprintresult {2}{1}&\tcprintresult {4}{2}&\tcprintresult {6}{3}&\tcprintresult {8}{4}\\ \hline
+\tcatbeginrow $x^2$&\tcprintresult {0}{0}&\color {blue}\tcprintresult {1}{1}&\tcprintresult {4}{2}&\tcprintresult {9}{3}&\tcprintresult {16}{4}\\ \hline
+\end {tabular}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+Điều này giúp người sử dụng dễ dàng thay đổi các đặc điểm của bảng theo ý muốn và sau đó có thể chèn tập tin này vào tập tin của một tài liệu nào đó với lệnh :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\input{mytable.tex}
+\end{lstlisting}
+\end{minipage}
+\end{center}
+và đây là kết quả :
+\begin{center}
+\input{mytable.tex}
+\end{center}
+
+\section{Sử dụng khái niệm "trung tố" hay "hậu tố"}
+Chúng ta có thể sử dụng cả hai khái niệm "trung tố" (infix) và "hậu tố" (postfix) bởi vì \tbcalc sử dụng \verb=\FPeval= và với \verb=\FPeval= thì cả hai cách dùng này đều được chấp nhận. Trong ví dụ sau đây, để tạo ra cùng một bảng, ta sẽ sử dụng khái niệm "trung tố" sau đó là "hậu tố". Hiển nhiên kết quả nhận được là như nhau bởi vì ta sử dụng cùng một "máy tính" :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+\tcprintroundvalue{6}
+\tcprintroundresult{6}
+V\-ới kh\-ái ni\-ệm trung t\-ố\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=10^k;k=-3:3}
+ {$\log x$}{ln(x)/ln(10)}
+ {$\sqrt{x}$}{root(2,x)}
+ {$\frac{1}{x}$}{1/x}
+
+\medskip
+V\-ới kh\-ái ni\-ệm h\-ậu t\-ố\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=k 10 pow;k=-3:3}
+ {$\log x$}{x ln 10 ln div}
+ {$\sqrt{x}$}{2 x root}
+ {$\frac{1}{x}$}{1 x div}
+\end{lstlisting}
+\end{minipage}
+
+\tcprintroundvalue{6}
+\tcprintroundresult{6}
+Với khái niệm trung tố\par\par\nobreak
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=10^k;k=-3:3}
+ {$\log x$}{ln(x)/ln(10)}
+ {$\sqrt{x}$}{root(2,x)}
+ {$\frac{1}{x}$}{1/x}
+
+\medskip
+Với khái niệm hậu tố\par\par
+\htablecalc[3]{$x=10^k$ o\`u $k\in[-3;3]$}{x=k 10 pow;k=-3:3}
+ {$\log x$}{x ln 10 ln div}
+ {$\sqrt{x}$}{2 x root}
+ {$\frac{1}{x}$}{1 x div}
+\end{center}
+Nếu như bạn thông thạo cả hai cách viết thì khái niệm hậu tố có lẽ là tốt hơn vì nó sẽ giúp tính toán nhanh hơn. Chẳng hạn biểu thức $\cos x(1-\cos x)$ sẽ được viết như sau với khái niệm trung tố
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+cos(x)*(1-cos(x))
+\end{lstlisting}
+\end{minipage}
+\end{center}
+
+Như vậy sẽ phải mất hai lần tính $\cos x$.\smallskip
+
+Còn với khái niệm hậu tố thì $\cos x$ chỉ được tính một lần :
+\begin{center}
+\begin{minipage}{\mywidth}
+\begin{lstlisting}
+x cos copy 1 swap sub mul
+\end{lstlisting}
+\end{minipage}
+\end{center}
+
+
+\bigskip
+\begin{center}
+$\star$\par
+$\star$\quad$\star$
+\end{center}
+
+\bigskip
+Đó là tất cả, hi vọng rằng gói này sẽ giúp ích cho các bạn !\par\nobreak
+Mọi ý kiến đóng góp xin gửi về cho tác giả qua \href{mailto:unbonpetit@gmail.com}{\texttt{\textbf{email}}}.\par\nobreak\bigskip
+Christian \textsc{Tellechea}\\
+
+Nd : nếu bạn muốn đóng góp ý kiến cho bản dịch, xin gửi email đến địa chỉ \href{mailto:huudienkhue.le@gmail.com}{\texttt{\textbf{huudienkhue.le@gmail.com}}}. Xin cảm ơn !
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/tabularcalc/tabularcalc.sty b/Master/texmf-dist/tex/latex/tabularcalc/tabularcalc.sty
index 268d26d0049..66588b71428 100644
--- a/Master/texmf-dist/tex/latex/tabularcalc/tabularcalc.sty
+++ b/Master/texmf-dist/tex/latex/tabularcalc/tabularcalc.sty
@@ -1,19 +1,20 @@
% __________________________________________________
% | |
% | |
-% | tabularcalc v0.1 |
+% | tabularcalc v0.2 |
% | |
-% | March 19 2009 |
+% | April 21 2009 |
% | |
% |__________________________________________________|
%
% This is tabularcalc.sty
%
-% "tabularcalc" package consists of the 6 following files:
+% The "tabularcalc" package consists of the 8 following files:
% tabularcalc.sty (this file)
% README
% tabularcalc_doc_fr.tex, tabularcalc_doc_fr.pdf (manual in french)
% tabularcalc_doc_en.tex, tabularcalc_doc_en.pdf (manual in english)
+% tabularcalc_doc_vn.tex, tabularcalc_doc_vn.tex (manual in vietnamese)
%
% Christian Tellechea 2009
% email : unbonpetit@gmail.com
@@ -33,63 +34,99 @@
% The Current Maintainer of this work is Christian Tellechea
% -------------------------------------------------------------------
+\ProvidesPackage{tabularcalc}[2009/04/20 v0.2 Compute formulas in tables]
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{tabularcalc}%
- [2009/02/15 v0.1 Compute formulas in tables]
+\RequirePackage{fp}
\RequirePackage{xstring}
-\RequirePackage{numprint}
-\RequirePackage{pgf,pgfmath}
-
-\newcommand\tabularcalcversion {0.1}
-\newcommand\tabularcalcdate {2009/03/19}
-\newcommand\tabularcalcfrenchdate {19 mars 2009}
-\newcommand\tabularcalcenglishdate {March $19^{\mathrm{th}}$ 2009}
-\newcount\tccol\newcount\tclin
+\RequirePackage[autolanguage]{numprint}
+
+\newcommand\tabularcalcversion {0.2}
+\newcommand\tabularcalcdate {2009/04/21}
+\newcommand\tabularcalcfrenchdate {21 avril 2009}
+\newcommand\tabularcalcenglishdate {April $21^{\mathrm{st}}$ 2009}
+\newcount\tccol
+\newcount\tclin
\newif\iftc@showval
+\newwrite\tc@export
\newcommand\tc@checkdefine[2]{\@ifdefinable#1{\def#1{#2}}{}}
+\tc@checkdefine\tc@evalexpr{}
+
+\def\tc@evalexpr#1#2#3{% calcul d'une expression avec fp
+ \IfBeginWith{#1}-%
+ {\def\tc@currentresult{0#1}}%
+ {\def\tc@currentresult{#1}}%
+ \FPset{#2}{#3}% variable:=#2
+ \FPeval\tc@currentresult\tc@currentresult
+ \FPclip\tc@currentresult\tc@currentresult}
+
+\DeclareOption{fixFPpow}{%
+ \def\FP@pow#1#2#3{% enl\`eve l'espace ind\'esirable lors du calcul de a^b
+ \FP@beginmessage{POW}%
+ {\def\FP@beginmessage##1{}%
+ \def\FP@endmessage##1{}%
+ \FPifzero{#2}%
+ \FP@pow@zero{#3}%
+ \else
+ \FPifint{#3}% g\`ere les cas (-2)^3
+ \FPifneg{#2}%
+ \FPneg\FP@tmpd{#2}%
+ \FPln\FP@tmpd\FP@tmpd
+ \FPmul\FP@tmpd\FP@tmpd{#3}%
+ \FPexp\FP@tmpd\FP@tmpd
+ \FPtrunc\FP@tmp{#3}0%
+ \ifodd\FP@tmp
+ \FPneg\FP@tmp\FP@tmpd
+ \else
+ \let\FP@tmp\FP@tmpd
+ \fi
+ \else
+ \FPln\FP@tmpd{#2}%
+ \FPmul\FP@tmpd\FP@tmpd{#3}%
+ \FPexp\FP@tmp\FP@tmpd
+ \fi
+ \else
+ \FPln\FP@tmpd{#2}%
+ \FPmul\FP@tmpd\FP@tmpd{#3}%
+ \FPexp\FP@tmp\FP@tmpd
+ \fi
+ \fi
+ \global\let\FP@tmp\FP@tmp}%
+ \FP@endmessage{}%
+ \let#1\FP@tmp}}
+
+\ProcessOptions\relax
\newcommand\tc@addtomacro[2]{\expandafter\def\expandafter#1\expandafter{#1#2}}
\newcommand\tc@expaddtomacro[2]{%
\expandafter\tc@addtomacro\expandafter#1\expandafter{#2}}
-% choisit le moteur pour calculer l'expression contenue dans \tc@currentresult
-% puis assigne le r\'esultat dans \tc@currentresult
-\tc@checkdefine\tc@evalexpr{%
- \expandafter\pgfmathparse\expandafter{\tc@currentresult}%
- \let\tc@currentresult\pgfmathresult}
-
-\tc@checkdefine\noshowmark{}
-\makeatother\def\noshowmark{@}\makeatletter
-
-\tc@checkdefine\startline{\rule[-1.2ex]{0pt}{4ex}}
+\tc@checkdefine\tcnoshowmark{}
+\makeatother\def\tcnoshowmark{@}\makeatletter
+\tc@checkdefine\tcatbeginrow{\rule[-1.2ex]{0pt}{4ex}}
\tc@checkdefine\tc@cellcode{}
\tc@checkdefine\tc@currentcellcode{}
-\newcommand\resetcellcode{\let\tc@cellcode\@empty}
-
-\tc@checkdefine\numberletter{x}
-\tc@checkdefine\listsep{,}
+\newcommand\tcresetcellcode{\let\tc@cellcode\@empty}
+\tc@checkdefine\tclistsep{,}
+\tc@checkdefine\tcprintvalue{}
+\def\tcprintvalue#1{\numprint{#1}}
-% d\'efinit la routine d'affichage des valeurs
-\tc@checkdefine\printvalue{}
-\def\printvalue#1{\numprint{#1}}
-% d\'efinit la routine d'affichage des r\'esultats
-\tc@checkdefine\printresult{}
-\def\printresult#1#2{\numprint{#1}}
+\tc@checkdefine\tcprintresult{}
+\def\tcprintresult#1#2{\numprint{#1}}
\newcommand\edefcellcode[3]{%
\ifx\@empty#1\@empty
\ifx\@empty#2\@empty
\tc@addtomacro\tc@cellcode{#3}%
\else
- \tc@addtomacro\tc@cellcode{\ifnum\tccol=#2\relax#3\fi}%
+ \tc@addtomacro\tc@cellcode{\ifnum\tccol=#2 #3\fi}%
\fi
\else
\ifx\@empty#2\@empty
- \tc@addtomacro\tc@cellcode{\ifnum\tclin=#1\relax#3\fi}%
+ \tc@addtomacro\tc@cellcode{\ifnum\tclin=#1 #3\fi}%
\else
\tc@addtomacro\tc@cellcode{%
- \ifnum\tclin=#1\relax\ifnum\tccol=#2\relax#3\fi\fi}%
+ \ifnum\tclin=#1\relax\ifnum\tccol=#2 #3\fi\fi}%
\fi
\fi}
@@ -100,45 +137,125 @@
\tc@checkdefine\tc@updwnrule\hline
% d\'efinit les 3 types de lignes
-\newcommand\sethrule[3]{%
+\newcommand\tcsethrule[3]{%
\def\tc@updwnrule{#1}\def\tc@firstrule{#2}\def\tc@interrule{#3}}
-\newcommand\resethrule{\sethrule\hline\hline\hline}
+\newcommand\tcresethrule{\tcsethrule\hline\hline\hline}
\tc@checkdefine\tc@lastvline{}
\tc@checkdefine\tc@firstcoltype{|c|}
\tc@checkdefine\tc@othercoltype{c|}
% d\'efinit les 3 types de colonnes
-\newcommand\setcoltype[3][]{%
+\newcommand\tcsetcoltype[3][]{%
\def\tc@firstcoltype{#2}\def\tc@othercoltype{#3}\def\tc@lastvline{#1}}
-\newcommand\resetcoltype{\setcoltype{|c|}{c|}}
+\newcommand\tcresetcoltype{\tcsetcoltype{|c|}{c|}}
-\newcommand\htablecalc{\def\tc@orientation{h}\tc@deftablestart}
-\newcommand\vtablecalc{\def\tc@orientation{v}\tc@deftablestart}
+\newcommand\tc@errmess[1]{\PackageError{tabularcalc}{#1}{}}
+\newcommand\tc@ifemptyerrmess[2]{\ifx\empty#1\tc@errmess{#2}\fi}
-\newcommand\tc@deftablestart[3][1]{%
+\newcommand\htablecalc{%
\begingroup
- \expandarg
+ \@makeother\:\@makeother\;\@makeother\,
+ \fullexpandarg
+ \def\tc@orientation{h}%
+ \tc@deftableid}
+
+\newcommand\vtablecalc{%
+ \begingroup
+ \@makeother\:\@makeother\;\@makeother\,
+ \fullexpandarg
+ \def\tc@orientation{v}%
+ \tc@deftableid}
+
+\newcommand\tc@deftableid[3][1]{%
\def\tc@nbformulas{#1}%
- \StrCount{\listsep#3}\listsep[\tc@nbval]% \tc@nbval = nombre de valeurs
+ \IfSubStr{#3};%
+ {\tc@analysevalueformula{#3}}% construit la liste des valeurs
+ {\StrBefore{#3}=[\tc@formulavariable]% analyse les valeurs
+ \tc@ifemptyerrmess\tc@formulavariable{Empty variable!}
+ \StrLen\tc@formulavariable[\tc@temp]%
+ \ifnum\tc@temp=\@ne\else\tc@errmess{Invalid variable}\fi
+ \StrBehind{#3}=[\tc@valuelist]%
+ \tc@ifemptyerrmess\tc@valuelist{No value!}}%
+ \StrCount{\tclistsep\tc@valuelist}\tclistsep[\tc@nbval]% nombre de valeurs
\let\tc@coltype\@empty
\tc@expaddtomacro\tc@coltype{\tc@firstcoltype*}% construit \tc@coltype
+ \if\tc@orientation h\let\tc@temp\tc@nbval\fi
+ \if\tc@orientation v\let\tc@temp\tc@nbformulas\fi
\expandafter\tc@addtomacro\expandafter\tc@coltype\expandafter
- {\expandafter{\tc@nbval}}% qui contiendra par exemple |c|*{4}{c|}
+ {\expandafter{\tc@temp}}% qui contiendra par exemple |c|*{4}{c|}
\expandafter\tc@addtomacro\expandafter\tc@coltype\expandafter
{\expandafter{\tc@othercoltype}}%
\tc@expaddtomacro\tc@coltype\tc@lastvline
- \let\tc@firstline\tc@updwnrule% 1ere ligne
+ \let\tc@firstrow\@empty% 1ere ligne
\tclin\z@\tccol\z@
\edef\tc@currentcellcode{\tc@cellcode}%
- \tc@expaddtomacro\tc@firstline\tc@currentcellcode
- \tc@expaddtomacro\tc@firstline{\startline#2&}%
- \def\tc@valuelist{#3}%
- \tc@expaddtomacro\tc@valuelist\listsep
+ \tc@expaddtomacro\tc@firstrow\tc@currentcellcode
+ \tc@addtomacro\tc@firstrow{\tcatbeginrow#2&}%
+ \tc@expaddtomacro\tc@valuelist\tclistsep
\tclin\@ne\tccol\@ne
- \csname tc@\tc@orientation readarg\endcsname}
+ \@nameuse{tc@\tc@orientation readarg}}
+
+\newcommand\tc@analysevalueformula[1]{%
+ \StrBefore{#1};[\tc@valueformula]%
+ \StrBehind{#1};[\tc@valueinterval]%
+ \StrBefore\tc@valueinterval=[\tc@variablevalue]%
+ \StrBehind\tc@valueinterval=[\tc@valueinterval]%
+ \StrLen\tc@variablevalue[\tc@temp]% controles
+ \ifnum\tc@temp=\@ne\else\tc@errmess{Invalid variable}\fi
+ \tc@ifemptyerrmess\tc@valueinterval{Invalid syntax}%
+ \StrBefore\tc@valueformula=[\tc@formulavariable]%
+ \StrLen\tc@formulavariable[\tc@temp]% contrôles
+ \ifnum\tc@temp=\@ne\else\tc@errmess{Invalid variable}\fi
+ \ifx\tc@variablevalue\tc@formulavariable
+ \tc@errmess{Variables must not be the same}%
+ \fi
+ \StrBehind\tc@valueformula=[\tc@valueformula]%
+ \tc@ifemptyerrmess\tc@valueformula{Empty formula}%
+ \StrBefore\tc@valueinterval:[\tc@startvalue]%
+ \tc@ifemptyerrmess\tc@startvalue{Invalid interval}%
+ \StrBehind\tc@valueinterval:[\tc@valueinterval]%
+ \StrBefore{\tc@valueinterval[}[[\tc@endvalue]%
+ \tc@ifemptyerrmess\tc@endvalue{Invalid interval}%
+ \StrBetween\tc@valueinterval[][\tc@valuestep]%
+ \ifx\@empty\tc@valuestep\def\tc@valuestep{1}\fi
+ \def\tc@temp{0}%
+ \ifx\tc@valuestep\tc@temp\tc@errmess{Step must not be 0}\fi
+ \ifdim\tc@startvalue pt<\tc@endvalue pt\ifdim\tc@valuestep pt<0pt%
+ \tc@errmess{Step should be positive}%
+ \fi\fi
+ \ifdim\tc@startvalue pt>\tc@endvalue pt\ifdim\tc@valuestep pt>0pt%
+ \tc@errmess{Step should be negative}%
+ \fi\fi
+ \let\tc@valuelist\@empty
+ \let\tc@currentvalue\tc@startvalue
+ \edef\tc@comparesign{\ifdim\tc@valuestep pt<0pt<\else>\fi}% < ou >
+ \tc@buildvaluelist}
+
+\newcommand\tc@buildvaluelist{%
+ \edef\tc@temp{%
+ \noexpand\tc@evalexpr
+ {\tc@valueformula}{\tc@variablevalue}{\tc@currentvalue}}%
+ \tc@temp
+ \tc@expaddtomacro\tc@valuelist\tc@currentresult
+ \FPadd\tc@currentvalue\tc@currentvalue\tc@valuestep
+ \FPclip\tc@currentresult\tc@currentresult
+ \expandafter\ifdim\expandafter\tc@currentvalue
+ \expandafter p\expandafter t\tc@comparesign\tc@endvalue pt
+ \else
+ \tc@expaddtomacro\tc@valuelist\tclistsep
+ \expandafter\tc@buildvaluelist
+ \fi
+ \tc@temp}
+
+\newcommand\tc@generatevaluelist[3][1]{%
+ \tc@analysevalueformula{#3}%
+ \edef\tc@temp{%
+ \unexpanded{\tc@deftableid[#1]{#2}}%
+ {\tc@formulavariable=\tc@valuelist}}%
+ \tc@temp}
% lit tous les arguments {nom ligne}{formule} et les assigne dans les sc
% \tcline@i et \tc@formula@i et ainsi de suite, puis va \`a \tc@hbuildlines
@@ -147,7 +264,7 @@
\@namedef{tc@line@\romannumeral\tclin}{}%
\edef\tc@currentcellcode{\tc@cellcode}%
\tc@expaddtocurrentline\tc@currentcellcode
- \tc@expaddtocurrentline{\startline#1&}%
+ \tc@addtocurrentline{\tcatbeginrow#1&}%
\@namedef{tc@formula@\romannumeral\tclin}{#2}%
\ifnum\tclin<\tc@nbformulas
\advance\tclin\@ne
@@ -160,19 +277,19 @@
\newcommand\tc@vreadarg[2]{%
\tclin\z@
\edef\tc@currentcellcode{\tc@cellcode}% construit la 1\`ere ligne
- \tc@expaddtomacro\tc@firstline{\tc@currentcellcode#1}%
+ \tc@expaddtomacro\tc@firstrow{\tc@currentcellcode#1}%
\@namedef{tc@formula@\romannumeral\tccol}{#2}%
\ifnum\tccol<\tc@nbformulas
- \tc@addtomacro\tc@firstline&%
+ \tc@addtomacro\tc@firstrow&%
\advance\tccol\@ne
\expandafter\tc@vreadarg
\else
\tclin\@ne\tccol\z@
- \loop% initialise les lignes \`a "\tc@currentcellcode\startline"
+ \loop% initialise les lignes \`a "\tc@currentcellcode\tcatbeginrow"
\@namedef{tc@line@\romannumeral\tclin}{}%
\edef\tc@currentcellcode{\tc@cellcode}%
\tc@expaddtocurrentline\tc@currentcellcode
- \tc@expaddtocurrentline\startline
+ \tc@addtocurrentline\tcatbeginrow
\ifnum\tclin<\tc@nbval
\advance\tclin\@ne
\repeat
@@ -181,8 +298,8 @@
\fi}%
\newcommand\tc@findskiplist{%
- \IfBeginWith\tc@currentvalue\noshowmark
- {\tc@showvalfalse% si le signe \noshowmark est pr\'esent...
+ \IfBeginWith\tc@currentvalue\tcnoshowmark
+ {\tc@showvalfalse% si le signe \tcnoshowmark est pr\'esent...
\StrGobbleLeft\tc@currentvalue1[\tc@currentvalue]}% ...efface-le
{\tc@showvaltrue}%
\IfSubStr\tc@currentvalue[% s'il y a une skiplist...
@@ -202,17 +319,19 @@
% le nombre de colonnes
\newcommand\tc@hbuildlines{%
\tclin\z@
- \StrBefore\tc@valuelist\listsep[\tc@currentvalue]% prend \tc@currentvalue
- \StrBehind\tc@valuelist\listsep[\tc@valuelist]% purge \tc@valuelist
+ \StrBefore\tc@valuelist\tclistsep[\tc@currentvalue]% prend \tc@currentvalue
+ \StrBehind\tc@valuelist\tclistsep[\tc@valuelist]% purge \tc@valuelist
\ifx\@empty\tc@currentvalue
\else
\tc@findskiplist
\edef\tc@currentcellcode{\tc@cellcode}%
- \tc@expaddtomacro\tc@firstline\tc@currentcellcode
+ \tc@expaddtomacro\tc@firstrow\tc@currentcellcode
\iftc@showval% pas de noshowmark : ajoute affichage valeur courante
- \expandafter\tc@expaddtomacro\expandafter\tc@firstline
- \expandafter{\expandafter\printvalue\expandafter
- {\tc@currentvalue}}%
+ \let\tc@currentvaluerounded\tc@currentvalue
+ \tc@tcroundvalue\tc@currentvaluerounded\tc@printvalueroundprecision
+ \expandafter\tc@addtomacro\expandafter\tc@firstrow
+ \expandafter{\expandafter\tcprintvalue\expandafter
+ {\tc@currentvaluerounded}}%
\fi
\tclin\@ne
\loop
@@ -224,7 +343,7 @@
\repeat% recommence pour toutes les lignes
\fi
\ifnum\tccol<\tc@nbval% s'il reste des colonnes
- \tc@addtomacro\tc@firstline&% ajoute "&" \`a la 1\`ere ligne
+ \tc@addtomacro\tc@firstrow&% ajoute "&" \`a la 1\`ere ligne
\tclin\@ne
\loop% et ajoute "&" aux autres lignes
\tc@addtocurrentline&%
@@ -232,22 +351,28 @@
\advance\tclin\@ne
\repeat
\advance\tccol\@ne
- \expandafter\tc@hbuildlines% recommence tout le processus
+ \let\tc@temp\tc@hbuildlines% recommence tout le processus
\else
\let\tc@nblines\tc@nbformulas
- \expandafter\tc@printtabular% sinon, va afficher la table
- \fi}
+ \ifx\tc@filename\@empty
+ \let\tc@temp\tc@printtabular% sinon, va afficher la table
+ \else
+ \let\tc@temp\tc@exporttabular% ou l'exporter dans un fichier
+ \fi
+ \fi
+ \tc@temp}
% construit les lignes du tableau par r\'ecursivit\'e principale sur \tclin
\newcommand\tc@vbuildlines{%
- \StrBefore\tc@valuelist\listsep[\tc@currentvalue]% prend \tc@currentvalue
- \StrBehind\tc@valuelist\listsep[\tc@valuelist]% purge \tc@valuelist
+ \StrBefore\tc@valuelist\tclistsep[\tc@currentvalue]% prend \tc@currentvalue
+ \StrBehind\tc@valuelist\tclistsep[\tc@valuelist]% purge \tc@valuelist
\ifx\@empty\tc@currentvalue
\else
\tc@findskiplist
\iftc@showval% pas de noshowmark : ajoute affichage valeur courante
+ \tc@tcroundvalue\tc@currentvalue\tc@printvalueroundprecision
\expandafter\tc@expaddtocurrentline\expandafter
- {\expandafter\printvalue\expandafter{\tc@currentvalue}}%
+ {\expandafter\tcprintvalue\expandafter{\tc@currentvalue}}%
\fi
\tccol\@ne
\loop
@@ -261,16 +386,21 @@
\fi
\ifnum\tclin<\tc@nbval
\advance\tclin\@ne
- \expandafter\tc@vbuildlines% s'il reste des lignes, recommence
+ \let\tc@temp\tc@vbuildlines% s'il reste des lignes, recommence
\else
\let\tc@nblines\tc@nbval
- \expandafter\tc@printtabular% sinon, va afficher la table
- \fi}
+ \ifx\tc@filename\@empty
+ \let\tc@temp\tc@printtabular% sinon, va afficher la table
+ \else
+ \let\tc@temp\tc@exporttabular% ou l'exporter dans un fichier
+ \fi
+ \fi
+ \tc@temp}
\newcommand\tc@displaycurrentresult[1]{%
\StrBetween\tc@skiplist[][\tc@nexttoskip]%
\ifx\@empty\tc@skiplist% pas de skiplist -> ajoute l'affichage de resultat
- \tc@addcurrentresult#1
+ \tc@addcurrentresult#1%
\else
\ifnum\tc@nexttoskip=\z@% si 0, n'affiche rien
\else
@@ -283,16 +413,18 @@
\fi}
\newcommand\tc@addcurrentresult[1]{% #1 : compteur courant
- \expandafter\StrSubstitute% remplace "x" par la valeur courante
- \csname tc@formula@\romannumeral#1\endcsname
- \numberletter\tc@currentvalue[\tc@currentresult]%
- \tc@evalexpr% \'evalue l'expression
- \edef\tc@currentresult{{\tc@currentresult}{\tc@currentvalue}}%
- \expandafter\tc@expaddtocurrentline\expandafter
- {\expandafter\printresult\tc@currentresult}}
+ \edef\tc@temp{%
+ \noexpand\tc@evalexpr{\@nameuse{tc@formula@\romannumeral#1}}%
+ {\tc@formulavariable}{\tc@currentvalue}}%
+ \tc@temp
+ \tc@tcroundresult\tc@currentresult\tc@printresultroundprecision
+ \edef\tc@temp{%
+ \noexpand\tc@addtocurrentline{\noexpand\tcprintresult
+ {\tc@currentresult}{\tc@currentvalue}}}%
+ \tc@temp}
\newcommand\tc@printcalclines{%
- \csname tc@line@\romannumeral\tclin\endcsname% affiche la ni\`eme ligne
+ \@nameuse{tc@line@\romannumeral\tclin}% affiche la ni\`eme ligne
\ifnum\tclin<\tc@nblines% et s'il en reste encore \`a afficher
\\\tc@interrule% va \`a la ligne, met le filet
\global\advance\tclin\@ne
@@ -302,15 +434,87 @@
\newcommand\tc@printtabular{%
\global\tclin\z@
\def\tc@currentvalue{\begin{tabular}}%
- \expandafter\tc@currentvalue\expandafter{\tc@coltype}%
- \tc@firstline\\\tc@firstrule% 1\`ere ligne + 1er filet
+ \expandafter\tc@currentvalue\expandafter{\tc@coltype}\tc@updwnrule
+ \tc@firstrow\\\tc@firstrule% 1\`ere ligne + 1er filet
\global\tclin\@ne
\tc@printcalclines% affichage des autres lignes
\\\tc@updwnrule% filet du bas
\end{tabular}% fin du tableau
\endgroup}
+
+% les macro d'export dans un fichier
+\tc@checkdefine\tc@filename{}
+\newcommand\tcwritetofile[1]{\gdef\tc@filename{#1}}
+
+\newcommand\tc@exporttabular{%
+ \immediate\openout\tc@export=\tc@filename
+ \immediate\write\tc@export{%
+ \noexpand\begin{tabular}{\unexpanded\expandafter{\tc@coltype}}%
+ \unexpanded\expandafter{\tc@updwnrule}}%
+ \immediate\write\tc@export{%
+ \unexpanded\expandafter{\tc@firstrow\\}%
+ \unexpanded\expandafter{\tc@firstrule}}%
+ \global\tclin\@ne
+ \tc@exportcalclines
+ \immediate\write\tc@export{\noexpand\end{tabular}}%
+ \immediate\closeout\tc@export
+ \endgroup
+ \gdef\tc@filename{}}
+
+\newcommand\tc@exportcalclines{%
+ \ifnum\tclin<\tc@nblines
+ \let\tc@temp\tc@interrule
+ \else
+ \let\tc@temp\tc@updwnrule
+ \fi
+ \immediate\write\tc@export{%
+ \unexpanded\expandafter\expandafter\expandafter
+ {\csname tc@line@\romannumeral\tclin\endcsname}\noexpand\\
+ \unexpanded\expandafter{\tc@temp}}% affiche la ni\`eme ligne
+ \ifnum\tclin<\tc@nblines% et s'il en reste encore \`a afficher
+ \global\advance\tclin\@ne
+ \expandafter\tc@exportcalclines% et recommence
+ \fi}
+
+%%% Les macros d'arrondi %%%%
+\newcommand\tcprintroundvalue{%
+ \@ifstar
+ {\let\tc@formatroundednumber\@gobbletwo\tc@printroundvalue}%
+ {\let\tc@formatroundednumber\FPclip\tc@printroundvalue}}
+
+\newcommand\tc@printroundvalue[1]{%
+ \ifx\@empty#1\@empty\let\tc@tcroundvalue\@gobbletwo
+ \else\let\tc@tcroundvalue\tc@round\def\tc@printvalueroundprecision{#1}%
+ \fi}
+
+\newcommand\tcprintroundresult{%
+ \@ifstar
+ {\let\tc@formatroundednumber\@gobbletwo\tc@printroundresult}%
+ {\let\tc@formatroundednumber\FPclip\tc@printroundresult}}
+
+\newcommand\tc@printroundresult[1]{%
+ \ifx\@empty#1\@empty\let\tc@tcroundresult\@gobbletwo
+ \else\let\tc@tcroundresult\tc@round\def\tc@printresultroundprecision{#1}%
+ \fi}
+
+\newcommand\tc@round[2]{% #1=sc contenant le nombre #2=rang d'arrondi
+ \FPround#1#1{#2}\tc@formatroundednumber#1#1}
+
+\tcprintroundresult{}% par d'arrondi \`a l'affichage par d\'efaut
+\tcprintroundvalue{}% par d'arrondi \`a l'affichage par d\'efaut
%
% Historique
%------------------------------------------------------------------------------
-%% v0.1 19/03/2009 : - Premi\`ere version
-%------------------------------------------------------------------------------ \ No newline at end of file
+% v0.1 19/03/2009
+% - Premi\`ere version
+%------------------------------------------------------------------------------
+% v0.2 21/04/2009
+% - pgfmath est abandonn\'e puisque beaucoup trop imprecis.
+% Le moteur de calcul est d\'esormais fp.
+% 2 probl\`emes dans \FPpow peuvent \^etre corrig\'e par l'option "fixFPpow".
+% - Les valeurs peuvent \^etre calcul\'ees au lieu d'\^etre entr\'ees une par
+% une. Cette fonctionnalit\'e tile lorsque ces valeurs suivent une loi
+% math\'ematique dans un intervalle donn\'e.
+% - Il est possible avec la commande \tcwritetofile d'exporter le prochain
+% tableau vers un fichier dont on choisit le nom
+% - Ajout de la traduction du manuel en vietnamien. \ No newline at end of file