% This file is embedded in datatool-user.pdf version 3.4.2 2025-11-06
% Example 80 Display Two Database Rows Per Tabular Row
% Label: "ex:displaydbrepeatcols"
% arara: pdflatex
% arara: pdfcrop
\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage[locales=en]{datatool}
\DTLsetup{store-datum,default-name=scores}
% define database:
\DTLaction{new}
% add columns in desired order:
\DTLaction[key=forename,value={First Name}]{add column}
\DTLaction[key=surname,value={Surname}]{add column}
\DTLaction[key=regnum,value={Student Number}]{add column}
\DTLaction[key=gender]{add column}
\DTLaction[key=parent]{add column}
\DTLaction[key=score,value={Score (\%)}]{add column}
\DTLaction[key=award]{add column}
% 1st row:
\DTLaction[
 assign={ forename = Jane, surname = Brown,
  regnum = 102647, score = 75, award = {\$1,830},
  gender = F, parent = {Ms Brown}
 }
]{new row}
% 2nd row:
\DTLaction[
 assign={ forename = John, surname = {Smith, Jr},
  regnum = 102689, score = 68, award = {\$1,560},
  gender = M, parent = {Mr and Mrs Smith}
 }
]{new row}
% 3rd row:
\DTLaction[
 assign={ forename = Quinn, surname = Ó Coinn,
  regnum = 103294, score = 91, award = {\$3,280},
  parent = {Mr and Mrs Ó Coinn}
 }
]{new row}
% 4th row:
\DTLaction[
 assign={ forename = Evelyn, surname = O'Leary,
  regnum = 107569, score = 81.5, award = {\$2,460},
  gender = n, parent = {Prof O'Leary}
 }
]{new row}
% 5th row:
\DTLaction[
 assign={ forename = Zoë, surname = Adams,
  regnum = 105987, score = 52, award = {\$1,250},
  gender = f, parent = {Mr and Mrs Adams}
 }
]{new row}
% 6th row:
\DTLaction[
 assign={ forename = Clare, surname = Vernon,
  regnum = 104356, score = 45, award = {\$500},
  gender = Female, parent = {Mr Vernon}
 }
]{new row}
% 7th row:
\DTLaction[
 assign={ forename = Roger, surname = Brady,
  regnum = 106872, score = 58, award = {\$1,350},
  gender = m, parent = {Dr Brady and Dr Mady}
 }
]{new row}
% 8th row:
\DTLaction[
 assign={
  forename = Andy, surname = Brown, regnum = 103569,
  score = 42, award = {\$980},
  gender = male, parent = {Mr Brown and Prof Sepia}
 }
]{new row} 
\begin{document}
\DTLaction[assign={surname,forename}]{sort}
\DTLaction[
 options={
  per-row=2,
  only-keys={forename,surname,score}
 }
]{display} 
\end{document}
