Live data from Hacker News

Towards LaTeX in the Browser

hackernoon.com

11–20 of 68 posts

Re: Towards LaTeX in the Browser

#11
(I'm a co-founder at Overleaf.com, which does collaborative 'LaTeX in the browser' in a different sense.)

I like the idea of a 'sane' subset of LaTeX that is easy to publish to the web. There are tools like LaTeXML and TeX4ht that try to convert general LaTeX documents to (X)HTML, but it's a very hard problem.

Some difficulties arise from the fact that TeX is just very hard to parse in general. Even the first stage of parsing TeX is Turing complete [1]. This makes it hard to write tooling e.g. for linting (though tools exist, e.g. chktex) or creating a WYSIWYG editor backed by LaTeX [2]. (edit: or creating a good LaTeX auto-complete [4])

Others arise from TeX's extensibility --- there are many thousands of packages that define their own commands and environments for different types of documents and different disciplines. This extensibility is on the one hand one of the main reasons that TeX and LaTeX are still actively used some 40 years after TeX's initial release, but on the other hand a major challenge for conversion to HTML. The LaTeXML project has many custom bindings [3] for these packages, but it's far from complete.

I guess the main question is whether we can find the right subset, and this project looks like a great start.

[1] https://tex.stackexchange.com/questions/4201/is-there-a-bnf-...

[2] https://www.overleaf.com/blog/81 --- my first attempt at rich text on Overleaf, many years ago

[3] http://dlmf.nist.gov/LaTeXML/manual/customization/customizat...

[4] https://www.overleaf.com/blog/523-a-data-driven-approach-to-...

Re: Towards LaTeX in the Browser

#12

I have found KaTeX to be the best currently-available solution. In particular, it can be rendered without client-side javascript.

Yeah, I'm really surprised it's not mentioned here.

It also causes much less page-reflowing than MathJax, and is much more lightweight.

Re: Towards LaTeX in the Browser

#13
post #4

Are there any other solutions to document typesetting with latex-like features? TeX is very obtuse for someone who hasn't been using it for a long time.

I've been using org-mode and exporting it to HTML. Then making an @media(print) style sheet and exporting the HTML/printCSS to PDF through princeXML.

It's been amazing. Latex equations are exported as pngs (for PDF export because I don't think prince does Mathjax, but org mode can export to mathjax). I have my bibliography with bibtex2html. And templating my pdfs becomes so much easier than with latex. It's just HTML CSS !! My figures are numbered and captioned and referenced throughout the text, same for tables. And my table of content is generated. And code is highlighted. And I have access to ditaa for ascii flow charts and a bunch of other stuff (for making uml in ascii with png export for the PDF for example). It also handles excel like tables with formulae (possible to have lisp formulae !! So cool !!) in text mode !!. And of course, you can plot your table through gnuplot inside your org file. You tell it which columns and rows, the type of graph etc :)

It's also easy to include other org files, or to go down to raw HTML for the export (rather than org mode->HTML) if need be (for a picture than spans over 2 pages for instance).

Give it a try, you might like it ;) In the end it's just an org mode export to HTML to PDF with the print CSS media query. But it works remarkably well and you have all the org mode features.

Re: Towards LaTeX in the Browser

#14
post #4

Are there any other solutions to document typesetting with latex-like features? TeX is very obtuse for someone who hasn't been using it for a long time.

You might want to check out LyX. It is a GUI editor that generates beautiful TeX documents but it is designed to be an user-friendly document processor instead of just a TeX GUI.

http://www.lyx.org/

Re: Towards LaTeX in the Browser

#16
post #8
post #4

Are there any other solutions to document typesetting with latex-like features? TeX is very obtuse for someone who hasn't been using it for a long time.

A common solution is to use LaTeX, but to use it indirectly: write in Markdown and convert to PDF using Pandoc [1], which uses LaTeX in the background. This is (part of) the process used in RMarkdown [2], for example. That way, you get all the benefits of TeX and LaTeX but without most of the pain. [1]: https://pandoc.org/index.html [2]: http://rmarkdown.rstudio.com/

I just use Atom with the markdown-preview-plus package for live preview.

Re: Towards LaTeX in the Browser

#17
post #4

Are there any other solutions to document typesetting with latex-like features? TeX is very obtuse for someone who hasn't been using it for a long time.

I've been using org-mode and exporting it to HTML. Then making an @media(print) style sheet and exporting the HTML/printCSS to PDF through princeXML. It's been amazing. Latex equations are exported as pngs (for PDF export because I don't think prince does Mathjax, but org mode can export to mathjax). I have my bibliography with bibtex2html. And templating my pdfs becomes so much easier than with latex. It's just HTML…

> Latex equations are exported as pngs (for PDF export because I don't think prince does Mathjax, but org mode can export to mathjax).

Prince does MathML, at least, if you want to avoid images.

Re: Towards LaTeX in the Browser

#19

I wonder if somebody has taken TeX and compiled to the browser in wasm using emscripten. That would be easier to port but heavy on load times. Edit: it exists! https://github.com/manuels/texlive.js/ is a limited port of LaTeX to JS, rendered to PDF

Classic TeX would be damn near useless in the age of Unicode, so you're looking at something like XeLaTeX or LUATex. The problem is that it's really easy to implement a really basic form of TeX, but unless you already planned for the really hard cases, maintaining your implementation is going to become intractible. TeX's real text typesetting is almost always woefully ignored even though _everything_ has to type beautifully, not just makes, and in modern version of TeX, that has to happen without insane syntax just to get a Unicode character we can already "just write" rather than needing all kinds of dedicated macros just for diacritics, it something as simple as mixing two writing scripts that necessitate two different fonts entirely.

Re: Towards LaTeX in the Browser

#20
post #4

Are there any other solutions to document typesetting with latex-like features? TeX is very obtuse for someone who hasn't been using it for a long time.

Geogebra, https://www.geogebra.org/, might suit your purpose. See it in action https://www.youtube.com/watch?v=GjPakjpEAXs You can use it to produce docs, such as https://www.geogebra.org/m/M4nBYbbG#material/c3wwdgD5
Post reply on HN