0

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}

enter image description here

Thanks.

Tobard
  • 1,189
  • Apparently, tblr does four passes over the material. – egreg Feb 08 '23 at 00:06
  • But I don't understand why the condition on \write cannot prevent multicount. – Tobard Feb 08 '23 at 06:54
  • @Tobard probably because tblr does not use the \write mechanism in the same way as longtabu. There may be other ways to test if you are in the final run though. – Marijn Feb 08 '23 at 09:04
  • Hi @egreg , @Marijn : any clue of the kind of trick I can use here? I just have been through the whole tabularray source code and it seem opaque to me... :-( – Tobard Feb 09 '23 at 17:55

0 Answers0