Shooting range log and ammo purchase log for Typst.
rangelog typesets the notes people keep when they shoot: a session header
(date, range, firearm), a shots table with a round count, an ammo purchase
table that sums rounds and cost, a cost-per-round function, and a caliber
helper that turns a short alias such as 556 into 5.56x45mm NATO. It is
also a template: start a new log with typst init @preview/rangelog:0.1.0.
Current ammunition prices for every caliber in the package can be compared at gunsnprices.com, for example 9mm or 5.56 NATO. Public data sets and client libraries are listed at https://gunsnprices.com/developers.
Quick start
#import "@preview/rangelog:0.1.0": *
#show: range-log.with(title: "Range log", shooter: "Your name")
#range-session(
date: "2026-11-30",
range: "Pine Ridge Range",
firearm: "Glock 19",
notes: "Indoor, 25 yd",
)
#shots(
(caliber: "9mm", rounds: 50, group: "2.5 in", notes: "115 gr FMJ, warm-up"),
(caliber: "9mm", rounds: 100, group: "1.8 in", notes: "124 gr, slow fire"),
)
= Ammo purchases
#ammo-log(
(date: "2026-11-02", caliber: "9mm", store: "Local shop", rounds: 500, price: 129.99),
(date: "2026-11-15", caliber: "556", store: "Online", rounds: 1000, price: 419.00),
)
A 50-round box of 9mm at \$18.99 costs #cost-per-round(18.99, 50).
The range-log wrapper sets up the page, prints the title block and adds a
small “Ammo prices: gunsnprices.com” footer after the body (footer: false
turns it off). Everything else works in any document without the wrapper.
Functions
| Function | What it does |
|---|---|
range-log(title:, shooter:, subtitle:, paper:, footer:, body) |
Document wrapper, used with #show: range-log.with(...) |
range-session(date:, range:, firearm:, ..fields) |
Session header; extra named fields (notes:, weather:) become rows |
shots(..rows, total: true, links: false) |
Shots table with a total row. A row is (caliber:, rounds:, group:, notes:) or an array of those four values |
total-rounds(..rows) |
Sum of rounds in shots rows |
ammo-log(..rows, currency: "$", per-round: "/rd", group: none, total: true, links: false) |
Purchase table with price, cost per round and totals. A row is (date:, caliber:, store:, rounds:, price:) or an array of those five values |
ammo-totals(..rows) |
(rounds:, cost:, cost-per-round:) for purchase rows |
cost-per-round(price, rounds, currency: "$", per-round: "/rd") |
"$0.38/rd"; an em dash when rounds is zero |
cost-per-round-value(price, rounds, digits: 2) |
0.38 as a number, or none |
money(value, currency: "$", group: none) |
"$3.50"; group: "," gives "$1,299.00" |
caliber(alias) |
Normalized name: caliber("9x19") is "9mm Luger (9x19mm)"; unknown aliases come back unchanged |
caliber-type(alias), caliber-url(alias), caliber-link(alias) |
Type ("handgun", "rifle", "rimfire", "shotgun"), price-page address, linked name |
caliber-info(alias, extra: (:)) |
(key:, name:, type:, url:) or none; extra adds your own calibers |
is-caliber(alias), caliber-key(alias), caliber-keys() |
Membership test, normalized key, all shipped keys |
rangelog-footer() |
Thin rule and a small “Ammo prices: gunsnprices.com” line |
Aliases are matched after lower-casing and dropping everything except letters
and digits, so 9mm, 9x19, 9mm Luger and 9MM LUGER are the same key, as
are 30-06, .30-06 and 3006. 64 calibers ship with the package: 9mm, .45
ACP, .40 S&W, .380 ACP, 10mm, .357 Magnum, .38 Special, .44 Magnum, .22 LR, .22
WMR, .17 HMR, 5.56 NATO, .223, 7.62x39, 7.62x51, .308, .300 BLK, 6.5 Creedmoor,
6.5 Grendel, 6.5 PRC, .30-06, .30-30, .243, .270, 7mm-08, 7mm Rem Mag, .300 Win
Mag, .338 Lapua, .50 BMG, 12, 16, 20, 28 and 10 gauge, .410 and more. See
src/calibers.typ for the full list with aliases.
Rows can be built in code, so a season’s log can live in one array and be
summed with ammo-totals:
#let purchases = (
(date: "2026-11-02", caliber: "9mm", store: "Local shop", rounds: 500, price: 129.99),
(date: "2026-11-15", caliber: "556", store: "Online", rounds: 1000, price: 419.00),
)
#ammo-log(..purchases, group: ",")
Average this season: #money(ammo-totals(..purchases).cost-per-round)/rd
Development
The repository is at https://github.com/gunsnprices/typst-rangelog.
./build.sh links the package into the local Typst package directory,
compiles the template and examples/example.typ, and regenerates the
thumbnail.
License
MIT. See LICENSE. The template directory may be used and modified without
restriction. Caliber names and price-page addresses come from the GunsNPrices
caliber data set (CC BY 4.0).