CLI & watch mode
The package ships a platex binary that runs the exact same pipeline as the
library — local system TeX Live → bundled Tectonic fallback → or a remote
service. No project wiring, and no TeX installation required.
npx @nandan-varma/platex main.tex # → main.pdf, right next to the inputIf you’ve installed the package (globally or in a project), the bin is on your
PATH as platex:
platex main.texCommon tasks
Section titled “Common tasks”platex main.tex # → main.pdfplatex main.tex -o out/paper.pdf # custom output path (dirs are created)platex main.tex -w # recompile on every saveplatex main.tex --watch -o out.pdf # watch + custom outputplatex main.tex -f refs.bib -f figures/ # a file and a whole directoryplatex main.tex -s https://platex.example.complatex main.tex --api-key "$PLATEX_API_KEY"echo '\documentclass{article}\begin{document}Hi\end{document}' | platex -platex main.tex --json | jq '.errors'Watch mode live rebuilds
Section titled “Watch mode ”-w / --watch recompiles whenever the input or any attached file changes.
platex watches every file it read for the last compile — the main .tex, every
-f attachment, and every file inside an attached directory.
platex main.tex -w -f refs.bib -f figures/- platex compiles once immediately and writes the PDF.
- It prints
— watching N file(s) for changes (Ctrl-C to stop). - On any change, it recompiles and rewrites the output. The watched set is re-synced after each build, so newly referenced files start being watched too.
- Press Ctrl-C to stop. The in-flight compile is aborted cleanly — no orphaned TeX processes.
Reading from stdin
Section titled “Reading from stdin”Pass - as the input to read LaTeX source from stdin. Combine with -o to name
the output (otherwise --json output is your only result):
cat main.tex | platex - -o main.pdfplatex - --json <<'EOF'\documentclass{article}\begin{document}Hello\end{document}EOFJSON output
Section titled “JSON output”--json prints the full CompileResult as JSON
on stdout, with the PDF base64-encoded in the pdf field. It writes the PDF
file only if you also pass -o.
platex main.tex --json | jq -r '.pdf' | base64 -d > main.pdf # extract the PDFplatex main.tex --json | jq '.warnings' # inspect warningsplatex main.tex --json -o main.pdf # JSON on stdout AND write the fileAll flags
Section titled “All flags”| Flag | Description |
|---|---|
-o, --output <path> |
Output PDF path (default: input path with .pdf) |
-e, --engine <name> |
pdflatex | xelatex | lualatex | tectonic |
-p, --passes <n> |
auto | 1 | 2 | 3 (default: auto) |
-b, --bib <name> |
bibtex | biber | none (default: bibtex) |
-f, --file <path> |
Attach an extra file or directory (repeatable). Files are keyed relative to the input’s directory; directories are walked recursively and keyed relative to the directory itself |
-t, --timeout <ms> |
Overall wall-clock budget for the whole pipeline |
-s, --service-url <url> |
Compile remotely (default: PLATEX_SERVICE_URL) |
--api-key <key> |
Bearer token for the service (default: PLATEX_API_KEY) |
--retry <n> |
Extra attempts on retryable remote failures |
-w, --watch |
Recompile whenever the input or attached files change |
--json |
Print the full CompileResult as JSON on stdout (pdf base64-encoded); writes the PDF file only if -o is given |
-q, --quiet |
Only print errors |
-h, --help |
Show help |
-V, --version |
Print the version |
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 |
Success |
1 |
Compile failed — errors are printed with file:line locations |
2 |
Usage or environment error (bad flags, missing input, --watch with stdin) |
This makes platex easy to drop into CI or a Makefile:
platex paper.tex -q || exit 1