MkDocs TeXSmith Plugin
mkdocs-texsmith turns any MkDocs project into a set of LaTeX sources ready for high-quality PDF production. The plugin reuses the TeXSmith rendering pipeline to transform the pages that MkDocs renders into TeX, keeping navigation structure, numbering, cross references, and assets in sync.
Highlights
- Export one or many "books" from the same MkDocs site, each with its own metadata and output folder.
- Reuse TeXSmith templates or override individual blocks to match your house style.
- Combine global
.bibfiles, per-book bibliographies, inline citations, and DOI lookups into a single bibliography. - Copy and prune assets automatically so only referenced images end up in the LaTeX project.
- Optional HTML snapshots for debugging, plus Material for MkDocs specific tweaks out of the box.
Installation
pip install mkdocs-texsmith
The package targets Python 3.12+. If you manage dependencies with uv, run:
uv add mkdocs-texsmith
Quick Start
-
Add the plugin to your
mkdocs.yml.plugins: - search - texsmith: build_dir: press # where LaTeX sources are written template: book # TeXSmith template to use bibliography: - docs/references.bib
-
Build your site as usual:
mkdocs build -
The LaTeX project for each configured book is created under
press/. Compile the resultingindex.texwith your preferred tool (latexmk,tectonic, etc.) to produce the PDF.
Configuration
All plugin options are declared under the texsmith plugin entry.
enabled(bool): turns the plugin on or off; automatically disabled duringmkdocs serve.build_dir(str): output root for generated LaTeX projects. Defaults topress.template(str): default TeXSmith template name. Falls back tobook.parser(str): HTML parser backend used by TeXSmith (lxmlby default).copy_assets(bool): copy images and other assets referenced by the book into the build directory.clean_assets(bool): remove unused files from the generatedassets/folder after rendering.save_html(bool): iftrue, store the rendered HTML alongside LaTeX snapshots underhtml/.language(str): override auto-detected language for templates and hyphenation.bibliography(list[str]): global.bibfiles applied to every book.books(list[dict]): per-book configuration (see below).template_overrides(dict[str, str]): map of template block names to override files.
Multiple books
The books list lets you export distinct artefacts from the same site. Each entry accepts BookConfig fields plus book-specific extras (template, template_overrides, bibliography):
plugins:
- texsmith:
books:
- title: "User Guide"
root: "Guide"
folder: "user-guide"
template: book
bibliography:
- docs/guide.bib
- title: "API Reference"
root: "Reference"
base_level: 2
copy_files:
docs/appendix/*.tex: backmatter/
If you do not declare any books, the plugin creates one automatically using the first navigation page as the root section.
Bibliography sources
- Global
bibliographyfiles apply to every book. - Book-level
bibliographyentries augment or override the global list. - YAML front matter can declare inline bibliography entries, including DOI links. DOIs are resolved at build time; failures are logged but do not stop the build.
- Per-book
.bibfiles are emitted with the LaTeX project, and anassets_map.ymlmanifest records the asset locations used by the renderer.
Templates and overrides
TeXSmith templates bundle LaTeX, Jinja, and formatter fragments. Set template globally or per book, then override specific fragments via template_overrides:
plugins:
- texsmith:
template: book
template_overrides:
heading: overrides/heading.j2
books:
- title: "Whitepaper"
template_overrides:
cover: overrides/custom_cover.tex.j2
Assets and HTML snapshots
copy_assets: truecopies images and other referenced files into<build_dir>/<book>/assets/.clean_assets: trueprunes unused files after rendering, keeping the LaTeX project tidy.- Enable
save_htmlto keep the intermediate HTML for each page under<build_dir>/<book>/html/, which helps when troubleshooting rendering issues.
Development
-
Clone the repository and install dependencies:
uv sync -
Run the documentation site locally:
uv run mkdocs serve
-
Use
pytestoruv run pytestto execute tests before contributing patches.
The repository maintains a Makefile shortcut (make deps) that mirrors the uv sync step.
License
The project is distributed under the MIT License. See LICENSE.md for the full text.
Metadata
Release files for mkdocs-texsmith 0.5.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mkdocs_texsmith-0.5.4.tar.gz | 91.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mkdocs_texsmith-0.5.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 108.1 kB
Release files / mkdocs_texsmith-0.5.4.tar.gz
| Download URL | mkdocs_texsmith-0.5.4.tar.gz |
|---|---|
| Size | 91.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a854a6833d998ea1438b9e05095e9c4f66ab73c08231d2c939b6cfda322132a0
|
|
BLAKE2b-256 checksum How to use checksums |
145cc4d8a0285aa72ad57ef7b130a0517ba7ee412c72fb80ac6340e56d84bf3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.
Transparency logRelease files / mkdocs_texsmith-0.5.4-py3-none-any.whl
| Download URL | mkdocs_texsmith-0.5.4-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62f9c36cd6e55f2d27f19e224900c67ace30a1a061f1416fb327475b438a481e
|
|
BLAKE2b-256 checksum How to use checksums |
471a34095b97264a5c1450ec99d82b87979acc7a7e5b02df6fb005f018319bce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.
Transparency log