Debian Codegraph @

texmf-dist/doc/latex/datatool/datatool-user-examples/datatool-user-example082.tex

raw
1 % This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
2 % Example 82 Display Data in a Stripy Table
3 % Label: "ex:displaydbstripytable"
4 % arara: pdflatex
5 % arara: pdfcrop
6 \documentclass[12pt]{article}
7 \pagestyle{empty}
8 \begin{filecontents}[noheader,overwrite]{studentmarks.csv}
9 Surname,Forename,StudentNo,Assign1,Assign2,Assign3
10 "Smith, Jr",John,102689,68,57,72
11 "Brown",Jane,102647,75,84,80
12 "Brown",Jane,102646,64,92,79
13 "Brown",Andy,103569,42,52,54
14 "Adams",Zoƫ,105987,52,48,57
15 "Brady",Roger,106872,68,60,62
16 "Verdon",Clare,104356,45,50,48
17 \end{filecontents}
18
19 \usepackage{colortbl}
20 \usepackage{datatool}
21 \DTLsetup{store-datum,default-name=marks}
22 \DTLread{studentmarks.csv}
23 \ExplSyntaxOn
24 \RenewDocumentCommand \DTLdisplaydbAddItem { m m m m m m m m }
25 {
26 \int_compare:nNnT { #7 } = { \c_one_int }
27 { % first column
28 \int_if_odd:nTF { #5 }
29 { % odd row
30 \tl_put_right:Nn #1 { \rowcolor { blue } }
31 }
32 { % even row
33 \tl_put_right:Nn #1 { \rowcolor { green } }
34 }
35 }
36 \tl_put_right:Nn #1 { #3 { #2 } }
37 }
38 \ExplSyntaxOff
39 \begin{document}
40 \DTLaction{display}
41 \end{document}