TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Towards LaTeX in the Browser

110 pointsby jxxcarlsonover 7 years ago

16 comments

jdleesmillerover 7 years ago
(I&#x27;m a co-founder at Overleaf.com, which does collaborative &#x27;LaTeX in the browser&#x27; in a different sense.)<p>I like the idea of a &#x27;sane&#x27; 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&#x27;s a very hard problem.<p>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])<p>Others arise from TeX&#x27;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&#x27;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&#x27;s far from complete.<p>I guess the main question is whether we can find the right subset, and this project looks like a great start.<p>[1] <a href="https:&#x2F;&#x2F;tex.stackexchange.com&#x2F;questions&#x2F;4201&#x2F;is-there-a-bnf-grammar-of-the-tex-language" rel="nofollow">https:&#x2F;&#x2F;tex.stackexchange.com&#x2F;questions&#x2F;4201&#x2F;is-there-a-bnf-...</a><p>[2] <a href="https:&#x2F;&#x2F;www.overleaf.com&#x2F;blog&#x2F;81" rel="nofollow">https:&#x2F;&#x2F;www.overleaf.com&#x2F;blog&#x2F;81</a> --- my first attempt at rich text on Overleaf, many years ago<p>[3] <a href="http:&#x2F;&#x2F;dlmf.nist.gov&#x2F;LaTeXML&#x2F;manual&#x2F;customization&#x2F;customization.latexml.html" rel="nofollow">http:&#x2F;&#x2F;dlmf.nist.gov&#x2F;LaTeXML&#x2F;manual&#x2F;customization&#x2F;customizat...</a><p>[4] <a href="https:&#x2F;&#x2F;www.overleaf.com&#x2F;blog&#x2F;523-a-data-driven-approach-to-latex-autocomplete" rel="nofollow">https:&#x2F;&#x2F;www.overleaf.com&#x2F;blog&#x2F;523-a-data-driven-approach-to-...</a>
评论 #16249972 未加载
评论 #16249871 未加载
评论 #16249895 未加载
kovarianceover 7 years ago
I have found KaTeX to be the best currently-available solution. In particular, it can be rendered without client-side javascript.
评论 #16249480 未加载
评论 #16248919 未加载
评论 #16249849 未加载
marvyover 7 years ago
Just a bit of historical correction. The article&#x2F;post says:<p>&quot;Ten years later, in 1978, his work bore fruit&quot;<p>This gets things pretty wrong. He got the idea in 1977, and his estimate of &quot;this will take 6 months&quot; was pretty close, in that the initial version was finished sometime in 1978. It then took about another ten years to be &quot;actually done&quot;. (Rewrite, add features, fix bugs, create Metafont, create WEB, etc...)
评论 #16249845 未加载
DavidSJover 7 years ago
Completely besides the point, but that integral evaluates to sqrt(2pi), not sqrt(pi).
评论 #16249160 未加载
评论 #16249851 未加载
applecrazyover 7 years ago
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.<p>Edit: it exists! <a href="https:&#x2F;&#x2F;github.com&#x2F;manuels&#x2F;texlive.js&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;manuels&#x2F;texlive.js&#x2F;</a> is a limited port of LaTeX to JS, rendered to PDF
评论 #16249559 未加载
评论 #16248740 未加载
svatover 7 years ago
I wonder whether this is the right approach. TeX itself is one of the most heavily documented programs in existence. Not only are its workings documented in detail in <i>The TeXbook</i> (and a host of other books by other authors, such as Eijkhout&#x27;s <i>TeX by Topic</i>) but even the program itself has been written in a “literate programming” style, with pretty formatted source code (with profuse comments) available in print (Vol B of <i>Computers and Typesetting</i>) and as a PDF (<a href="http:&#x2F;&#x2F;texdoc.net&#x2F;texmf-dist&#x2F;doc&#x2F;generic&#x2F;knuth&#x2F;tex&#x2F;tex.pdf" rel="nofollow">http:&#x2F;&#x2F;texdoc.net&#x2F;texmf-dist&#x2F;doc&#x2F;generic&#x2F;knuth&#x2F;tex&#x2F;tex.pdf</a>), there&#x27;s a detailed history&#x2F;retrospective and log of every change that went into the program (see Chapters 10 and 11 of the book <i>Literate Programming</i>, though the log without explanation is also available online <a href="http:&#x2F;&#x2F;texdoc.net&#x2F;texmf-dist&#x2F;doc&#x2F;generic&#x2F;knuth&#x2F;errata&#x2F;errorlog.pdf" rel="nofollow">http:&#x2F;&#x2F;texdoc.net&#x2F;texmf-dist&#x2F;doc&#x2F;generic&#x2F;knuth&#x2F;errata&#x2F;errorl...</a>), and there are even 12 hours of video of Knuth talking about the internals of the program (<a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=bbqY1mTwrj8&amp;index=12&amp;list=PL94E35692EB9D36F3" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=bbqY1mTwrj8&amp;index=12&amp;list=PL...</a>).<p>So when the article says:<p>&gt; To reproduce all of LaTeX in the browser is too much to ask<p>I wonder why? The file <i>tex.web</i> is less than 25000 lines long, much of it comments, so I&#x27;d estimate that TeX itself is only about 20000 sloc (in fact <i>tangle</i> on <i>tex.web</i> generates a Pascal file <i>tex.p</i> which is only 6115 lines long). This is not a lot IMO, and it would be a lot better to actually re-implement this, with additional support for things like getting the parse tree etc.
patteover 7 years ago
I was wondering recently if&#x2F;how it would be possible to piggybag latex’ georgous typesetting (place the letters) to bring justified-text to websites. I want to do a PoC for absolut positioning all letters of a basic document placed by tex for my screensize.<p>Did anyone ever see such an approach?
gravypodover 7 years ago
Are there any other solutions to document typesetting with latex-like features? TeX is very obtuse for someone who hasn&#x27;t been using it for a long time.
评论 #16248784 未加载
评论 #16249131 未加载
评论 #16249589 未加载
评论 #16248783 未加载
评论 #16249844 未加载
评论 #16250215 未加载
评论 #16249159 未加载
martyalainover 7 years ago
What do you think of this project {lambda way} as an alternative to LaTeX in a browser: <a href="http:&#x2F;&#x2F;lambdaway.free.fr" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr</a><p>For instance, from this wiki page <a href="http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=oxford" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=oxford</a> I could directly generate a PDF paper, <a href="http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;data&#x2F;lambdatalk_20170728.pdf" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;data&#x2F;lambdatalk_20170728.p...</a>, and slides, <a href="http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=oxford_slides" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=oxford_slides</a><p>Some other pages in this workshop: <a href="http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=factory" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=factory</a> <a href="http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=NIL" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=NIL</a> <a href="http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=teaching" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=teaching</a> <a href="http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=lambdacode" rel="nofollow">http:&#x2F;&#x2F;lambdaway.free.fr&#x2F;workshop&#x2F;?view=lambdacode</a><p>Your comments are welcome.<p>Alain Marty
etaioinshrdluover 7 years ago
I used <a href="https:&#x2F;&#x2F;github.com&#x2F;phfaist&#x2F;pylatexenc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;phfaist&#x2F;pylatexenc</a> to convert LaTeX to unicode text, with math symbols and superscripts etc.<p>It&#x27;s of course never going to be as good looking as MathJax or something like that -- but it may be more appropriate to be able to treat it as plain Unicode text in some cases.<p>For instance, it works in title fields across the web and search engines will understand it better than anything else.
emerybergerover 7 years ago
There is not really a need to modify LaTeX at all to make it run in the browser. It already exists. Without modifying a single line of code, we have implemented a full browser-based port of LaTeX as part of our Browsix project, which makes it possible to run full, unmodified Unix applications inside the browser. See <a href="http:&#x2F;&#x2F;browsertex.org" rel="nofollow">http:&#x2F;&#x2F;browsertex.org</a> and <a href="http:&#x2F;&#x2F;browsix.org" rel="nofollow">http:&#x2F;&#x2F;browsix.org</a> (and <a href="http:&#x2F;&#x2F;bpowers.net" rel="nofollow">http:&#x2F;&#x2F;bpowers.net</a> and <a href="https:&#x2F;&#x2F;jvilk.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jvilk.com&#x2F;</a> and <a href="http:&#x2F;&#x2F;plasma.cs.umass.edu" rel="nofollow">http:&#x2F;&#x2F;plasma.cs.umass.edu</a>).
djuergesover 7 years ago
I actually did &#x27;LaTeX in the browser&#x27; as a master thesis in 2014, but never went to continue developing it afterwards, be it as open-source project or with a commercial intent in mind. Although I though, at that time, I was at least up to the few solutions that were out there and solved the task of instant updates and real-time collaborative work on a document pretty gracefully.<p>Some neat improvements would have been version and so on, but you know, never made it that far after picking up a job. Kind of a shame...<p><a href="https:&#x2F;&#x2F;github.com&#x2F;djuerges&#x2F;cotex" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;djuerges&#x2F;cotex</a>
jessriedelover 7 years ago
I read the post but I still don&#x27;t understand: is it possible to define new commands using \def or \newcommand? At first I thought these are what the other meant by &quot;macro&quot;, but later he says<p>&gt; We are exploring ways for users to define non-default environment behaviors in the browser. The same goes for macros used outside the dollar and double-dollar fences.<p>But I can&#x27;t use \def or \newcommend to define things that appear <i>inside</i> dollar signs either.
评论 #16251717 未加载
angarg12over 7 years ago
Just for fun here is a little web game I made to look like a maths paper using MathJax.<p><a href="https:&#x2F;&#x2F;angarg12.github.io&#x2F;TrueExponential&#x2F;" rel="nofollow">https:&#x2F;&#x2F;angarg12.github.io&#x2F;TrueExponential&#x2F;</a>
jimhefferonover 7 years ago
PreTeXt from <a href="http:&#x2F;&#x2F;mathbook.pugetsound.edu&#x2F;" rel="nofollow">http:&#x2F;&#x2F;mathbook.pugetsound.edu&#x2F;</a> has gotten some mindshare.
abritinthebayover 7 years ago
I love the output of LaTeX but the language itself (and it’s dependencies and packages) are an absolute horror show.<p>I’ve never understood how people can learn be it so, writing it is painful, it’s tooling is <i>abysmal</i>, and it rarely seems to work except on the person who wrote its machine.<p>We’ve got to be able to do better.
评论 #16251161 未加载
评论 #16250530 未加载