0

I am using a spreadtab environment in a document to display a table with calculations. Since the commands are repeated for each row, I want to define a command via \newcommand that represents one row at a time. With this I hope that I can tidy up the code.

Unfortunately, the arguments of the command are always interpreted as the content of the text field. How can I define in \newcommand that an argument should be interpreted as a numeric field?

Below is a minimal example and an example of the basic idea of the command.

Thanks in advance,

BR Christoph

Minimal example:

\documentclass{scrlttr2}
\usepackage{spreadtab}
\usepackage{numprint}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{siunitx}
\renewcommand{\familydefault}{\sfdefault}
\nprounddigits{2}
\STsetdecimalsep{{,}}

\begin{document} \begin{spreadtab}{{tabularx}{\textwidth}{c|X|N{4}{2}|N{4}{2}}} \hline @\tiny Quantity & @\tiny Description & @\multicolumn{1}{r|}{\tiny Unit price} & @\multicolumn{1}{r}{\tiny Quantity * Unit Price} \ \hline 3 & @Product 1 & :={2.5} ,EUR &:={[-3,0][-1,0]} ,EUR \ \hline 2 & @Product 2 & :={5.5} ,EUR & :={[-3,0][-1,0]} ,EUR\ \hline 3 & @Product 3 & :={1.0} ,EUR & :={[-3,0]*[-1,0]} ,EUR\ \hline \multicolumn{3}{l}{@Total} & :={sum(d1:[0,-1])} ,EUR \ \hline \end{spreadtab} \end{document}

Basic idea for the new command:

\newcommand{\newentry}[3]{#1 & #2 & #3 \,EUR & :={[-3,0]*[-1,0]} \,EUR \\ \hline}

In this case #1 should adress the numeric field. #3 and the 4th column with the product formular should adress the numeric and text field. #2 should adress the text field only. A new entry in the table should be generated with \newentry{1}{Product 4}{25.00}.

1 Answers1

0

After posting this question, I found some question on this topic from the past. With the help of this topic, I was able to solve the problem: textual replacement within spreadtab

BR Christoph