florilegium README

README проекта с github.com/kevinraymond/florilegium. Одним файлом markdown: README.md.

florilegium

build playground release CTAN license OpenSSF Scorecard

Procedurally generated Delft-blue page margins for LaTeX, their plants, visitors, shells and Gothic tracery sampled from genomes. No images, no imported paths, no external assets: every petal, leaf, stem, whorl and arch is a curve computed while the page is being written, painted like a watercolor, and written straight into the PDF. Every page grows a garden of its own, and each document's seed its own plants.

six seeds

Six seeds of the grown margin. Same code, different seed, and the garden fills whatever space the text leaves free.

Try it in your browser · download the package and the PDFs · on CTAN · documentation

Origin

The Reddit post asked how to make flowers like these in LaTeX. I don't know how the original was made. This project is one possible way. The way I did it first, in 1.3, uses hand-authored primitives with randomized parameters, painted in Lua and placed by a procedural layout whose "fill the unused space" part borrows a 1998 idea from the ornament literature. In 2.0 the plants and animals of the grown margin are sampled from genomes of botanical traits, so what grows is procedural too, not only where it grows. It gets a similar look, but I explicitly tried to not replicate the original.

This project was made with the assistance of AI (Claude), and I'm sharing the process I used to bring it to life.

Quick start

With LuaLaTeX, put florilegium.sty and the florilegium*.lua files beside your document (or upload them to an Overleaf project set to LuaLaTeX). They are all in florilegium.zip, with the TikZ library and the manual:

\usepackage[a4paper,left=68mm,right=22mm]{geometry}   % a wide margin for the garden
\usepackage[grown,sections]{florilegium}              % flowers at the headings, too
\definecolor{ink}{HTML}{5B2A1F}                       % optional: any hue (this is sepia)
...
\florilegiuminitial[4]{T}his paragraph starts with a decorated T.
\florilegiumtextend                                   % at the very end: fill the space below

With pdfLaTeX, or in any TikZ picture, the TikZ library draws the same species in pure TikZ (it needs only its two tikzlibraryflorilegium*.code.tex files):

\usepackage{tikz}
\usetikzlibrary{florilegium}
\begin{tikzpicture}
  \pic {florilegium plants={plants={3/rose, 17/umbellifer, 29/mustard}, size=21cm, width=6cm}};
\end{tikzpicture}

