Strange results had been reported here when using the fp package inside a table using tabu package.
A solution had been proposed to manage the fact that computations are done twice by performing a test on \write parameter.
As it comes to do similar calculations with tabularray I get odd results as well, despite the test. Any idea to fix this?
Here is a minimal example based on the topic I refer to:
\documentclass[11pt]{report}
\usepackage{fp}
\usepackage{tabu,longtable}
\usepackage{tabularray}
\FPset\totalone{0}
\FPset\totaltwo{0}
\let\origwrite\write
\def\add#1{%
\relax\ifx\origwrite\write
\FPadd\0\totalone{#1}
\global\let\totalone\0
\FPadd\0\totaltwo{#1}
\global\let\totaltwo\0
\fi
#1
}
\def\ptotalone{%
\totalone
\FPset\0{0}\global\let\totalone\0
}
\def\ptotaltwo{%
\totaltwo
\FPset\0{0}\global\let\totaltwo\0
}
\begin{document}
\subsection*{With longtabu:}
\begin{longtabu}{c}
\add{0.25} \
\add{0.5} \
\add{1} \
total one: \ptotalone
\end{longtabu}
total two: \ptotaltwo
\subsection*{With tabularray:}
\begin{tblr}{c}
\add{0.25} \
\add{0.5} \
\add{1} \
total one: \ptotalone
\end{tblr}
total two: \ptotaltwo
\end{document}
Thanks.

tblrdoes four passes over the material. – egreg Feb 08 '23 at 00:06\writecannot prevent multicount. – Tobard Feb 08 '23 at 06:54tblrdoes not use the\writemechanism in the same way aslongtabu. There may be other ways to test if you are in the final run though. – Marijn Feb 08 '23 at 09:04tabularraysource code and it seem opaque to me... :-( – Tobard Feb 09 '23 at 17:55