TeX doesn't have dynamic reflow, is defined by a macro system that involves essentially monkey patching the parser as it goes, lacks anything resembling a DOM, wasn't designed with Unicode or internationalization in mind, is completely unparallelizable, doesn't interoperate with CSS, has its own concept of block and inline layout that doesn't allow for text wrapping around floats without hacks, requires multiple passes to compute various things like tables of contents, and wasn't designed for interactive-level performance. Something syntactically like TeX may well be the solution, but jamming TeX itself into the Web platform wouldn't end well.
There's a related article called A Functional Description of TeX's Formula Layout [1] that describes a more modern reimplementation of a part of TeX.
[1] http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.39....
It's not that CSS is still very far from professional typesetting; what amazes me is that at the same time it's much more complex. Look at all these possible 'display' values and box models! And you still cannot do a run-in header! Or automatic numeration! (You can do the latter natively with XSLT, but it's not cool.) By comparison TeX only has boxes, vertical and horizontal lists, glue, and a few lesser things like kerning. And it produces works of art.
- quality justified paragraphs making use of inter-word spacing and hyphenation
- font ligatures (tex uses quality fonts have special characters for sequences like fi fi fl ffi ffl ft etc)
- good heuristics about where to cut pages (e.g. flexible spacing around heading)I guess that the Web just started simple and evolved from that, and then nobody bothered to remake it for prettier text.
What's interesting is that it could separate the content and the styling information, so you could load the same content into two or more publications with different styles and get two different typesetting from the same source (e.g. one column small page for a book and two or three column large page for an article in a journal). And it was very easy to change the format or paper size: just change it and it would reflow the content accordingly. It didn't even took much time, as far as I can remember, and I'm talking about IBM PC 286 here.
So, truly, it's not a technical obstacle; web could have a much better typesetting engine working at high speed (and I'd say that it would be much better to imitate paged media instead of scrolling; scrolling is really inconvenient for reading). It's just that it grows wildly and in all directions at once; it tries to be a "semantic" storage, a rendering medium, and an application engine at the same time, and is not particularly good at any of this.
It might "simply be" the case (well, in fact it is) that TeX is simply really old and doesn't lend itself well to concepts it predates such as dynamic reflow, etc...
But for just rendering equations, I don't think you can beat TeX for ease of use. And most of the criticisms then don't apply - you can void the insane macro system, it doesn't require multiple passes, etc. I guess lack of CSS support could still be an issue.
Is that due to implementation or the specification?
I used TeX a few times back in the mid-90's and something about it really clicked with me. The documents I made with it are easily the most attractive documents I've made.
Since then, I've wondered why TeX isn't used for ebooks and thanks to your comment, now I know.
If your equations require concurrency to render, you're either a genius or insane. Or both.
(Replaced by "\binom{n}{k}" in LaTeX with amsmath.)
- "\near" as a synonym for "\simeq"
- \newcommand{\hyp}[1][\mathbb{R}]{\prescript{*}{}{#1}}
- \newcommand{\powerset}{\mathcal{P}}
This way you can change the notation easily and all-at-once if you need to, as well as making the semantics clear to the source-reader.
Having more semantic information in that scenario would help the sighted just as much as the visually impaired—imagine hovering over an unfamiliar notation with your mouse and seeing it explained.
Specifically, just like a sighted person has to determine from context whether "a(b)" is function application or variable multiplication, a blind person can be asked to determine from context whether "a left-parenthesis b right-parenthesis" is function application or variable multiplication.
No AI or CV is required for such a reading algorithm. It's unfortunate that this reading algorithm doesn't quite match what two mathematicians would say if they were conversing with each other, but there's at least one good reason to believe this is still a useful reading algorithm: it's exactly the system used by blind mathematician Abraham Nemeth with his readers, called "mathspeak":
The speech generated by this protocol is not exactly what a
professor in class would use, but it is absolutely unambiguous
and results in a perfect Nemeth Code transcription. It avoids
largely unsuccessful attempts by a reader to describe the
notation he sees, accompanied by the shouting and gesturing that
such attempts at description engender.
http://www.nfbcal.org/s_e/list/0033.html(Nemeth notably created the Nemeth Braille Code for Mathematics, which is part of Unified English Braille and is probably the most widely used Braille code for math. MathSpeak hasn't enjoyed the same level of adoption, but only because there's no standard, MathPlayer, VoiceOver etc all have their own ad hoc rules for how to read math.)
(Strictly speaking the example I gave was a verbose variant of the system described in the email: http://www.gh-mathspeak.com/examples/NemethBook/?rule=18 ) [2]:
Is to run that giant heap of probably not sandboxed or security-audited code in every client actually a thing I would want to have? I mean people are paranoid about js doing unwanted things, but a large distribution of tex code running inside the browser, really?
https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX
You just need to standardise it. There's no need to include all of LaTeX in a standard that is just for rendering equations.
For display yes, though it is far larger in scope than that and I wouldn't want to teach someone TeX just for a few formulas, and it is geared for display and not manipulation.
MathML was intended to be just for math type markup so is more concise in that respect, and IIRC was intended to allow automated manipulation in an easy manner (I wouldn't want to do it by hand due to the verbosity of it all, but understanding and manipulating the structure in code must be easier than trying to interpret TeX).
But I agree TeX is easier to write and read if you only care about the look and feel.
You use them like so:
<katex-inline>c = \pm\sqrt{a^2 + b^2}</katex-inline> <script type="application/x-tex">
...TeX code...
</script>
and process it using a javascript TeX-to-DOM processor... seems likely somebody, somewhere, has done that?Update: I just read the rest of the comments and discovered KaTeX.
Having a context-free representation is IMHO a necessity for processing untrusted inputs (e.g. webpages). It also makes it a way faster.
proprietary adjective 1. relating to an owner or ownership.
2.(of a product) marketed under and protected by a registered trade name.
None of the above is true to TeX. What am I missing?
Knuth wrote it using his novel "literate programming" technique in which the source code is embedded in the documentation. Every 4-5 lines of source code has roughly a paragraph of explanation. That source/documentation is published for anyone to read as Knuth's "TeX: The Program" book, accompanied by his "TeXBook", a couple hundred pages each.
That documentation has definitely encouraged all the people reimplementing the TeX layout algorithms, for example MathJax and matplotlib for math layout, as well as a number of alternative tex implementations.
Also, I found "TeXBook" very hard to follow; "The Program" is much more understandable. Every chapter in "TeXBook" starts with a few paragraphs of relatively simply text and then descends into a bunch of additional paragraphs marked with "dangerous turn" signs that talk about things that were never mentioned before. As the author put it, they're explained "somewhere", but it's really hard to find that somewhere.
On the other hand, somewhat like Perl, it is also a language intended from its beginning to be extended. Knuth has said that he never expected things like LaTeX to be built on top of TeX; he rather thought that people would hack directly on the TeX source as necessary.
Ideally, I'd prefer that HTML5 include a <math> tag, or something similar, that takes TeX as input and produces formatted output. A side benefit would mean that every browser, and every system, in the world would have TeX installed!
At least MathJax can take TeX as input.