Under pdfLaTeX a strip this tall needs more memory than pdfTeX has by default; run it as extra_mem_top=10000000 pdflatex doc.tex (pdfLaTeX's memory).

Using the package lists every option and command.

The documents

florilegium-grow.tex florilegium.tex
composition grown: plants grown to fit the page by a greedy space-filling loop authored: stems, leaves and flowers placed by hand, every parameter sampled
adapts to the page layout, and the free space below the text on the last page nothing (tuned for A4, 68 mm margin)
preview grown authored
PDF florilegium-grow.pdf florilegium.pdf

Both are self-describing: their body text is the write-up of how the margin is drawn. showcase.tex shows what the margin does with a document's text, and spread.tex two-sided pages.

Watch it grow

as it grows with the free space it fills
seed 6 growing seed 6 growing, with the free discs marked

Seed 6, from an empty margin to the finished page. The stems rise first, leaves open as the tips pass their nodes, and each stem ends in a flower. Then the greedy loop takes over: on the right, each dashed circle is the largest free disc it found, just before a branch grows to it. Big holes come first, small ones last. The visitors fly in along the way, each to a hole of its own, and the last frame is exactly the page this seed always gives.

How it works follows the loop step by step.

Plants from genomes

three plants on one root, twice every flower form, as its plant holds it
two strips of three species plants the flower forms of the species

Each plant in a grown margin is a species, 62 traits sampled in a fixed order from one of fifteen body plans, from the visitor its flowers are for to its flower, its cluster, its leaf and its fruit. A body plan keeps botany's rules, so a lily has its parts in threes and a pea flower is two-sided with a pod. A document gets eight species and each page grows four, so they recur through the document the way plants recur through a garden. Each species can describe itself:

A blue wheel of five lobes in a coiled cyme that uncurls, for bees; hairy, smooth-edged, oval leaves; then nutlets.

A blue pea flower along a raceme, for bees; leaves of five pairs of smooth-edged leaflets, climbing by tendrils; then pods.

The species garden describes the genome and how a page chooses its plants. Any of its traits can be fixed and the rest sampled, so a TikZ pic can grow a seven-leaflet palmate leaf or a white rose (your own genome, the traits).

Visitors

butterflies, moths, bees, a hoverfly, dragonflies, beetles, caterpillars, a snail and a bird

Visitors are sampled from genomes of their own, fifteen kinds from butterflies and hawkmoths to ladybirds, caterpillars, snails and birds. Each plant brings the visitor its flowers are for, so a bee flies in near a bee flower and a hummingbird near a red tube, while a snail climbs a stem and a caterpillar eats a leaf of its own. About three come to a page; novisitors leaves them out, and the plants grow into the room they would have taken.

The margin reads the text

the three pages of showcase.tex

showcase.tex, "A year in the margin": spring on the first page, summer, autumn on the last.

A paragraph can open with a decorated initial, the letter's outline read from a font and wound with a vine that passes over and under its strokes. Every numbered section and subsection can get a flower beside it in copper, the way headings were once picked out in red, and \florilegiumbloom puts one beside any line. With the option aging, the garden ages from buds on the first page to fruit and seed heads on the last. Using the package has the details.

Gothic tracery

a headpiece over a section, the margin's vine up its jamb windows of every period, in TikZ
a headpiece of Gothic tracery over a section heading, with a vine from the margin twining its jamb ten windows of Gothic tracery of different periods

A window of Gothic tracery is sampled from a genome of its own, the way a plant is. Its period comes first and sets the arch, how the head branches, the figures and their foils, the cusps, the orders and the hood. With the option headpieces every section gets one, a screen of lights under a flat arch. The garden sends a branch to it, and a vine twines up the jamb with the leaves of the nearest plant. The same windows are TikZ pics. An initial can open under a cusped arch, and an ornament can be a trefoil, a quatrefoil or a rose.

\usepackage[grown,headpieces]{florilegium}
\pic {florilegium tracery={seed=3, role=window, size=4cm, traits={period=curvilinear}}};

Gothic tracery describes the genome, the headpiece and how a window is drawn.

Shells

shells on the ground at the foot of the plants shells of every kind, in TikZ
an ammonite, a turret shell and a cowrie lying on the ground under the footer's vine ammonites, bivalves, whelks and cowries drawn in TikZ

A shell is sampled from a genome too: an ammonite or a nautilus, five kinds of bivalve, three sea snails or a cowrie, a coil drawn as David Raup's tube. Each document has a cabinet of four, and on one page in three a few of them lie on the ground beside the root, under the footer's vine. theme=shells fills the whole margin with them, among strands of wrack. The same shells are TikZ pics.

\usepackage[grown,noshells]{florilegium}   % or no shells on the ground
\pic {florilegium shell={seed=3, role=ammonite, size=3cm}};

Shells describes the genome, where they lie and how each kind is drawn.

In pure TikZ

The species don't need Lua. Under pdfLaTeX, \usetikzlibrary{florilegium} samples each plant, visitor, window of tracery and shell from its genome, grows it and paints it with pgfmath and TikZ alone, and each of the strips above is one \pic. It takes a minute and a half for a strip of three plants 21 cm tall, and pdfTeX needs more memory than it has by default. Under LuaLaTeX, the same pics are drawn by florilegium's Lua in under a second, within a fraction of a point of pure TikZ's drawing. Only the margin itself, laid out around a page's text, is the package's and needs LuaLaTeX.

\pic {florilegium flower={seed=7, role=hero, size=2.6cm}};
\pic {florilegium inflorescence={seed=20, role=heath, scale=1.3, season=0.3}};   % in spring
\pic {florilegium visitor={seed=3, role=butterfly, size=3cm}};

The TikZ library lists every pic and key.

Themes

seed 6 as the species garden, geometric, math and shells

Seed 6 four times: the species garden, with theme=geometric, with theme=math and with theme=shells.

The growth loop never knew what it was drawing, so a theme can redraw it. theme=geometric cuts v1.3's plant from flat, straight-edged shapes, with crystals among the flowers. theme=math grows no plant at all, but figures, families of figures and equations that cascade down the margin and across the foot of the page. theme=shells lays shells sampled from genomes among strands of wrack, the document's cabinet of four low in the corner. Themes shows all three, and how to write one.

More in the margin

one seed in six inks seed 6 at four densities and a lower intensity
Any ink. The whole palette comes from one color, computed in OKLCH so the pale end never turns gray. Less in the margin. density grows less, down to a single vine; intensity paints paler.
pages 2 and 3 of spread.tex ornaments set in the text
Both sides of the page. The garden grows in the wider margin, mirrored on a right-hand page. One ornament in the text. \florilegiumornament{leaf} sets one shape in the line.

Without TeX

SVG and the browser PostScript
the playground, a proof of the page and its colophon two prints of florilegium.ps, two different gardens
florilegium-svg.lua runs the package's own Lua under any Lua 5.3 or 5.4 and writes the page as SVG, byte for byte the drawing LuaLaTeX would make, for Typst or any page background. The playground runs it in the browser, set as a printer's proof whose colophon is the set of controls. postscript/florilegium.ps grows v1.3's garden in PostScript, one self-contained file. Ghostscript or a printer computes every petal while it reads the page; sent twice to a printer with no seed, it prints two different gardens.

SVG, Typst and the browser and the PostScript port have the details.

Ports and adaptations

Other people have taken the garden further. Each of these is its author's own project, kept in its own repository, and follows the release named beside it; questions about one belong there.

project what it does follows
groeneveld/florilegiumTypst a Typst package, the drawing code translated to Rust and run as a WebAssembly plugin, with a sumi-e plum style of its own 1.1
Baldomo/florilegium-typst a second Typst package, also a Rust port run as a WebAssembly plugin 2.0
wilsybubs/florilegium a fork that compiles with XeLaTeX as well 1.1
jfoboss/florilegium a JavaScript port that regrows the garden on an e-book's part-title pages, and a Claude skill (in Russian) that builds ePub, FB2 and MOBI books with it 1.3
amberwhitehead/florilegium a single web page, in plain JavaScript and SVG, that grows a garden around a poem you write 1.1
funkhouserw/florilegium a fork with a cat gym theme and an oak theme, and Felilegium, a web editor that grows them, a kelp forest or the flowers around text boxes you draw and exports PNG, PDF or HTML 2.0

tikz-flora by wn-mitch is a LuaLaTeX package of its own that grows watercolor flora in the margin, drawn through PGF, and names florilegium among the projects it started from.

To build on florilegium from another tool, call florilegium-svg.lua. Its command line and the options of its page function are what stays put from one release to the next, and they draw the garden LuaLaTeX draws (SVG, Typst and the browser). The other files, and the functions inside them, may be renamed or rewritten in any release, as 1.3 renamed every module; each release's notes list the files it renamed or removed. Pin a port to a release tag.

1.3 and 2.0

Nothing in either release is an image: every shape is computed from a seed. What the code decides is another matter. In 1.3 the margin is grown, but what grows in it comes from a fixed set of hand-designed kinds, shapes written by hand (a flower, a lily, a leaf, a butterfly ...) whose sizes and details are random. In 2.0 the grown margin's plants and animals are species sampled from genomes, so each document's seed grows plants of its own, and the TikZ library draws the same species on their own.

page 2 of the grown document, 1.3 and 2.0 up close at 600 dpi, 1.3 left and 2.0 right
the margin of the same page in 1.3 and in 2.0 the top flower and the middle of the column of each, at 600 dpi

The same page and seed in both releases. 2.0 paints its species with 1.3's washes, streaks and veins, so what changes is what grows: daisies, star lilies, a fern at the root, and the visitors those plants bring.

what release where things go the plants and animals drawn by
grown margin 1.3 procedural, grown into the free space hand-designed kinds Lua (LuaLaTeX)
grown margin 2.0 procedural, grown into the free space procedural species from genomes Lua (LuaLaTeX)
authored page both placed by hand hand-designed kinds Lua (LuaLaTeX)
geometric theme both procedural, grown hand-designed kinds, cut flat Lua (LuaLaTeX)
math theme both procedural, packed into the free space figures computed from their mathematics, and TeX's equations Lua and TeX (LuaLaTeX)
ornaments and initials both set in the text; an initial's vine grown round its letter hand-designed kinds Lua (LuaLaTeX)
TikZ pics (\usetikzlibrary{florilegium}) 2.0 procedural, each pic grows its own plants procedural species from genomes pure TikZ (pdfLaTeX or LuaLaTeX), or Lua (LuaLaTeX's default)
SVG without TeX, and the playground both as that release's margin as that release's margin any Lua 5.3 or 5.4, a browser
PostScript (postscript/florilegium.ps) both procedural, grown hand-designed kinds (1.3's garden) PostScript

A species page draws about 1.7 times as much as a 1.3 page, and takes a little under twice as long:

1.3 2.0
ten pages of text, no margin (LuaLaTeX) 0.4 s, 33 KB 0.4 s, 33 KB
the same ten pages with the grown margin (LuaLaTeX) 7.1 s, 6.3 MB 12.3 s, 10.5 MB
what the margin adds to a page 0.68 s, 0.63 MB 1.19 s, 1.0 MB
one TikZ strip of three plants, pdfLaTeX, pure TikZ not in 1.3 91 s, 1.3 MB (6.3 million words of TeX's memory)
the same strip, LuaLaTeX, pure TikZ (engine=tikz) not in 1.3 96 s, 1.3 MB
the same strip, LuaLaTeX, Lua engine (the default) not in 1.3 0.8 s, 0.5 MB

tools/bench.tex (seed 7, the last page short) and tools/bench-tikz.tex, timed on 2026-11-03 on an Intel Core i9-13900K with LuaHBTeX 1.17.0 (TeX Live 2023), each time the median of three runs (pure TikZ: one run). What the margin adds is the difference from the same text without one (option nomargin), per page. make bench measures every row again.

Documentation

These pages, with this README's origin, quick start and credits, are also typeset as one PDF, the manual florilegium-doc.pdf, which is in florilegium.zip too.

Build

make                        # the four PDFs and the manual (LuaLaTeX)
make zip                    # build/florilegium.zip, the package as one folder, for CTAN and the release
make RUN=tools/in-docker    # the same in a TeX Live image, after: docker build -t florilegium-tex tools
make playground             # the browser playground at http://localhost:8000/web/

Credits

License

MIT, see LICENSE, except florilegium-pgfmath.lua, which reimplements part of pgf in Lua and is distributed under the LaTeX Project Public License 1.3c, as its header says. Copyright (c) 2026 Kevin Raymond.

florilegium (kevinraymond/florilegium)

Ищем в базе…

Что это такое?Это пакет LaTeX, который рисует процедурно генерируемые цветочные поля страницы в стиле дельфтского синего. Всё вычисляется в Lua во время верстки страницы: каждый лепесток, лист и стебель — это параметрическая кривая, без изображений и внешних ресурсов.
Это пакет LaTeX, который я подключаю, или отдельное приложение?Это пакет для LuaLaTeX: florilegium.sty плюс девять .lua-файлов, которые вы помещаете в свой документ, а не отдельное приложение.
Как заставить это работать в моём документе?Компилируйте с LuaLaTeX — один проход занимает около секунды на страницу (два прохода для showcase.tex, так как его режим сезонов требует количества страниц). Если TeX не установлен, есть образ Docker, который можно собрать один раз и использовать, или можно просто вставить файлы пакета в проект Overleaf.
Нужны ли внешние изображения или шрифты?Изображения и импортированные ресурсы не нужны — всё рисуется как параметрические кривые в Lua во время компиляции. Единственная необязательная зависимость от шрифта нужна для функции буквицы: она берёт контуры из шрифта OpenType (по умолчанию Latin Modern Bold).
Подходит ли поле под любую разметку страницы?Написанный вручную florilegium.tex рассчитан на A4 с полем 68 мм и не адаптируется; только версия «grow» подстраивается под разметку страницы и под свободное место. Режим сезонов/старения тоже требует два прохода компиляции, чтобы узнать количество страниц.
Для чего нужна версия на PostScript?florilegium.ps — самостоятельный порт на PostScript, который позволяет Ghostscript или настоящему принтеру построить тот же выращенный сад без TeX вообще; управляется флагами -dSeed, -dAge и -dNoVisitors.
Что меняют геометрическая и математическая темы?theme=geometric перерисовывает то же выращенное растение плоскими многоугольниками, четырёхугольниками-«воздушными змеями» и кристаллами вместо органических кривых, а theme=math полностью заменяет сад каскадом математических фигур, формул и символов, заполняющих поле.
Может ли поле реагировать на содержимое документа?Да — опции позволяют выращивать украшенную буквицу, ставить цветок рядом с каждым заголовком раздела, распускать цветок рядом с любой выбранной строкой или состарить весь сад от весны до осени по страницам документа.
Какие бабочки, пчёлы и птицы появляются?На большинстве страниц появляются одна-две бабочки и несколько пчёл на открытых местах, а также улитка, ползущая по главному стеблю, и примерно на каждой пятой странице птица на веточке. Они берутся из собственного потока случайных чисел и отключаются опцией novisitors.
Автор
kevinraymond
Размер
81.6 MB
Звёзды
1.7K
Возраст
19 д
Коммиты · 90 дней