somebodil17 downloadsBuilds the LaTeX in a note into a PDF beside the note, with the LaTeX program on your computer or, where there is none, with a built-in pdfTeX.
An Obsidian plugin that builds the LaTeX in a note into a PDF beside the note.
A note keeps a LaTeX document in a block of code, where Obsidian shows it as it is written. The plugin hands the document to the LaTeX program of your computer, or to a pdfTeX of its own where the computer has none, and puts the PDF next to the note, or where the note says: Papers/Resume.tex.md gives Papers/Resume.pdf.
Not made by Obsidian.
---
type: private
---
```latex
\documentclass{article}
\begin{document}
Hello
\end{document}
```
latex or tex, or that holds \documentclass. A note that is nothing but the document, with no block around it, is taken whole, without its properties.Name.tex.md is a LaTeX note: the command for every note builds these. The PDF is Name.pdf, beside the note.pdf of a note puts the PDF somewhere else: a path from the root of the vault, as pdf: Resume.pdf for the top of the vault or pdf: Papers/CV.pdf. A folder that is not there is made. The path has to end in .pdf and to stay inside the vault: a build never writes over a file of another kind..tex file, is looked for in the folder of the note.% !TEX program = xelatex. The programs are pdflatex, xelatex and lualatex. Without the comment, the program of the settings is used: to begin with, pdflatex. The built-in engine stands in for pdflatex only..tex.md.A notice says what was built, with the number of pages and what built it, the installed program or the built-in engine, or what LaTeX found wrong, with the line.
A computer without LaTeX builds a document as well: with pdfTeX made into WebAssembly by the SwiftLaTeX project, which runs inside Obsidian.
The setting Engine says what builds a document:
| Engine | What builds |
|---|---|
| The installed program, or the built-in engine where there is none | To begin with. A computer that has the LaTeX program builds as it always did. |
| The installed program only | Never the built-in engine: without the program, the build fails and says so. |
| The built-in engine only | Always the built-in engine, also where a program is installed. |
What to know of the built-in engine:
pdflatex. A document that asks for xelatex or lualatex is not built by it: where that program is not installed, the build fails and says that the built-in engine is pdfTeX only.engine/ in .obsidian/plugins/latex-to-pdf/), so a second build needs no network. Measured on a tablet with Linux: the first build of a résumé of two pages fetched 16.6 MB and took 50 seconds, of which the format of LaTeX (10.4 MB) and the list of fonts (4.8 MB) are fetched once for all documents. A second build took 2 seconds, with nothing fetched.\input{part}, \includegraphics{picture.png}, the .bib file of \bibliography{refs}. A file in a folder below is not: \includegraphics{figures/picture.png} fails with the built-in engine, which never asks for a name with a folder in it. Put the file beside the note.\pdfgentounicode=1 with glyphtounicode), as a LaTeX of today does by itself.engine/, the next build fetches again. The folder tells git to pass over it.With an installed LaTeX program, the plugin uses no network.
The built-in engine asks one service for the files of TeX a document uses: texlive.texlyre.org, the files of a TeX Live that the TeXlyre project hands out by name for engines of this kind. It is not a service of this plugin, nor of Obsidian. The endpoint of SwiftLaTeX itself does not answer any more.
https://texlive.texlyre.org/pdftex/26/article.cls: classes, packages, fonts, and the format of LaTeX. Every file the document asks for that is not beside the note is asked for there, also one of your own that is missing: \input{chapter-two} with no such file beside the note asks the service for the name chapter-two.main.aux, are never asked for.127.0.0.1, at a port that is free, with a word in the address that is made for that build): the engine asks there, and the plugin answers from what is kept or asks the service. Nothing outside the computer can reach it.The files of the service are used as they come: they are not checked against anything. The engine itself is checked: see Development.
-no-shell-escape), and an error ends the run in place of waiting for an answer. The built-in engine is made that way.With obsidian-cmd-runner, a PDF is built by a script or on a build server, with the LaTeX program that is installed there or with the built-in engine:
obsidian-cmd-runner --vault notes --plugin path/to/latex-to-pdf --command latex-to-pdf:build
The run builds every note that is named .tex.md, or the notes it is given: --arg 'latex={"notes":["Papers/Resume.tex.md"]}'. It gives back each PDF with its pages and size, what built it ("engine": "installed" or "built-in") and how many bytes the built-in engine fetched for it, and fails when a document has an error or no LaTeX note is found. Named before the command of another plugin, it makes the PDF that the other then uses: as a site that holds the PDF.
A plugin that is brought with --plugin is taken out after the run, and what the built-in engine has kept goes with it: every run then fetches all files again. Install the plugin in the vault to keep them. The engine is chosen with the settings: --settings latex-to-pdf=settings.json, with {"engine": "installed"} for a build server that must not use the built-in engine.
bibtex and biber are not started, so a document with citations from a .bib file comes out without them. The built-in engine runs a BibTeX of its own after each run: with it, the citations of a .bib file beside the note are in the PDF. It has no biber.pdflatex of TeX Live, through obsidian-cmd-runner: a résumé of two pages with nine packages, built into the PDF beside its note and, with the property pdf, into one at the top of the vault, the same text as the PDF made from it elsewhere. A second build left the PDF as it was.pdflatex of the Mac puts it: up and down the same, and sideways further off in some lines, after a space; a second build, which left the PDF as it was; a build with the network cut, from what was kept; a document with an error, which fails with the error and its line; a document that asks for xelatex; a document that takes in a .tex file, pictures and a .bib file from the folder of its note; and a document that never ends, which is stopped.pdflatex installed and Obsidian 1.15.1: the installed program is still what builds, and leaves the PDF that is there as it is; set to the built-in engine, the same résumé is built in 33 seconds the first time and in under a second after.xelatex and lualatex, Windows, the installed program on Linux, a document that takes in files with the installed program, and the built-in engine on macOS and Windows.npm install
npm run check # types, lint, and the tests that need no Obsidian
npm run build # main.js, with the built-in engine inside: 833 kB
The built-in engine is two files of the SwiftLaTeX project, swiftlatexpdftex.js and swiftlatexpdftex.wasm. They are not in this repository. src/pins.ts names them as the site of SwiftLaTeX publishes them, by the commit that holds them, with the SHA-256 of each: a file that is anything else is refused, in the build and in the plugin.
A build fetches the two files into .engine/, which git passes over, checks them, and puts them into main.js. So the first build needs the network, and the plugin itself never fetches a part of itself when it runs: a plugin in the community directory of Obsidian may not.
Nothing of SwiftLaTeX is copied into this repository: the engine is run as it is published, in a worker, and told what to do with the messages its script answers to (src/builtin.ts).
The main.js of a release holds the built-in engine, unchanged: the pdfTeX of the SwiftLaTeX project (Copyright (c) SwiftLab, 2018-2022), which is under AGPL-3.0, made of pdfTeX, which is under GPL-2.0-or-later and uses code of TeX by Donald Knuth. The plugin is under the same licence as its engine.
pdftex.wasm. The two files a build takes are named in src/pins.ts, by the commit that holds them and by their SHA-256.