Latex Compiler

by moshe kalman weinstock
5
4
3
2
1
Score: 50/100

Description

Reviews

No reviews yet.

Stats

0
stars
133
downloads
0
forks
20
days
14
days
14
days
1
total PRs
0
open PRs
0
closed PRs
1
merged PRs
0
total issues
0
open issues
0
closed issues
77
commits

Latest Version

15 days ago

Changelog

What's new in 1.0.6

  • Added a one-time notice explaining why your first LaTeX compilation may take longer. Required packages are downloaded as needed and cached for future compilations.
  • Paused the compiler timeout during package downloads so slow downloads have time to finish.
  • Improved code block setup errors with instructions for resolving conflicts with other plugins.
  • Removed stale jobs from the render queue before they run.
  • Updated the plugin description to mention TikZ support.

README file from

Github

Obsidian LaTeX Compiler

This Obsidian plugin lets you use a full LaTeX compiler right inside Obsidian code blocks. You can write complete documents, use files and images from your vault, and export your work as a PDF or SVG. It works just like a regular LaTeX setup, but everything happens in Obsidian. All you need to do is install the plugin; no extra steps required. Despite what it can do, it’s small, uses memory carefully, and works on Android too.

The plugin includes two LaTeX engines, pdfTeX and XeTeX. It downloads TeX Live packages as needed and caches them for future use. You can reference files in your vault as you would in a regular LaTeX project, and the plugin makes them available during compilation. It then displays the result as a PDF or converts it to SVG using poppler-pdf2svg, caching the result for later use. You can also view a formatted compilation log at any time.

Disclosures

Network use: The plugin connects to texlive.texlyre.org, a third-party TeX Live mirror maintained by Texlyre, to download TeX files needed for compilation that are not already cached. Downloaded files are cached locally for future offline use. Internet access is required for uncached downloads.

Features

Write complete LaTeX documents.

The plugin is designed to behave like a normal LaTeX compiler, rather than a limited renderer for equations or TikZ. It supports complete and complex LaTeX documents, including document classes, sections, environments, macros, and multi-page output.

Render as PDF or SVG

You can render the same LaTeX as either a PDF or SVG. To render the code block as a PDF, use the latex language in the header; for SVG, use the latexsvg language. You can switch between them anytime by changing the code block language.

You can control the SVG background and sizing behavior from the plugin settings, and exported notes are handled correctly whether the code block renders as PDF or SVG.

TikZ code blocks

If you already use tikz code blocks, you can keep them as-is. The plugin supports the same block type for compatibility, so you don’t need to rewrite existing notes.

Use files from your vault, even code blocks

Your LaTeX code doesn’t have to be in just one code block. You can reuse code and include images by referencing them just like you would in a regular LaTeX project.

For example, suppose your vault looks like this:

Vault/
├── MathNotes/
│   ├── references.bib
│   ├── shared/
│   │   └── mathmacros.sty
│   └── chapters/
│       ├── introduction.tex
│       └── math.md
└── attachments/
    └── diagram.png

If your LaTeX block is inside MathNotes/chapters/math.md, paths are resolved relative to that note.

% You can reference a file in the same folder:
\input{introduction.tex}

% go up one folder:
\addbibresource{../references.bib}

% go up one folder and into another:
\usepackage{../shared/mathmacros}

% or start from the vault root:
\includegraphics{/attachments/diagram.png}

You can also use ./ explicitly for the current directory, so ./introduction.tex and introduction.tex both refer to the same file here.

This works with most other files, like. .png, .cls, and .pk, basically any files that LaTeX can use.

Code-block dependencies

You can reference another code block as a dependency. If a block is only meant to be included elsewhere and doesn't need to render on its own, use the latex-file code block type and give it a name:

```latex-file name: my-super-amazing-codeblock
Some incredible LaTeX...
```

To reference it, add:: before the name you gave the code block:

\input{::my-super-amazing-codeblock}

And if the code block is in another note, put the note path before::

\input{some note.md::my-super-amazing-codeblock}

The same name: syntax also works with latex, latexsvg, and tikz code blocks. You can also reference those blocks as dependencies, just unlike latex-file, they will still compile and render normally.

Use TeX packages

The compiler can use TeX Live packages just like a normal LaTeX installation. If a required package is not already available, the plugin downloads it automatically and caches it for future compilations.

You do not need a constant internet connection to use the plugin. You only need internet access the first time a package is downloaded; after that, you can reuse the cached copy offline.

This means you can use packages such as TikZ, amsmath, bibliography tools, and many others without installing or configuring TeX separately.

Work with your rendered output.

Every render has a menu with actions for working with the generated result. You can save the output to your vault, inspect the compilation log, recompile the code block, and access additional actions specific to PDF or SVG output. To open the menu for an SVG render, right click the SVG. For a PDF render, click the three-dot menu in the top-right corner of the PDF toolbar.

The plugin lets you avoid guessing what went wrong with your LaTeX or digging through the console. Compilation errors appear directly on the rendered block with the error message and, when possible, the relevant source line.

At any time, if you want to see the full LaTeX log, just open the menu and choose the log option. You'll get a structured view of the full log (which you can view and copy), a list of all warnings and errors, and a display showing the logged dependencies used and how they connect.

Runs on desktop and Android

The compiler runs inside Obsidian and doesn't need a system LaTeX installation or any other external program. This means the plugin also works on Android, where setting up a traditional TeX environment is usually much harder.

The bundled compiler and conversion runtimes have been heavily optimized for download size and memory usage, making a full LaTeX environment practical even on mobile devices.

iOS: Compilation is currently disabled on iOS, but cached renders can still be displayed. If you keep the cache in your vault, you can view synced renders from another device on iOS.


Development

The generated compiler worker files are included in the repository, so you do not need to build SwiftLaTeX or the PDF-to-SVG runtime from source just to build the plugin.

If you only want to build the plugin from the generated files already included in the repository, skip to Build the plugin.

Build everything from source

To rebuild the compiler and rendering components as well as the plugin itself:

  1. Clone this repository and enter it.
  2. Install the dependencies:
    npm install
    
  3. Clone the SwiftLaTeX fork.
  4. Install the Emscripten SDK and Git Bash.
  5. Create the local build configuration:
    Copy-Item scripts\local-config.example.ps1 scripts\local-config.ps1
    
    Then edit scripts/local-config.ps1 and fill in the required paths for your SwiftLaTeX checkout, Emscripten SDK, and Git Bash installation.
  6. From the plugin repository, build SwiftLaTeX:
    npm run build:swiftlatex
    
    This builds the pdfTeX, XeTeX, and DVIPDFM workers, copies them into the plugin source tree, and generates their compressed payloads.
  7. Build the poppler-pdf2svg fork, then replace:
    src/latexRender/pdfConversion/pdfToSvgWasm.js
    
    with the newly generated pdfToSvgWasm.js.
  8. Build and bundle the plugin:
    npm run build
    
    The final plugin bundle is written to main.js.

Build the plugin

If you do not need to rebuild SwiftLaTeX or the PDF-to-SVG runtime from source:

  1. Clone this repository and enter it.
  2. Install the dependencies:
    npm install
    
  3. Build and bundle the plugin:
    npm run build
    
    The final plugin bundle is written to main.js.

Acknowledgements

This plugin is based on obsidian-latex-render by fenjalien. Thank you for providing the starting point for this project.

Thanks also to SwiftLaTeX for making it possible to run LaTeX engines in the browser (this plugin uses a modified fork), and to Texlyre for maintaining the TeX Live mirror used to download packages on demand.