kisonecat / tikzjax

TikZJax is TikZ running under WebAssembly in the browser
LaTeX Project Public License v1.3c
443 stars 39 forks source link

usetikzlibrary #2

Open righthandabacus opened 5 years ago

righthandabacus commented 5 years ago

Does it possible to use the \usetikzlibrary{} line? I tried to put along the \begin{tikzpicture} line but no success.

3geek14 commented 4 years ago

That would need to be in the preamble, which tikzjax has predefined. Everything you can edit is inside the document environment, so there is not currently a way for you to do this.

A possible way for this to be implemented would be to specify the libraries to load in the <script> tag, and that sounds like a pretty useful feature.

j-loreaux commented 4 years ago

I think this is an absolutely essential feature for TikZJax. In particular, it would allow for rendering commutative diagrams, which has long been a feature missing from MathJax and KaTeX because of its complexity. Of course, the SVGs could be rendered server-side or in advance, but there may be instances when this is undesirable.

@3geek14, do you know if doing this would require multiple core dumps (one for each collection of libraries used in the preamble), or is there are a way to load the core before reading the preamble is complete? I would be interested in giving this a shot, but I'm not sure exactly how to go about creating the necessary core dumps with web2js.

kisonecat commented 4 years ago

I do have all of TeX-live stuck on Amazon S3, and I've got a version of TeX-in-wasm with the file I/O instrumented with asyncify so they can be interrupted and replaced with network fetches. This should make it possible to get usetikzlibrary to work without too much pain.

Maybe we could schedule a time to collaborate on this? (Depressingly the pandemic has made my schedule even worse but I would really love to get this all working. I've at least straightened out the greek letter problems...)

ComFreek commented 4 years ago

@kisonecat Does that mean one would always need a server serving TeX-Live files? Or is it possible to get a self-contained client-only version out of it?

I know almost nothing about TeX internals, so sadly, I cannot offer to collaborate on this.

kisonecat commented 4 years ago

Somewhere there would be a server hosting the TeX files, but that only differs from hosting mathjax by the size and number of the files. Importantly, the server doesn't do any computation, so something like S3 is fine, and I expect the copy I've already got hosted on S3 will be suitable for everyone everywhere for a while given that we have NSF grant support.

You could still do an entirely client-side version, but TeX really does involve a ton of files, so if you want to support arbitrary \usepackages and all, those packages need to be available somewhere.

matssson commented 3 years ago

Would you consider adding support for some essential packages before adding arbitrary support? Essential meaning matrix, arrows, and hopefully even tikz-cd

3geek14 commented 3 years ago

I think you'll run into an issue where everyone has a different interpretation of what counts as essential. I, for example, have never used matrix or tikz-cd, and I'd instead be asking for automata and positioning. (At least, when I was newer to TikZ, I would have considered those essential.)

rcalsaverini commented 3 years ago

Hi! Just wanted to check if this discussion went any further. I'm pretty interested in this.

matheusfillipe commented 2 years ago

So is there no way to include libraries, even if globally?

3geek14 commented 2 years ago

Currently, that is the case, at least on this version of the project. It looks like a few people have forked the repo and have made more additions, and in particular it looks as thought @drgrice1 might have added support for tikz libraries (and possibly even other latex packages) on their fork.

matheusfillipe commented 2 years ago

@3geek14 That looks really nice. I've been trying to build @dgrice1 web2js: https://github.com/drgrice1/web2js/tree/ww-modifications, but the last step fails like this:

$ node initex.js
This is e-TeX, Version 3.14159265-2.6 (INITEX)
**entering extended mode
(latex.ltx (texsys.cfg)
./texsys.aux found

\@currdir set to: ./.

Assuming \openin and \input
have the same search path.

Defining UNIX/DOS style filename parser.

catcodes, registers, parameters,
LaTeX2e <2021-11-15> patch level 1
! LaTeX Error: LaTeX requires the e-TeX primitives and additional
               functionality available in the engines:
               - pdfTeX v1.40
               - XeTeX v0.99992
               - LuaTeX v0.95
               - e-(u)pTeX mid-2012
               or later.
<argument> ...-2012\MessageBreak or later}
                                          \batchmode \read -1 to \res...
l.1117   }

