I'm using datatool, and I have tried to nest the \DTLforeach function four times, to create multiple tables from various csv files. Naturally the title error comes up.

How come the \DTLforeach function is limited to a nesting depth of three only?

I could use Python or MATLAB to rearrange my data and slot it neatly into LaTeX, but is there a TeX-based workaround for this?

  • Can you post a minimal example that uses 4 nestings? That way one can play around with attempts to correct it within LaTeX.
    – Werner
    Aug 27, 2018 at 4:10

1 Answer 1


Because datatool keeps track of a number of things for each level of nesting using macros of the form \...i, \...ii, \...iii, as well as counters for each level. You'll have to add all of the macros and counters for higher levels (\...iv, \...v, ...) as well as update the condition for testing the level depth (2 locations, one associated with \DTLforeach and one for \DTLforeach* as part of \@sDTLforeach).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.