A small library for running LaTeX child processes in Deno.
https://doc.deno.land/https://deno.land/x/latrex@v1.1.1/mod.ts
LaTeX must be installed on your machine. You can download it here.
import { latrex } from "https://deno.land/x/latrex@v1.1.1/mod.ts";
const document = await Deno.readFile("./document.tex");
const pdf = await latrex(document);
await Deno.writeFile("./output.pdf", pdf);
import { latrex } from "https://deno.land/x/latrex@v1.1.1/mod.ts";
const document = `
\\documentclass{article}
\\begin{document}
hello world
\\end{document}
`
const pdf = await latrex(document);
await Deno.writeFile("./output.pdf", pdf);
const pdf = await latrex(document, {
command: 'xelatex',
args: ['-no-file-line-error', '-no-pdf'],
inputs: ['./styles', './fonts'],
passes: 3,
errorLogsPath: './my-tex-errors.log'
});
Option | Type | Default | Description |
---|---|---|---|
command |
string |
'pdflatex' |
The command to run for your compiling your LaTeX document (pdflatex, xetex, /user/bin/custom-tex, etc). |
args |
string[] |
['-halt-on-error'] |
Arguments passed to the command. |
passes |
number |
1 |
The number of times to run options.command . Some documents require multiple passes. Only works when doc is a string. |
inputs |
string[] |
N/A | A list of absolute paths to the directory which contains the assets necessary for the doc (such as fonts or cls files, etc). |
errorLogsPath |
string |
N/A | The path to the file where you want to save the contents of the error log to. |