Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typst support to plotters #513

Open
Kreijstal opened this issue Oct 21, 2023 · 4 comments
Open

Add typst support to plotters #513

Kreijstal opened this issue Oct 21, 2023 · 4 comments

Comments

@Kreijstal
Copy link

What is the feature ?

This is a pure rust alternative of LaTeX

(Optional) Why this feature is useful and how people would use the feature ?

You can write code that contains mathematical syntax and fonts

@AaronErhardt
Copy link
Member

I do not quite understand how this should work. Do you mean that plotters should be usable from typst code or that typst code should be usable from plotters?

@Kreijstal
Copy link
Author

well, in matplotlib you can have a latexified title, here you should be able to do the same, to put equations in your plots

@nil-is-lin
Copy link

If typst could be integrated with this package, it would be a very elegant writing tool. Of course, typst itself supports math modes in latex, so naturally you can write latexed text to graphs.

@jonaspleyer
Copy link
Contributor

Having read this comment

well, in matplotlib you can have a latexified title, here you should be able to do the same, to put equations in your plots

my understanding is that we would like to generate code which when imported in a typst document is rendered to display the image which was drawn by plotters. This would mean to write a new backend which can export to the .typ format just like svg or the bitmap backend.

I like the idea but it is not simple at all but have some thoughts on this.

Styling, Set and Show Rules

Typst has a very simple and powerful syntax to style even basic building blocks such as rectangles, circles, lines etc. While this is a great tool for writers to quickly change layout and theming of their document, this makes it really hard when generating code. It is possible to overwrite the "general" styling arguments for each geometric shape (circle, line, rectangle, etc.) but this would mean that when generating code which can be rendered inside typst documents, we would have to specify every (even optional) argument of these functions to obtain repeatable builds which display identical even in different documents.

Practicability

Typst is a very fast moving language and features are being added constantly. I have only partially played around with it and have not seen many breaking changes

(Why) Do we want this?

Detour to matplotlib and pgf

Let's compare this feature to the option of matplotlib to generate pgf files which can be included in LaTeX documents. It is not very easy to generate nice plots from inside of a LaTeX document without the use of other tools (such as lualatex etc.). matplotlib offers a vast choice of plotting options. The reason to generate pgf files from matplotlib is to match the style of the LaTeX document as closely as possible. This means (although often not true in practice) that for example fonts should be invariant of scaling of the overall figure and thus always match the font-style and size of the text even when we resize the overall figure.

Differences

However, typst is much more flexible than LaTeX when it comes to scripting. This means (and people are already doing this) that we can generate (some) plots by writing pure typst code. While performance may be an issue in the future, it is clear that the flexibility of typst does not exhibit the same kind of problems which LaTeX does. Thus I find it questionable if this desired feature will really have a meaningful impact and be used at all.

TLDR

  • I see some technical problems (and choices to be made in this regard).
  • I do not know if this feature would be used at all since typst scripting is already very powerful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants