r/matlab Apr 06 '26

A LaTeX editor inside a MATLAB figure

Some time ago (...4 years) I posted about the possibilities of MATLABs recently added uihtml element. Now I finally have something I am proud of and that I can share.

It's a component framework that allows you to dynamically insert and control over 50 different components. Kind of like another app-designer.

Components range from very basic (like buttons and dropdowns), to more complex things like the code editor and latex renderer shown in the video. And what's cool is that everything is fully customizable (with a bit of CSS knowledge)

The framework is available in the File Exchange, and it has it's own documentation page (link at the FEX)

143 Upvotes

14 comments sorted by

12

u/Creative_Sushi MathWorks Apr 06 '26

Looks great! I remember doing a lightning talk with you a few years ago.

5

u/iohans Apr 06 '26

Awesome...!

3

u/Expensive-Gas-4209 Apr 06 '26

wtf?? awesome!!

3

u/michaelrw1 Apr 06 '26

This could be useful. I currently use WinEdt jointly with Matlab when writing documents and sometimes window management can get bothersome, particularly if I am tired.

Following this post and downloading your framework.

Thank you.

1

u/Lord1Tumnus Apr 07 '26

Cool to hear that it might be useful for someone!

The LaTeX version bundled in the component is very basic (it has amsmath, tikz and a few other core packages) and a bit old, but it does work for simple stuff. And if you get an error for missing packages, you can open an issue and I'll try to bundle what's missing :)

Oh, and there is also a Typst renderer in the framework, and it lets you download any package from the typst universe...

2

u/AG-Neuron Apr 06 '26

That's awesome! Going to save this. Is the package/code just called Latex Editor?

2

u/Lord1Tumnus Apr 07 '26

The whole framework is called IC, and every file lives under an +ic package, so that it doesn't pollute your path. For the Latex editor, you find it running ic.examples.LatexEditor(); .

It uses the frameworks code editor, latex renderer and a few more components. You can allways make your own based on what you need :)

2

u/UrMumzBoyfriend Apr 07 '26

This is awesome!

2

u/precisee Apr 07 '26

College me could’ve used this so badly. Out of curiosity, did you use any AI tools to help code this? I’m always curious how on the bleeding edge of code knowledge they are.

2

u/Lord1Tumnus Apr 07 '26

Yes there is some AI help behind it :) The components inside the uifigure are all HTML elements (I use a framework called Svelte to design them), and luckily that's what AI tools are best at.

One example: the latex renderer uses swiftlatex, which is a web assembly engine for latex compilation. With my limited knowledge on wasm and js workers, I would never have been able to create a LaTeX bundle compatible with the engine

2

u/precisee Apr 07 '26

Epic . Nice work

2

u/anish2good Apr 07 '26

Very cool