A tool for building LaTeX documents with Git integration and diff generation
Project description
LaTeX Builder
A Python tool for building LaTeX documents with Git version management and automatic diff generation.
Features
- Git Integration: Automatic detection of current commit, branch, and tag information
- LaTeX Compilation: Complete compilation workflow using XeLaTeX and BibTeX
- Diff Generation: Create visual differences between Git versions using latexdiff
- Version Management: Generate version information files for LaTeX documents
- Clear Logging: Beautiful command-line interface with clear progress indicators
- GoReleaser-like Versioning: Smart version naming based on Git tags and working tree status
Version Naming Logic
The tool uses GoReleaser-like version naming:
- Tag commits:
{tag}-{commit}(e.g.,v1.2.3-a1b2c3d) - Non-tag commits:
{next_version}-snapshot-{commit}(e.g.,v1.2.4-snapshot-a1b2c3d) - Dirty working tree:
{version}-dirty-{commit}(e.g.,v1.2.4-dirty-a1b2c3d)
Where {next_version} is the patch-bumped version of the latest semantic version tag.
Usage
Command Line
# Basic usage (in Git repository containing main.tex)
pipx run latex-builder
# Specify LaTeX file
pipx run latex-builder -t document.tex
# Specify output directory
pipx run latex-builder -o build_output
# Enable verbose output
pipx run latex-builder -v
# Full options
pipx run latex-builder -t main.tex -r misc/revision.tex -o output -b build -v
Generate Only revision.tex
# Generate revision.tex only (no build or diff)
pipx run latex-builder revision
# Specify output path for revision.tex
pipx run latex-builder revision --revision-file misc/revision.tex
Python API
from latex_builder import Config, LatexDiffTool
from pathlib import Path
# Create configuration
config = Config(
tex_file="main.tex",
revision_path="misc/revision.tex",
output_folder=Path("output"),
build_dir=Path("build"),
verbose=True
)
# Run tool
tool = LatexDiffTool(config)
exit_code = tool.run()
Package Structure
latex_builder/
├── cli/ # Command line interface
│ ├── main.py # Main application class
│ └── parser.py # Command line argument parsing
├── config/ # Configuration management
│ └── settings.py # Configuration data classes
├── diff/ # Diff generation
│ └── generator.py # LaTeX diff operations
├── git/ # Git operations
│ ├── repository.py # Git repository handling
│ └── revision.py # Git version data structures
├── latex/ # LaTeX processing
│ └── processor.py # LaTeX compilation
└── utils/ # Shared utilities
├── command.py # Command execution
└── logging.py # Logging setup
Configuration Options
tex_file: Main LaTeX file to compile (default: "main.tex")revision_path: Path to revision.tex file (default: "variables/revision.tex")verbose: Enable debug logging (default: False)output_folder: Output files directory (default: "output")build_dir: Temporary build files directory (default: "build")
Output Files
The tool generates the following output files:
- Current Version PDF:
{version-name}.pdf - Diff Files:
- LaTeX Source:
{compare-version}-vs-{current-version}.tex - PDF Document:
{compare-version}-vs-{current-version}.pdf
- LaTeX Source:
- Metadata:
metadata.jsoncontaining version information - Version File:
revision.texcontaining version macros for LaTeX
Examples:
v1.2.3-a1b2c3d-vs-v1.2.4-snapshot-e4f5g6h.texv1.2.3-a1b2c3d-vs-v1.2.4-snapshot-e4f5g6h.pdf
Requirements
- Python 3.11+
- Git repository
- LaTeX installation including:
- XeLaTeX
- BibTeX
- latexdiff
Example
# In a Git repository containing LaTeX project
cd my-latex-project
# Install package
uv pip install -e /path/to/latex-builder
# Build current version and generate diffs
uv run latex-builder -v
This will:
- Analyze current Git state
- Generate version information files
- Compile current version PDF
- Generate diff documents with previous commit and previous tag
- Output all files to
output/directory
Architecture
The package uses a modular architecture with clear separation of concerns:
- CLI Layer: Handles command line interaction
- Core Logic: Git operations, LaTeX processing, diff generation
- Configuration: Centralized settings management
- Utilities: Shared functionality for logging and command execution
Each module can be tested independently, following Python best practices.
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 latex_builder-0.0.12.tar.gz.
File metadata
- Download URL: latex_builder-0.0.12.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a34ba467cdc14afbe4729a2d9209f70b7490db4b272c095c4d52549451fb0c1
|
|
| MD5 |
079ed7e0489a6f5a366bb22e8e15f072
|
|
| BLAKE2b-256 |
2ec96849b9a8f69c0cd8cda71dd91428816864260b5fcdfcdfbb0c454ab657a3
|
File details
Details for the file latex_builder-0.0.12-py3-none-any.whl.
File metadata
- Download URL: latex_builder-0.0.12-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03225ad067d8bad373bb87e0d356ae6494ce8f02eac97f7f2bad188d4835b785
|
|
| MD5 |
27244e963874d7263ca0ad0b1e25367e
|
|
| BLAKE2b-256 |
824f227d672f90b39992ac664b293b6b843f99bf99729ca770d1b7c7eadc4857
|