From d7d41075057a0e7c03b8291416882ae09b54e9d8 Mon Sep 17 00:00:00 2001 From: finga Date: Tue, 3 Dec 2024 21:00:56 +0100 Subject: [PATCH] Start with the dictionary environment Use datatool to create database of entries and print them sorted. --- dictionary.sty | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 dictionary.sty diff --git a/dictionary.sty b/dictionary.sty new file mode 100644 index 0000000..f4ebbd2 --- /dev/null +++ b/dictionary.sty @@ -0,0 +1,21 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{dictionary}[2024/11/24 Dictionary] + +\RequirePackage{babel} +\RequirePackage{datatool} + +\newcommand{\entry}[2]{% + \DTLnewrow{dictionary}% + \DTLnewdbentry{dictionary}{word}{#1}% + \DTLnewdbentry{dictionary}{translation}{#2}% +} + +\newenvironment{dictionary}{% + \DTLifdbexists{dictionary}{\DTLcleardb{dictionary}}{\DTLnewdb{dictionary}}% +}{% + \DTLsort{word}{dictionary}% + \scriptsize% + \DTLforeach*{dictionary}{\word=word,\translation=translation}{% + \selectlanguage{vietnamese}\textbf{\word:} \selectlanguage{naustrian}\translation\\}% + \selectlanguage{vietnamese}% +}