jettex.compile¶
LaTeX compilation functions.
Module Overview¶
This module provides functions to compile LaTeX documents using various engines.
Classes¶
CompileResult(success, output_file, log_file, stdout, stderr, returncode)
dataclass
¶
Result of a LaTeX compilation.
Attributes¶
success
instance-attribute
¶
Whether compilation succeeded.
output_file
instance-attribute
¶
Path to the output PDF file if successful.
log_file
instance-attribute
¶
Path to the compilation log file.
stdout
instance-attribute
¶
Standard output from the compiler.
stderr
instance-attribute
¶
Standard error from the compiler.
returncode
instance-attribute
¶
Return code from the compiler.
Functions¶
Functions¶
pdflatex(input_file, output_dir=None, interaction='nonstopmode', synctex=False, shell_escape=False, extra_args=None, quiet=False, timeout=None)
¶
Compile a LaTeX file using pdflatex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_file
|
Union[str, Path]
|
Path to .tex file |
required |
output_dir
|
Optional[Union[str, Path]]
|
Directory for output files |
None
|
interaction
|
str
|
Interaction mode |
'nonstopmode'
|
synctex
|
bool
|
Enable SyncTeX |
False
|
shell_escape
|
bool
|
Enable shell escape |
False
|
extra_args
|
Optional[List[str]]
|
Additional arguments |
None
|
quiet
|
bool
|
Suppress output |
False
|
timeout
|
Optional[int]
|
Compilation timeout in seconds |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
CompileResult |
CompileResult
|
Compilation result |
Example
result = pdflatex("document.tex") if result.success: ... print(f"PDF created: {result.output_file}")
Source code in jettex/compile.py
xelatex(input_file, output_dir=None, interaction='nonstopmode', synctex=False, shell_escape=False, extra_args=None, quiet=False, timeout=None)
¶
Compile a LaTeX file using xelatex.
XeLaTeX supports OpenType fonts and Unicode natively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_file
|
Union[str, Path]
|
Path to .tex file |
required |
output_dir
|
Optional[Union[str, Path]]
|
Directory for output files |
None
|
interaction
|
str
|
Interaction mode |
'nonstopmode'
|
synctex
|
bool
|
Enable SyncTeX |
False
|
shell_escape
|
bool
|
Enable shell escape |
False
|
extra_args
|
Optional[List[str]]
|
Additional arguments |
None
|
quiet
|
bool
|
Suppress output |
False
|
timeout
|
Optional[int]
|
Compilation timeout in seconds |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
CompileResult |
CompileResult
|
Compilation result |
Source code in jettex/compile.py
lualatex(input_file, output_dir=None, interaction='nonstopmode', synctex=False, shell_escape=False, extra_args=None, quiet=False, timeout=None)
¶
Compile a LaTeX file using lualatex.
LuaLaTeX provides Lua scripting and OpenType font support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_file
|
Union[str, Path]
|
Path to .tex file |
required |
output_dir
|
Optional[Union[str, Path]]
|
Directory for output files |
None
|
interaction
|
str
|
Interaction mode |
'nonstopmode'
|
synctex
|
bool
|
Enable SyncTeX |
False
|
shell_escape
|
bool
|
Enable shell escape |
False
|
extra_args
|
Optional[List[str]]
|
Additional arguments |
None
|
quiet
|
bool
|
Suppress output |
False
|
timeout
|
Optional[int]
|
Compilation timeout in seconds |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
CompileResult |
CompileResult
|
Compilation result |
Source code in jettex/compile.py
latexmk(input_file, output_dir=None, engine='pdflatex', interaction='nonstopmode', synctex=False, shell_escape=False, clean=False, continuous=False, extra_args=None, quiet=False, timeout=None)
¶
Compile a LaTeX file using latexmk.
latexmk automatically runs the correct number of compilations and handles bibliography/index generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_file
|
Union[str, Path]
|
Path to .tex file |
required |
output_dir
|
Optional[Union[str, Path]]
|
Directory for output files |
None
|
engine
|
str
|
Backend engine (pdflatex, xelatex, lualatex) |
'pdflatex'
|
clean
|
bool
|
Clean auxiliary files after compilation |
False
|
continuous
|
bool
|
Continuous compilation mode (watch for changes) |
False
|
extra_args
|
Optional[List[str]]
|
Additional arguments |
None
|
timeout
|
Optional[int]
|
Compilation timeout in seconds |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
CompileResult |
CompileResult
|
Compilation result |
Source code in jettex/compile.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
clean_auxiliary(input_file, output_dir=None)
¶
Clean auxiliary files from LaTeX compilation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_file
|
Union[str, Path]
|
Path to .tex file |
required |
output_dir
|
Optional[Union[str, Path]]
|
Directory containing auxiliary files |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of files removed |
Source code in jettex/compile.py
Examples¶
Basic Compilation¶
from jettex import pdflatex
result = pdflatex("document.tex")
if result.success:
print(f"Created: {result.output_file}")
else:
print(f"Failed: {result.stderr}")
With Options¶
from jettex import xelatex
result = xelatex(
"document.tex",
output_dir="./build",
synctex=True,
shell_escape=True,
quiet=True
)
Using latexmk¶
from jettex import latexmk
# latexmk handles multiple passes automatically
result = latexmk(
"thesis.tex",
engine="xelatex",
clean=True
)