2

I would like to make an array with some automatic calculations. I use the package ftlpoint.

I made a test, but it does not work:

\newcommand{\line}[2]{%
    \fpMul{\produit}{#1}{#2}% Calculation
    \produit&%print result
    \produit&print result in another cell
}

On the first cell, no problem, but in the second cell, LaTeX says the command \produit doesn't exist (undefined control sequence).

How can do this?

Ps. Of course, my example is very simplified. I would like to make other calculations as well.

3
  • 1
    You example is to simplified ;-) Please add a minimal working example. Sep 7, 2011 at 15:15
  • You should use \MyLine instead of \line as I believe that is already defined elsewhere. Sep 7, 2011 at 15:26
  • Yes, in fact, i work in french, so I use \ligne and not \line
    – Maïeul
    Sep 8, 2011 at 15:58

1 Answer 1

4

I think you need to make the definition of \produit global. Otherwise it goes out of existence when you move into another table cell.

\documentclass{article}
\usepackage{fltpoint}
\newcommand{\tline}[2]{%                                                        
    \fpMul{\temp}{#1}{#2}\global\edef\produit{\temp}% Calcul                    
    \produit&%seeing result                                                     
    \produit%seeing result on a other cell                                      
}
\begin{document}
\begin{tabular}{c|c}
\tline{2}{3}
\end{tabular}
\end{document}
5
  • Instead of \global\edef you could simply use \xdef.
    – mhp
    Sep 7, 2011 at 15:37
  • the problem is that I have one value of produit by line. So I can't have an unique value
    – Maïeul
    Sep 8, 2011 at 9:16
  • @Maieul --- That doesn't matter. \edef (or \xdef as @mhp suggests) will overwrite any old value that exists. Sep 8, 2011 at 11:00
  • @lan Thompson : thank ! I did'nt know the \edef command :)
    – Maïeul
    Sep 8, 2011 at 15:57
  • @Maieul: if this answers your question, you can select it.
    – raphink
    Sep 10, 2011 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.