Skip to main content
Version: 0.4.0

Country

The country module provides a standardized way to define country-specific configurations for sender and recipient addresses. This module controls formatting of city and postal code layout positions and ensures compliance with ZUGFeRD/Factur-X standards by mapping to the correct ISO 3166-1 alpha-2 country codes.


Predefined Countries

Predefined country configurations are available for most countries and can be referenced directly as properties:

Country CodePropertyDefault NameCity Format Style
ATcountry.at"Österreich"European (e.g., 1234 Wien)
BEcountry.be"België"European (e.g., 1000 Brussel)
CHcountry.ch"Schweiz"European (e.g., 8000 Zürich)
DEcountry.de"Deutschland"European (e.g., 10115 Berlin)
EScountry.es"España"European (e.g., 28001 Madrid)
FRcountry.fr"France"European (e.g., 75001 Paris)
GB / UKcountry.uk / gb"United Kingdom"UK Postcode (e.g., London \n SW1A 2AA)
ITcountry.it"Italia"European (e.g., 00187 Roma)
UScountry.us"United States"US State/Zip (e.g., New York, NY 10001)

Other EU member states are also predefined (e.g., bg, cy, cz, dk, ee, gr, hr, hu, ie, lt, lu, lv, mt, nl, pl, pt, ro, se, si, sk).

Example Usage:

#import "@preview/invoice-pro:0.4.0": invoice, country

#show: invoice.with(
sender: (
name: "My Company GmbH",
address: "Stubenring 1",
city: "1010 Wien",
country: country.at, // Customizes address format and ZUGFeRD XML
),
recipient: (
name: "US Client Inc",
address: "123 Main St",
city: "New York, NY 10001",
country: country.us,
),
// ...
)

Customizing Predefined Countries

If you need to change the displayed name of a predefined country (e.g., if writing the invoice in another language), you can customize it using Typst's .with() feature:

// Displays "Allemagne" instead of "Deutschland", but retains the "DE" ZUGFeRD country code
#let french-germany = country.de.with(name: "Allemagne")

Country Dictionary Schema

A country object is a structured dictionary with the following schema:

KeyTypeDescription
namestrThe human-readable name of the country.
codestrThe ISO 3166-1 alpha-2 code of the country (e.g., "DE", "GB").
parse-cityfunctionParses a raw address city line string to extract the name and post-code.
format-addressfunctionFormats the recipient/sender elements vertically into content block lines.
format-inlinefunctionFormats the recipient/sender elements horizontally into an inline string.