I would like to use the spreadtab package in combination with datatool to make calculations within a table. The data is coming from an external file; here is an example (scores.csv):

John,"Smith, Jr",68

This is the tex file:

\documentclass[a4paper, 11pt]{scrartcl}



            @First Name & @Surname & @Score (\%) \\\hline%
                \firstname & \surname & \score \\}
        @Average & & sum(c1) \\

Unfortunately, the calculations do not work. When I try to change sum(c1) to sum(c1:c5), the compilation results in an error. When I use STdebug it shows that the resulting table has only two rows: the first containing the DTLforeach code and the second is the one used for calculating the average score. My guess is that spreadtab tries to evaluate too early and therefore stumbles over code that has not run yet. Not sure though, I'm a novice in LaTeX.

I am aware that datatool can make calculations, too, but spreadtab is more flexible and provides what I need in my use case (i.e. referencing values from other columns and rows etc.).

Any help is greatly appreciated.

  • 1
    Same issue with csvsimple. :-( Seems like spradtab misses some expand-before-evaluation macro.
    – Morty
    Commented Jun 9, 2020 at 8:53

1 Answer 1


I worked around this issue by using a script that reads the data from the external file and builds the .tex file from the data. I was not able to make datatool and spreadtab work together.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .