I must use longtblr from tabularray package and would like to calculate simple products on each row.
Trouble is, the product displayed in the final result is the same for every row : the product from the ending row. As illustrated below, the first row should end with 4.4 and not 8.
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{functional}
\IgnoreSpacesOn
\FpNew \Total
\PrgNewFunction \Product {mmm} {
\FpSet \SubTotal {#2 * #3}
\TlSet \Row {#1 & #2 & #3 & {\FpUse \SubTotal}\\}
\FpAdd \Total {\FpUse \SubTotal}
\Return {\TlUse \Row}
}
\IgnoreSpacesOff
\begin{document}
\begin{longtblr}[evaluate=\Product]{cccc}
\Product{Text}{1.1}{4}
\Product{Text}{4}{2}
Total &&& \FpUse \Total
\end{longtblr}
\end{document}
I'm using latest tabularray and functional packages from github for these functionalities.
I'm also computing the total sum from the last column and it is working fine.
Thanks in advance for any helpful answer ! And many thanks to @L.J.R. for creating this wonderful TeX package (the most feature-packed tabular environment to my knowledge) !
Row
before each return to see what will be executed.\PrgNewFunction \SetRow {mmmm} {\TlSet \Row {#1 & #2 & #3 & #4\\}}
+\SetRow {#1} {#2} {#3} {\FpUse \SubTotal}
functional
package is to avoid using argument variants or\exp_args
. Users still need to know some about expansion, and there are several expansion functions provided infunctional
package.