| Crates.io | leva |
| lib.rs | leva |
| version | 0.4.3 |
| created_at | 2025-03-18 15:01:18.96431+00 |
| updated_at | 2025-06-10 16:30:29.127336+00 |
| description | Render LaTeX documents using Tera templates |
| homepage | https://leva.techne.schloosser.com |
| repository | https://git.schloosser.net/leva/leva-rs |
| max_upload_size | |
| id | 1596660 |
| size | 183,956 |
NOTICE: this readme is a bit old, it needs to be revised ...
A Rust-based tool (CLI app) for generating and compiling LaTeX documents dynamically using TOML configuration files and Tera templates. This tool supports XeLaTeX and LuaLaTeX for PDF generation and includes features like file watching for automatic recompilation.
If you like this project and want to support it, feel free to send a small donation (Bitcoin):
bc1qtmvkgp3d9svpq8622shxvmjccmu3pz6k8yh4a
or the universal code:
PM8TJKkg86BgcFHNTe2bxjJiJk921QMyjfeQVtmAKSk644EZcmgcrqZaVLewFA61rra8sZRxXZHu18TzHzaPAPHBEH49xTyjAwx8gH5Qd2KuJK3Z5w8L
The donated funds will be used exclusively for [server costs / development / documentation]. Thank you for your support!
Leva, [abbreviation from German] LaTex Erweiterung zur Vorlage Arbeitsweise, is an attempt to extend LaTex towards even further separation of typesetting semantics from content-related semantics. Leva-rs is a command-line application which implements the first draft of LEVA in Rust.
This tool is designed to automate collaboration between a designer and author, with the presumption that the designer works on providing the LaTex preamble and a few required values to be supplied with a TOML document, while the author provides the content and supplies all the information related to the content [meta-date] via the TOML document. Even if you're not working in a collaborative setting, or within different agencies: using this tool as a writer you can focus on writing the content, which is the primary concern of an author, and as a designer focus on typesetting aspect of the via a template, which is the primary concern of a typesetter.
.tex files.To use this application, you need to have Rust installed on your system. If you don't have Rust installed, you can follow the official installation guide at https://www.rust-lang.org/tools/install.
In order to compile LaTeX documents, you need to have XeLaTeX or LuaLaTeX installed on your system. These LaTeX engines are not bundled with the application and need to be installed separately. Please make sure you have either XeLaTeX or LuaLaTeX installed and available in your system's PATH before using the press or watch commands.
To install XeLaTeX, you can refer to the official documentation at https://tug.org/xetex/.
To install LuaLaTeX, you can refer to the official documentation at http://www.luatex.org/.
Once Rust is installed, you can install the tool directly from crates.io (once published):
cargo install leva
Once Rust is installed, you can clone the repository and build the application using the following commands:
git clone <repository-url>
cd <repository-name>
cargo build --release
The built binary will be located in the target/release directory.
Note: Make sure to install the appropriate LaTeX engine based on your requirements and system compatibility.
The application provides the following commands:
bind: Generate a .tex file from a template and TOML configuration.press: Compile the generated .tex file to PDF using XeLaTeX or LuaLaTeX.watch: Watch for changes in the source files and automatically recompile the document.Create a TOML Configuration File (config.toml):
template = "./template.tex"
content = "./content.tex"
output = "./output.tex"
Generate the LaTeX File:
latex-generator bind ./config.toml
This will generate output.tex based on the provided template and content.
Compile to PDF:
latex-generator press ./config.toml --xelatex
This will compile output.tex to output.pdf using XeLaTeX.
Watch for Changes:
latex-generator watch ./config.toml ./ --xelatex
This will watch the current directory for changes and automatically recompile the document when changes are detected.
bindconfig: Path to the TOML configuration file (required).pressconfig: Path to the TOML configuration file (required).--xelatex: Use XeLaTeX for compilation.--lualatex: Use LuaLaTeX for compilation.--auxiliary: Do not clean up auxiliary files.watchconfig: Path to the TOML configuration file (required).directory: Path to the directory to watch for changes (required).--xelatex: Use XeLaTeX for compilation.--lualatex: Use LuaLaTeX for compilation.This command generates the LaTeX document by binding the template and content files together through Tera template engine; It requires a TOML configuration file with the following minimal content:
template = "./vorlage.tex" # Default value
content = "./inhalt.tex" # Default value
output = "./output.tex" # Default value
For an example for how to take advantage of Tera, please see the example directory.
To use the bind command, run the following command:
./<binary-name> bind <config-file>
Replace <binary-name> with the name of the built binary and <config-file> with the path to the TOML configuration file.
This command generates the PDF version of the output file by compiling the LaTeX document. It requires a TOML configuration file with the same content as the bind command.
To use the press command, run the following command:
./<binary-name> press <config-file> [options]
Replace <binary-name> with the name of the built binary, <config-file> with the path to the TOML configuration file, and [options] with any of the following options:
-x, --xelatex: Compile the LaTeX document using XeLaTeX-l, --lualatex: Compile the LaTeX document using LuaLaTeX-a, --auxiliary: Do not clean up the auxiliary files of the LaTeX compilerThis command watches the specified directory for changes and automatically recompiles the document when changes are detected. It requires a TOML configuration file with the same content as the bind command.
To use the watch command, run the following command:
./<binary-name> watch <config-file> <directory> [options]
Replace <binary-name> with the name of the built binary, <config-file> with the path to the TOML configuration file, <directory> with the path to the main directory to watch for changes, and [options] with any of the following options:
-x, --xelatex: Compile the LaTeX document using XeLaTeX-l, --lualatex: Compile the LaTeX document using LuaLaTeXThe TOML configuration file specifies the paths to the template, content, and output files:
template = "./template.tex" # Path to the LaTeX template file
content = "./content.tex" # Path to the content file
output = "./output.tex" # Path to the output .tex file (optional, defaults to "output.tex")
{{ config.title }}).template.tex\documentclass{article}
\usepackage[utf8]{inputenc}
\title{ {{ config.title }} }
\author{ {{ config.author }} }
\date{ {{ config.date }} }
\begin{document}
\maketitle
{% block content %}{% endblock %}
\end{document}
content.tex{% extends "./template.tex" %}
{% block content %}
\section{Introduction}
This is my first Latex Document wrapped within a template proccessed by \texttt{LEVA}.
\textbf{LEVA} is simple Rust tool which proccesses LaTex files and replaces placeholders with values from a TOML file using the \texttt{tera} template engine.
\section{Testing}
Should it work now?
{% endblock %}
config.tomltemplate = "./template.tex"
content = "./content.tex"
output = "./output.tex"
title = "My LaTeX Document"
author = "Jane Doe"
date = "2023-10-05"
latex-generator bind ./config.toml
latex-generator press ./config.toml --xelatex
This will generate output.tex and compile it to output.pdf.
Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request.
Your feedback and feature requests are highly welcomed. Especially, if you're interested in developing this project further, contact me to arrange a virtual meetup or send me a link to a streaming of your writing session.
The tools is designed to empower you to deliver your work to more authors, and encourage more writers to use LaTex syntax as their default, by reducing the effort and complexity in writing a preamble. Equally, if you're working interested in publishing your template open-source, let's get together.
This project is licensed under the AGPL-3.0-only. See the LICENSE file for details.
Copyright (C) 2025 Hossein Rezaei (pen name: Isaak Engineer)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
This application was built using the following libraries:
For any inquiries, please contact isaakengineer@schloosser.com
The author benefitted immensely from inputs by DeepSeek both in role as a brainstorming partner and common/best practice suggestions.
The time for translating algorithm to written code in Rust programming language was heavily shortened via Copilot, and DeepSeek (partially).
Happy writing in LaTeX and rendering in PDF!