top | item 21710105

Web-assembly powered WYSIWYG LaTeX Editor, supporting nearly all LaTeX package

741 points| LegitGandalf | 6 years ago |github.com

114 comments

order
[+] svat|6 years ago|reply
This is amazing.

• This seems to be their main page: https://www.swiftlatex.com/

• Not all the source code is on GitHub; crucially their modification of the TeX engine seems to be distributed only as the two `.wasm` binary files). Not sure if they plan to share more or not.

• As mentioned in the FAQ/docs page, this is the work of just two people from New Zealand (Gerald Weber and Elliott Wen), and they have a paper about it from 2018 (“SwiftLaTeX: Exploring Web-based True WYSIWYG Editing for Digital Publishing”, DOI: 10.1145/3209280.3209522). Based on a quick skim so far, the paper looks fantastic, looking forward to reading it in more detail.

• In the paper, Figure 5 and the surrounding text describe how TeX was modified (the part of most interest to me); it's really clever! To avoid modifying the data structures and introducing new bugs, they hook only into TeX's internal allocation functions for tokens. (TeX as originally written by Knuth does not use malloc() or equivalent; it does all its own allocation out of giant arrays called "mem" and "str".) They can then look up this bookkeeping when the token lists are being shipped out to PDF format.

• Looks like it has some limitations as far as PS/PDF specials goes (aka “drivers” in the TeX world), so TikZ or tcolorbox don't work too well for example. However my guess is that this is just an issue with their PDF rendering (per the paper they use something like Pdf2htmlEX rather than pdf.js, for speed), and not a fundamental issue.

• But otherwise most of the standard LaTeX features and packages seem to work (labels and cross-references, etc); you can \usepackage anything and it will download the corresponding files but no data leaves your system; everything happens in the browser. Heck I even pasted in xii.tex (without the final "jbye") and it works (can click on “partridge” in the PDF and go to the corresponding part of the source).

• This sort of WYSIWYG editing for LaTeX has been done in a couple of proprietary systems before (BaKoMa TeX / Texpad), and some ancient systems as well (VorTeX), but they've been buggy in my limited experience. There was also a very impressive demo at this year's TUG meeting, by David Fuchs (who Knuth described as his “right-hand man” on the TeX project). All these projects have had to grapple with the same issues (achieving quiescence etc). This one seems to have its share of minor bugs (some artefacts seem to be visible in their published paper too!), so e.g. a feature to fully update the PDF after a (very) long typing pause (or manual user request) seems desirable. Nevertheless it's very impressive as it is.

• I think some sort of engagement with the TeX community (the mailing lists at http://tug.org/texlive/lists.html etc) may help: it appears their code is currently based on pdfTeX; they should probably consider XeTeX / LuaTeX as well (given that the doc page at https://swiftlatex.readthedocs.io/en/latest/ mentions “Lack of Unicode Support”). There are experts there with some idea of corner cases, the weird things that users want, etc. Hope this becomes part of the TeX mainstream (what little there is of it) to benefit all users (good typesetting for everyone!) and not some sort of edge case that dies when/if the authors lose interest.

Overall, am really awestruck by all this. Congratulations and good luck to the authors!

[+] ChuckNorris89|6 years ago|reply
This is indeed amazing.

I'm interested if it can be self hosted for using in a commercial environment. This would be a killer feature for increasing Latex adoption at corporations stuck with MS Word.

[+] jfk13|6 years ago|reply
> • Not all the source code is on GitHub; crucially their modification of the TeX engine seems to be distributed only as the two `.wasm` binary files). Not sure if they plan to share more or not.

PdfTeX is GPL-licensed, so if this is derived from pdfTeX (is it?), I assume they'd be required to make their source available. (Note that the GPL says that "the source code for a work means the preferred form of the work for making modifications to it", which I don't think would be a .wasm binary file.)

[+] bouvin|6 years ago|reply
Their paper even won the Best Student Paper award at DocEng 2018.
[+] amichail|6 years ago|reply
How is this better than TeXmacs?
[+] irrational|6 years ago|reply
>crucially their modification of the TeX engine seems to be distributed only as the two `.wasm` binary files

