I wonder whether I can create a table using spreadtab
, calculate the sum of some floating number to display in the last row, and save that sum to be used in another spreadtab
table earlier on in the document.
The goal is to create multiple tables of sums of money, where each row in a table is explained in a table further below (it's a budget plan). To achieve maximum ease of use, I would first create the tables further down the line of subaccounts, compute the sum of money and use that in the table further above to be included in the bigger account.
I was thinking of a structure like in the .aux file, where the saved value is read in the next compilation of the document. I'm wondering whether the use of counters support decimal values. I'm also wondering how easy it would be to create multiple of such counters, maybe at the order of magnitude 2.
I've noticed I'm an absolute TeX noob compared to many people on this forum, and I'd struggle for weeks trying to get this to work. Does anyone have a good idea/implementation for such a setup? Or maybe there's already a very simple way to do this?
Hopefully this MWE shows what I mean
\documentclass{article}
\usepackage{spreadtab}
\begin{document}
\section{Main account}
\begin{center}
\begin{spreadtab}{{tabular}{lr}}
@ Accounts & @ Subtotal \\\hline
@ Subaccount 1 & 5 \\ % <=== would be nice to use \STtag{val} here, or something else
@ Subaccount 2 & 3 \\\hline
@ Total & sum(b2:b3)
\end{spreadtab}
\end{center}
\section{Sub account 1}
\begin{center}
\begin{spreadtab}{{tabular}{lr}}
@ Items & @ Subtotal \\\hline
@ Item 1 & 2 \\
@ Item 2 & 3 \\\hline
@ Total & sum(b2:b3) tag(val)
\end{spreadtab}
\STmakegtag{val}
\end{center}
\end{document}