Debian Codegraph @

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

raw
1 % This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
2 % Example 65 Creating and Displaying a Database with \\DTLaction
3 % Label: "ex:actions"
4 % arara: pdflatex
5 % arara: pdfcrop
6 \documentclass[12pt]{article}
7 \pagestyle{empty}
8 \usepackage{datatool}
9 % custom expandable command:
10 \newcommand{\limiteded}{limited edition}
11 % define a database with the name 'pricelist':
12 \DTLsetup{store-datum,default-name=pricelist}
13 \DTLaction{new}% create the default database
14 % 1st row:
15 \DTLaction[
16 assign={
17 Product = {The Adventures of Duck and Goose},
18 Quantity = {1,452}, Price = {\$1.99}
19 }
20 ]{new row}
21 % 2nd row:
22 \DTLaction[
23 assign={
24 Product = {Duck and Goose on Holiday},
25 Quantity = {94}, Price = {\$2.99}
26 }
27 ]{new row}
28 % the next value needs to be expanded:
29 \DTLaction[
30 key={Notes}, expand-value={\limiteded} ]{new entry}
31 % 3rd row:
32 \DTLaction[
33 assign={
34 Product = {The Return of Sir Quackalot},
35 Quantity = {3}, Price = {\$4.99}
36 }
37 ]{new row}
38 \begin{document}
39 % Display the data:
40 \DTLaction{display}
41 \end{document}