I thought one of the selling points of webassembly is that wasm files must have a textual format that anyone can read the source.

[+] Slartie|6 years ago|reply
One of the key aspects about LaTeX that made me very productive with it was that I could just dump lots and lots of text pretty much directly from my brain into the plaintext editor, without thinking much about the intricate details of the layout. I suspect that an important "feature" that enabled this was the fact that I didn't have the exact layout present and visible in front of me all the time, but just the semantic aspects of it - until I manually triggered a compilation to actually get everything laid out.

However, this is still an awesome editor, and I would probably have loved to use the near-instant WYSIWYG updates for more complex and layout-sensitive parts of papers, like tables and such. I'd just wish this editor would allow to disable the distracting layout rendering completely for "dump-text-from-brain" phases.

[+] PeterStuer|6 years ago|reply
For me it was the reverse. Layout and content always went hand in hand, with both engaging and influencing each other.

I have noticed these different approaches, text as 'data' irrespective of presentation and text as an element part of a holistic piece of work, to be strongly preferred by different people and either of them struggling to be productive when mismatched.

[+] mFixman|6 years ago|reply
I agree. Brain-dumping `\begin{float}[t]` while writing seems more natural than thinking "go to this menu, click this option, see if it inserted the float, and choose 'top' in its location properties dialog".
[+] superfist|6 years ago|reply
Personally I hate Tex/LaTeX and I think it should be replacted by something else long time ago. First of all syntax is horrible, if you don't work with it on daily basis try to figure out what macro you wrote one year ago is doing. Each time you have to jump to manual and learn almost everythig from very beginning. Next thing is lack of utf-8 and TrueType fonts supports (I know there is XeTeX and LuaTeX) but today such features such be in very core of text system no in some software branch. Extensibility is next thing and here again it is very poor unless you use something modern like LuaTeX or you are an expert in TeX macros. Packages dependency hell is next thing side by side with stupid compilation process with meaningless error messages. Am I the only one who think this way?
[+] todd8|6 years ago|reply
The problem with systems like Adobe Indesign is that they are “What You See Is All You Get”. For a company brochure with special typography and particular Pantone ink colors used in offset printing there may be nothing better. However, I’ve owned a license to Indesign for over a decade. I’ve done tutorials, bought half a dozen books on it and maybe produced one document using it.

In Indesign I wasted so much time figuring out how to get the layout, the formatting, the figures, code samples, mathematics, bibliography, even page numbering, index and footers I wanted that I had to give up.

The power of bibtex, TikZ, and other packages in the TeX ecosystem make it possible to use a system that produces just the sort of documents that I want—and the software is infinitely less expensive (it doesn’t cost anything).

TeX isn’t without its difficulties. I’ve been programming for over 50 years and still dread diving into the macro language based code for complex packages—but at least it’s available, something you can’t say about these other proprietary systems.

TeX was written by a Computer Scientist (perhaps the most eminent Computer Scientist) and it shows. Its real power is revealed only to those able to program. This is a shame, because using it has made me appreciate good typesetting—something I’ve found difficult to achieve in the kind of papers I write when I use other tools.

I use MS Word when my recipient needs it that way, I use Apple Pages or Google Docs for simple documents when I don’t care what they look like, and Markdown or Org mode for my own notes. For anything important or for something I want to have as archival source (TeX is a purposely frozen format) I use TeX and its related tools, LaTeX etc.

Give it some time, it may grow on you.

[+] andrepd|6 years ago|reply
Your comment reminds me of the people who shit on C++. Some of the criticism may be true, but there simply isn't anything out there that could possibly be considered a feasible replacement.

Also:

>lack of utf-8 and TrueType fonts supports

There's UTF-8 support in the standard pdfLaTeX compiler and TrueType support in XeTeX (which is far far from a trivial issue, which is why there are two branches, if you don't need TT fonts you're better off with pdfLaTeX which has more support for e.g. microtypographical adjustments).

[+] porker|6 years ago|reply
> Am I the only one who think this way?

No. But redoing it all from scratch and getting mindshare is difficult.

Substance.io is one project I've followed for years who aim to do this, and the time, false starts etc show just how tricky it is. https://twitter.com/_mql/status/1202200085288935430

