commit 8a6bc1c949ea34a25ecfc3709095af0590a0e96f Author: finga Date: Tue Dec 3 21:00:56 2024 +0100 Start with the dictionary environment Use datatool to create database of entries and print them sorted. diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bd647fb --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Create the `dictionary` environment where the + `\entry{word}{description}` command can be used. 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}% +}