?
This is e-TeX, Version 3.14159265-2.6 (INITEX)
**Sorry, I can't find that format; will try PLAIN.
I can't find the PLAIN format file!

And no core.dump is generated. Could you maybe point out what am I missing there?

3geek14 commented 2 years ago

I've never tried building either project myself. Best of luck!

ravirathore commented 2 years ago

@3geek14 That looks really nice. I've been trying to build @dgrice1 web2js: https://github.com/drgrice1/web2js/tree/ww-modifications, but the last step fails like this:

$ node initex.js
This is e-TeX, Version 3.14159265-2.6 (INITEX)
**entering extended mode
(latex.ltx (texsys.cfg)
./texsys.aux found

\@currdir set to: ./.

Assuming \openin and \input
have the same search path.

Defining UNIX/DOS style filename parser.

catcodes, registers, parameters,
LaTeX2e <2021-11-15> patch level 1
! LaTeX Error: LaTeX requires the e-TeX primitives and additional
               functionality available in the engines:
               - pdfTeX v1.40
               - XeTeX v0.99992
               - LuaTeX v0.95
               - e-(u)pTeX mid-2012
               or later.
<argument> ...-2012\MessageBreak or later}
                                          \batchmode \read -1 to \res...
l.1117   }

?
This is e-TeX, Version 3.14159265-2.6 (INITEX)
**Sorry, I can't find that format; will try PLAIN.
I can't find the PLAIN format file!

And no core.dump is generated. Could you maybe point out what am I missing there?

@Matheusfillipe

Hi,

Please let know if you have resolved this issue.

Am also facing this issue.

Regards,

matheusfillipe commented 2 years ago

@ravirathore No, I couldn't manage to build it. I contacted the developer and he gave me his build of it core.dump then I could build his tikzjax fork using it.

I took the freedom to host this build at https://tikzjax.pages.dev/tikzjax.js

I used it and made a post on my "experiments site" / blog: https://blog.mattf.one/series/coding/1.html#import-latex-libraries (I needed some workaround because it renders in the wrong position)

But it is not really ready for production and can be very unstable. It is a very interesting concept but still needs more development and web-assembly support in browser to mature in general.

ravirathore commented 2 years ago

@matheusfillipe Thanks for the revert. Can you please share the core.dump file. Need to build this and work on it a bit - include some libraries etc.

It's a great project and definitely have lot of potential for itself and also for the webassembly.

Thanks,

ravirathore commented 2 years ago

@matheusfillipe Took your core.dump from your url and compiled. Its working. Thanks.

Do you know how to add new packages?

I tried adding 'chemfig.sty' in tex_files.json; and compiled.

And, tried to run the following script:-

..............

...........

It showed following error :-

Error: Could not find file input.dvi at Me (run-tex.js:1:412407) at texify (run-tex.js:1:417762)

Do you know where am I making mistake?

Thanks,

matheusfillipe commented 2 years ago

@ravirathore

Sorry I am not sure how to add additional packages.

Remember that you need both https://tikzjax.pages.dev/tex.wasm.gz and https://tikzjax.pages.dev/core.dump.gz: https://github.com/drgrice1/tikzjax/tree/ww-modifications#building.

Besides that, this is all we know: https://github.com/drgrice1/tikzjax/tree/ww-modifications#options

Additional packages can be made available by adding a file .json that contains an array of file names needed by the package to the tex_packages directory, and adding the gzipped files in that array to the tex_files directory.

Make sure you have the ww-modifications branch of https://github.com/drgrice1/dvi2html inside your node-modules.

Besides that I think we are going off topic and you should try to contact the author of the fork himself.

ravirathore commented 2 years ago

@matheusfillipe

thanks!