One could argue that Adobe InDesign, Quark XPress et al are the replacement. They have the typesetting and layout capabilities that common software lacks.

[+] alanbernstein|6 years ago|reply
I feel like there isn't even a straightforward way to learn the principles of the syntax of LaTeX, in full. I've been an occasional user for years, I love the results, and I can do basic math typesetting off the top of my head. Anything more involved (diagrams especially), I really do need to start from scratch with some new package to get things working. Fortunately, stackoverflow tends to be a one-stop solution for me most of the time.

I don't believe I'll ever have a deep enough grasp to be able to do those more complex tasks on my own, and that really bothers me. I can imagine some syntax improvements, but like a sibling comment said, I don't see the mindshare shift happening any time soon.

[+] cbolton|6 years ago|reply
Next thing is lack of utf-8 and TrueType fonts supports (I know there is XeTeX and LuaTeX)

UTF-8 is supported by all modern engines. It's just that it wasn't the default for pdfTeX so you had to add one line to enable it. But this has changed in 2018 [1], so UTF-8 is now th default LaTeX encoding even when using good old pdfTeX.

[1] https://www.texdev.net/2018/03/25/latex2e-utf-8-as-standard/

[+] jimhefferon|6 years ago|reply
> Next thing is lack of utf-8 and TrueType fonts supports (I know there is XeTeX and LuaTeX)

The two halves of that sentence seem to be in conflict. Could you say more?

[+] lisper|6 years ago|reply
Why don't you just design your own syntax and write a little compiler for it that uses TeX as its back end?
[+] tambre|6 years ago|reply
Have you tried LaTeX3? I find it to be a huge productivity booster compared to the old TeX ways that I never managed to grok.
[+] GnarfGnarf|6 years ago|reply
I sat next to Prof. Knuth in 1982 at Stanford, while he did a demo of TeX on the university's DEC-10. I asked him what was next? He said: real-time, WYSYWIG display.

At the time, the idea struck me as utterly impossible.

[+] todd8|6 years ago|reply
Back in the 80’s I worked as an OS software architect. I used to do a mental exercise occasionally. I would imagine how I would design things if processors were infinitely fast. Back then we were still following Moore’s law, even for single processor machines. Processor speed, memory size, disk speed, and network speed all put hurdles up for what we could do.

I remember talking to a colleague about the possibility of a TeX system that would rerender a page as it was typed in one screen and viewed in another. Ok

[+] babayega2|6 years ago|reply
Very nice. Used ShareLatex back in the days. Now it is Overleaf[0]. I guess this will help to bring in competition. One of the benchmark I use to test Latex Editor is my Bachelor paper [1] written in French with all the accents and math symbols. I used that to test this new Latex editor and it seems not produce the PDF. But Texmaker ( my favorite) would just produce the PDF even if there are errors.

[0]: https://www.overleaf.com/ [1]: https://bitbucket.org/iMitwe/my-thesis/src/master/inegalites...

[+] ivansavz|6 years ago|reply
Whaaaaaat. This is amazing! I know so many people who have difficulties collaborating on manuscripts the mismatch between skills document skills (life sciences vs. computer science), but thanks to WYSIWYG, they will now be able to collaborate.

The checkpointing thing is very impressive... typing + update is near instant. Never seen that before.

[+] fg6hr|6 years ago|reply
A web grandmaster see I. Office365/GoogleDocs should be very interested in this stuff and by "very" I mean 50 millions at least (they burn way more money on complete bs projects). It's very likely that the author knows more than I do, but it seems reasonable to work out some sort of dual-licensing deal: one for corps who want to take it and develop further and one for smaller businesses who are ok with saas-ish solution.
[+] conorliv1|6 years ago|reply
The typing update speed blows Overleaf out of the water. I've used Overleaf for the past 3 years. It's a great product, but one of my biggest complaints is slow LaTeX rendering. If this product were a bit more polished I would use it instead of Overleaf.
[+] LolWolf|6 years ago|reply
You should check out TexPad![0] It’s lovely and essentially real-time, with autocomplete, etc. I use it as my editor of choice for all of my papers (not that any of them have particularly challenging layouts).

Really cannot recommend it enough. :)

———

[0] https://www.texpad.com/

