Is there a BNF grammar of the TeX language? (2010)
tex.stackexchange.com
tex.stackexchange.com
TeX the language is the prime example of gatekeeping.
OTOH, no one has ever succeeded in creating and popularizing a context-free language that compiles to TeX.
FTFY. If you learn TeX from Knuth’s TeX book, along with the typographical concepts it works with, the error messages generated by documents written in raw TeX are understandable.
LaTeX on the other hand is what the metaprogramming-heavy Boost/STL libraries are to C or C++. Abandon all hope.
https://visualmatheditor.equatheque.net/doc/texbook.pdf
+1 on this.
That book is fantastic, one of my favorites. It's been a couple of years since I last read it, and your comment reminded me that I should probably skim again.
% This manual is copyright (C) 1984 by the American Mathematical Society.
% All rights are reserved!
% The file is distributed only for people to see its examples of TeX input,
% not for use in the preparation of books like The TeXbook.
% Permission for any other use of this file must be obtained in writing
% from the copyright holder and also from the publisher (Addison-Wesley).
\loop\iftrue
\errmessage{This manual is copyrighted and should not be TeXed}\repeat
If you want a free PDF on TeX try _TeX for the Impatient_:https://tug.ctan.org/info/impatient/book.pdf
If you want a copy of _The TeXbook_, buy it.
That said, even with these restrictions, writing a good lexer/parser of a LaTeX-like syntax is still a challenge (and made all the slower by the needs to earn money, spend time with my kids and have other joys in life).
You hit the nail on the head. Brilliant design of the typesetting system, not an ergonomic language.
I think over the next few years Scroll (https://scroll.pub/) will become the language all academics use to publish papers.(Or another markdown like alternative, but ours will be _very_, _very_ good)
You are always in an ergonomic, simple, fun, forgiving high level language (Scroll), but then you can dip down into TeX whenever you want for its beautiful 2D math rendering (thanks to KaTeX library).
We don't have great automatic whole document PDF generation yet (you still have to manually save as PDF from your web browser), but we will get there.
If anyone really wants this please shoot me an email--fun to get more passionate beta users that can help us steer priorities and build something free and great for paper writers all across the globe.
Zerodha had a great article [2] how they migrated from LaTeX based pdf generation to Typst, which ended up saving time and compute.
[1]: https://typst.app/ [2]: https://zerodha.tech/blog/1-5-million-pdfs-in-25-minutes/
The language itself is horrible and the skill floor is too high but the Turing completeness enables a ton of wacky features that would never be allowed in something like Mathematica.
Still, multiple parsers and great tooling exist for C++, and the error messages have gotten much better in recent years. This is probably because companies needed them for different reasons, and they have the resources to build alternatives.
A friend, although he is a good mathematician, kept criticizing TeX, so I explained one view of it: TeX was not intended to be some new big steps forward in interactive user interface, to replace Microsoft's Word, HTML or Mathematica, or for making images or movies. Instead, TeX was, first, for something he knew well -- the journal of the AMS (American Mathematical Society). For doing the word processing for the AMS, TeX was a nice step forward from what went before.
TeX seems fine to me, just the way it is. Started with Knuth's book and also got his file of TeX source his book. The book is easier to read, but with my favorite text editor KEDIT sometimes the file is easier to search.
Also with the TeX software have the Windows program to display the formatted output on a screen and the program to write the output to a PDF file. Both work fine.
It appears that Knuth made commendable efforts to get any bugs out of TeX.
Wrote some macros for TeX: The main collection has, just checked, 86 macros. Also have macros for some special purposes, e.g., foils, inserting images, verbatim, business cards, etc.
Use TeX for business letters; used TeX for the last paper I published: The paper had a lot of tricky math notation, and TeX handled that well. The journal seemed quite pleased to get the TeX input with my macros; then they were able to format the paper right away.
When rusty with TeX, my old papers, letters, etc. and macro collections get me productive again quickly.
Since I like TeX so much and since the philosophy of LaTeX seems different, never used LaTeX.
Knuth's book shows that it's possible to write long documents with TeX.
_TeX: The Program_
and
_METAFONT: The Program_
I've found that LP allows me to be successful working on projects which are more complex and of greater length than other tools allow me to --- worst case is I find myself reading through a nicely typeset hyperlinked PDF until I understand the code I need to modify and am then able to control/command click to go right to it in the editor.
I've been trying to put together a list of Literate Programs published as books:
https://www.goodreads.com/review/list/21394355-william-adams...
I wish that there were more standard tools for it --- it kills me that I couldn't find a nice .layout for doing Literate Programming in LyX w/ arbitrary programming languages.
I'm just glad that my using this system lets me overcome hurdles/complexity beyond levels which previously posed insurmountable stumbling blocks --- at a previous job there was a typesetting back-end for phone book ads which I had written in LaTeX using a documented TeX file (.dtx) --- once a year or so they would sell a license to a new customer and I would have to update it to their needs, and every quarter or so there would be a bug report... being able to read through the code would quickly get me in a place where I could fix things and then move on to the next task.
Current effort is at:
https://github.com/WillAdams/gcodepreview
At some point in time I need to look into if using Lua would allow some niceties such as per-file line # tracking...
If you like deep dives, I suggest two follow-up tools for mathematical typesetting:
1. LuaTeX, which is TeX + Lua scripting support. (luatex.org) An example:
https://tex.stackexchange.com/questions/70/what-is-a-simple-...
This has become my default, and I enjoy it. (I use lualatex.)
2. A friend of mine was inspired to write a modern macOS app for math typesetting. It's called MadHat:
One of the coolest features is "no compilation," which I view as a slight exaggeration, but what's true is that it can work quickly and incrementally so you don't have a compile-and-wait cycle, even on long documents.
Sort of a supercharged version of Lisp reader macros.
The above sentence can be a Forth program. This? Another Forth program.
What does my post do? Run it to find out!
> OK
https://en.wikipedia.org/wiki/Racket_(programming_language)#...