Convert MkDocs documentation to LaTeX PDF.
Project description
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.register_material(bool): register Material for MkDocs specific renderers (enabled by default).
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
The plugin automatically registers TeXSmith's Material integration when register_material is true, aligning colors and fonts with the Material theme if you use it.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_texsmith-0.2.1.dev0.tar.gz.
File metadata
- Download URL: mkdocs_texsmith-0.2.1.dev0.tar.gz
- Upload date:
- Size: 91.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
034d23c6c15b953d83dac1758d60966f03ff7919ab89a7dbcc5e8696b36f4522
|
|
| MD5 |
bb4628957373fdbb06cdc71471475694
|
|
| BLAKE2b-256 |
0780631332a75777448659bbd444e62b45aa33e2057acd3612e7915f9ae21cfd
|
Provenance
The following attestation bundles were made for mkdocs_texsmith-0.2.1.dev0.tar.gz:
Publisher:
ci.yml on yves-chevallier/texsmith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_texsmith-0.2.1.dev0.tar.gz -
Subject digest:
034d23c6c15b953d83dac1758d60966f03ff7919ab89a7dbcc5e8696b36f4522 - Sigstore transparency entry: 779246061
- Sigstore integration time:
-
Permalink:
yves-chevallier/texsmith@a3aa6418d31c0d256d5abe598c32abaf344d7210 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/yves-chevallier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@a3aa6418d31c0d256d5abe598c32abaf344d7210 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mkdocs_texsmith-0.2.1.dev0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_texsmith-0.2.1.dev0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0f1f6084f2fbd3374f2ffbca2dcdd989f9aa715203bd71b8c5bddfc0e259f54
|
|
| MD5 |
c6f82aa477fa630b447ac042806bdb5a
|
|
| BLAKE2b-256 |
3a83bb166dbe3dab329543babad43d415ec56c2a9e733941f12d6a81b403c313
|
Provenance
The following attestation bundles were made for mkdocs_texsmith-0.2.1.dev0-py3-none-any.whl:
Publisher:
ci.yml on yves-chevallier/texsmith
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_texsmith-0.2.1.dev0-py3-none-any.whl -
Subject digest:
e0f1f6084f2fbd3374f2ffbca2dcdd989f9aa715203bd71b8c5bddfc0e259f54 - Sigstore transparency entry: 779246063
- Sigstore integration time:
-
Permalink:
yves-chevallier/texsmith@a3aa6418d31c0d256d5abe598c32abaf344d7210 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/yves-chevallier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@a3aa6418d31c0d256d5abe598c32abaf344d7210 -
Trigger Event:
push
-
Statement type: