Generation of images from latex

I am trying to convert latex into an image like those online latex to image converters.
Most of the methods I have seen for doing so suggest calling an external application via say the subprocess module which will generate the image for me.

However, management is not keen on this as it will require external users to install additional software in addition to our own which, with I can assume to be a simple task.

I have seen which is more or less the problem. It suggests use of MathJax or built-in function of Sumpy or python specific libs . Another option is a cpp library for which I have to create bindings for (in which I have zero experience)
Another solution I have is to

  1. Have .PNG files that contain btyes for numbers (0-9) and other symbols that are needed
  2. Then using image crate for each char use include btyes and place the btyes in the image.

But this solution is error prone and not exactly flexible for more complex LaTeX equations.

So is there some rust lib that provides this functionality directly or indirectly. Any help is appreciated!

For a modern, modular typesetting engine written in Rust, try Typst instead.

If you still insist on actual LaTeX input, then that's one google search away, too.

However, calling into an external process for such a complex task doesn't seem too bad. Couldn't you just package your application as a Docker container with LaTeX preinstalled?


Very curious indeed that these two libraries didn't show up on my searches , both seem promising , and need to check if output as image functions correctly

I have looked at the libraries and i believe typst is more then enough for my use case but i didnt seem to find any api callable via code , so it there only the cli or is there a callable api via code

So far they don't distribute their crates on, but you can use their compiler as a git dependency from here.

1 Like

I attempted to use it via git (and correct me if i am doing this wrong) but i am unable to do it . I have tried :

typst = { git = ""}


typst = { git = ""}

However in both cases i get with cargo build --verbose

    Updating git repository ``
warning: spurious network error (3 tries remaining): request failed with status code: 404; class=Http (34)
warning: spurious network error (2 tries remaining): request failed with status code: 404; class=Http (34)
warning: spurious network error (1 tries remaining): request failed with status code: 404; class=Http (34)
error: failed to get `typst` as a dependency of package `arkley_describe v0.0.3 (C:\Users\Aarav Aditya Shah\Documents\GitHub\arkley\arkley_describe)`

Caused by:
  failed to load source for dependency `typst`

Caused by:
  Unable to update

Caused by:
  failed to fetch into: ....\.cargo\git\db\typst-ae98927b3345e35f

Caused by:
  network failure seems to have happened
  if a proxy or similar is necessary `net.git-fetch-with-cli` may help here

Caused by:
  request failed with status code: 404; class=Http (34)

If i use github to clone it works but not with cargo

You will want to specify the git url, not the viewable tree url.
I found this in the green "Code" button on the main page:

For reference, this matches the cargo reference example (which shows details like how to specify a branch).

It's the crate named typst (unsurprisingly).

It's the crate named typst (unsurprisingly).

That is true but when you search up typst on and open up the doc

That is a side effect of the typst authors seemingly not having published their crate via

When you do the latter, docs are generated and uploaded to, and a entry is upserted as well.

I just thought of something else. You can get a version of what would be uploaded on by cloning the git repo, then navigating to the crate, and executing cargo doc --open. That will build the docs, as well as open up a browser window to their index.


Building the docs of your project with typst as dependency should also include the docs for typst when you run cargo doc without the --no-deps option.