[+] porker|6 years ago|reply
LyX [0] eat your heart out.

It's good to see competition in this space as LyX's development has slowed the last few years. I still like it, but will be interested to try this alternative.

0. https://wiki.lyx.org

[+] codeduck|6 years ago|reply
I use Lyx as my primary tool for writing. I know it's clunky but it's as reliable as the tides.
[+] upofadown|6 years ago|reply
LyX is WYSIWYM (What You See Is What You Mean). So an entirely different sort of thing. I guess you could argue that there is really no point to doing a WYSIWYG editor on top of LaTex. If it entirely works then the LaTex is just a internal layer that adds nothing but pointless complexity. WYSIWYM is the primary reason that people bother with LaTex in the first place. It's for the people that want the computer to do the work of laying out the text.
[+] krackers|6 years ago|reply
The rendering happens in real-time when you type! Is this using pdflatex? Because I've never seen an editor with this low of a response time.

Only slight nit is the blue progress bar/page load bar that appears across the top of the screen while you're typing is annoying. And the baseline kerning of the fonts in math mode seem a bit off: $$x^2 + 2x + 1$$ has the x in 2x a bit raised

[+] ulrikrasmussen|6 years ago|reply
It appears to be using a heuristic to update the PDF directly when you type, and then it periodically runs LaTeX to do global layout. Try putting the cursor before \LaTeX in the example document and input a few spaces. For me, it shifted the first characters into the later ones, perhaps because their heuristic couldn't detect that they are on the same line due to the vertical offset.
[+] jpdus|6 years ago|reply
Really nice, the speed is way better than e.g. Overleaf.

Is there any way to divide the screen horizontally instead of vertically for use with widescreens? Did not find an option at first glance.

[+] ericjang|6 years ago|reply
This is incredible. I've never seen LaTeX render so fast; it almost feels like WYSIWYG editing.
[+] fivre|6 years ago|reply
While I don't doubt the utility of this at all, I am quite amused by the concept of WYSISYG LaTeX.
[+] stabbles|6 years ago|reply
Some people I know literally share LaTeX math in emails and chats and assume my head has an internal LaTeX-compiler to understand it (usually I do). I guess this means people are really accustomed to writing maths in one go in LaTeX -- it's like the pseudo-code of maths.
[+] pjmlp|6 years ago|reply
Why? It is almost as old as LaTeX.

Not everyone enjoys programming their documents and visual editors for LateX written in Motif were the first ones to become available.

[+] savolai|6 years ago|reply
I'm getting this on ios Safari when creating document:

"Oops Error Detected! Looks like there was a problem when creating the project: DataCloneError: Failed to store record in an IDBObjectStore: BlobURLs are not yet supported."

[+] _emacsomancer_|6 years ago|reply
Fortunately, the WYSIWYG-bit is non-mandatory. You can also edit the source directly.

I assume Google Drive files can be simultaneously edited by multiple people? If so, then this represents a real competitor to Overleaf.

[+] xuejie|6 years ago|reply
This is indeed amazing! But I was wondering if it's possible to compile the whole TeXmacs into WebAssembly and have it in the browser. That will be a totally different world.
[+] philistine|6 years ago|reply
This seems like an incredible tool to increase adoption of TeX systems. It solves the problem of: I want to try my hand at TeX but you’re saying I have to install what now?
[+] _emacsomancer_|6 years ago|reply
Overleaf.com is another place to try out TeX without installing anything. (The free version is perfectly fine for almost anything other than collaborating with 3+ people on the same project.) The web interface isn't as nice as a proper text editor, but it's not too bad.
[+] 1980phipsi|6 years ago|reply
Google drive and dropbox are blocked at work for me...It would be nice if they had an option for if you don't want to save your work. Like just an in-browser editor without saving. Sometimes I just might want to write up some Latex and then copy it into something else. Nowadays I usually need to open up Lyx to do the same thing.
[+] 1980phipsi|6 years ago|reply
Ah, so the sandbox mode on github is what works for me. However, there is no link for it on the main page.

Regardless, I suppose I was mistaken on what the project was. I assumed it was like a WYSIWYG version of Lyx in the browser. You're still writing Latex with this.