Hacker News new | ask | show | jobs
by xvilka 49 days ago
I have been using TeX/LaTeX for ages and today same issues hinder the user experience like multiple decades ago - cryptic error messages, complex pipeline, lack of the proper Unicode symbols support out of the box, and so on.

Nowadays, with Typst existing, it's vital for TeX ecosystem to solve these issues, since none of them are present in Typst. Projects like Tectonic would solve this for TeX, but they lack enough hands and (maybe) financial support.

Otherwise, using TeX only makes sense nowadays only if 1) you already have some templates 2) some features are still missing in Typst 3) you are just forced to use TeX/LaTeX for whatever reason.

2 comments

(Disclaimer: I'm on the TeX Live team)

> cryptic error messages

These have somewhat improved recently, but I agree that they're still not great.

> complex pipeline

You can typically just run "latexmk --lualatex <filename.tex>" and your document should compile in a single step.

> lack of the proper Unicode symbols support out of the box

UTF-8 has been the default input encoding since 2018 [0], so character input should mostly just work. Using complex scripts (Arabic, Devanagari, etc.) requires XeLaTeX or LuaLaTeX, but LuaLaTeX is recommended for most documents anyways [1].

Now, you still won't be able to typeset arbitrary characters without any additional setup, but this is because there is no single font that contains all characters, and since mismatched fallback fonts usually looks bad, the (La)TeX developers do not want this to be the default. But

  \usepackage{fontspec}
  \setmainfont{Some Font with your Characters}
should be all that you need in most cases.

> Projects like Tectonic would solve this for TeX

All of these have already been fixed in TeX, except for the error messages, which would be impossible for Tectonic to fix.

(Background: the TeX engines give excellent error messages, and LaTeX gives good error messages for "expected" errors, but unexpected errors usually give a TeX engine error message unrelated to your LaTeX input, since LaTeX is internally implemented on top of TeX engine macros. So much like C++ template errors, it isn't really possible to fix this.)

> Otherwise, using TeX only makes sense nowadays only if

4) If you actually like TeX for some reason like I do :)

[0]: https://www.latex-project.org/news/latex2e-news/ltnews28.pdf...

[1]: https://www.latex-project.org/news/2024/11/01/issue40-of-lat...

I recently had a document break because I used umlauts together with the subfigs package. Apparently both use " characters internally and clash badly. This is not a particularly exotic use case.
Yeah, unfortunately lots of the third-party LaTeX packages are fairly poorly written. Which also applies to most other programming languages, but LaTeX is somewhat unique here since (1) approximately nobody makes money off of TeX, so even "important" packages are often volunteer-maintained, and (2) LaTeX2e has been around since the early 90s, so some of the popular packages have been unmaintained for over 20 years.

The core/official LaTeX code is really quite stable, but it's also very limited, so it's pretty reasonable to conflate it with the LaTeX ecosystem as a whole. But yes, the LaTeX Team is definitely aware of the problems caused by Babel shorthands (which is what " is in German), and they're trying to figure out some way to fix it without breaking other documents.

I'd much prefer bad looking unicode characters to just skipping them and having broken output honestly. This is currently the main reason I'm considering moving from LaTeX to typst -- just always having broken output as I use more unicode (maths symbols, emojis) in my documents.
> I'd much prefer bad looking unicode characters to just skipping them

That is an option that you can enable. If you're only using a few different languages (which is by far the most typical case), it's mostly automatic with Babel (by using "\babelfont"), but if you really want to support everything, you can use something like [0] (which is admittedly rather convoluted).

> just always having broken output as I use more unicode (maths symbols, emojis) in my documents.

Adding "\tracinglostchars=3" anywhere in your document (before the offending character) will turn any missing characters into an error message, and using the "--halt-on-error" command-line flag will make that error fatal. I've talked to the LaTeX Team and they'd really like it if they could make those the default, but they have 40 years of backwards compatibility to deal with. I've also talked to the Overleaf support team, and it's depressingly common for documents to compile with 50+ errors and for users to think that that's completely okay.

LaTeX is fairly similar to C here, because in both cases, the errors are nearly always important, a good document/program should compile with zero errors, yet thousands of old documents/programs do compile with errors and their users complain if you make them fatal by default.

[0]: https://tex.stackexchange.com/a/707031/270600

That's genuinely good to know.

The thing that often hits me nowadays is using pandoc (or pandoc via quarto) to go markdown -> latex -> pdf, which tends to bury these issues (and in markdown it's more tempting to just write emojis / unicode maths symbols.

Why use markdown, because I want good HTML output (which I realise is getting better in latex, but still not as good as markdown -> HTML.

Using LaTeX makes sense because that's what all journals and conferences expect.

I'm writing two books, both in LaTeX.

I really don't get what the problem is.

Using LaTeX is mostly fine, except for the endless compile times, useless error messages, lack of unicode, etc. like the GP said.

I'm maintaining an internally used LaTeX document class and the development experience is even worse. TeX has no concept of such avant-garde ideas like lists, dictionaries, or namespaces. Things break all the time, and sometimes only when you load three specific packages in a specific order because they all patch each other's routines. I still haven't completely groked the idea of fragile commands and expanding macros. Characters can change meaning depending on context, even the `comment` character (%) or the `escape` character (\), (and I believe even the curly braces) for example when used inside `\path{}` or `\url{}` [1]. It makes a difference whether you comment out line endings or not. The LaTeX3 syntax looks like a bad joke. I mean, look at it:

\ExplSyntaxOn \tl_set:Nn \l_tmpa_tl {A} \group_begin: \tl_set:Nn \l_tmpa_tl {B} \par value~inside~group:~\tl_use:N \l_tmpa_tl \group_end: \par value~outside~group:~\tl_use:N \l_tmpa_tl

\tl_set:Nn \l_tmpb_tl {A} \group_begin: \tl_gset:Nn \l_tmpb_tl {B} \par value~inside~group:~\tl_use:N \l_tmpb_tl \group_end: \par value~outside~group:~\tl_use:N \l_tmpb_tl \ExplSyntaxOff

????

Let's just let it retire and focus our efforts on Typst and pushing publishers to accept Typst.

[1] Just look at all these poor souls trying to achieve something as exotic as putting a URL with a percent sign inside a footnote: https://tex.stackexchange.com/questions/12230/getting-percen...

> except for the endless compile times, useless error messages, lack of unicode, etc.

Some of these have been fixed; see my sibling comment [0] for more details.

> TeX has no concept of such avant-garde ideas like lists, dictionaries, or namespaces. […]. The LaTeX3 syntax looks like a bad joke.

But that is in fact the entire purpose of LaTeX3. I agree that the syntax looks intimidating, but it's actually quite nice once you learn it, and it's written that way to provide namespacing in TeX. Similarly, LaTeX3 defines lists, dictionaries, and most other conventional datastructures.

> Things break all the time, and sometimes only when you load three specific packages in a specific order because they all patch each other's routines.

Hmm, well it depends. The LaTeX kernel and the TeX engines are more stable than nearly all other software, but the third-party packages do indeed break occasionally. But you see similar dynamics play out in most other ecosystems: JavaScript the language is incredibly stable and has excellent backwards compatibility, but if you use 50+ third-party packages, then things do indeed break occasionally.

> Characters can change meaning depending on context

Much like operator overloading in other languages, catcode changes in TeX can indeed be misused and are sometimes confusing, but they're also a pretty useful solution to problems that would otherwise be tricky to solve.

All this isn't to say that TeX doesn't have issues—I criticize LaTeX myself fairly frequently—but most of these are due to the fact that LaTeX is 40-year-old software built on a 50-year-old engine, and has remained backwards-compatible with documents throughout that entire time. And La(TeX) is slowly modernizing, so I'm fairly hopeful that things will continue to improve.

[0]: https://news.ycombinator.com/item?id=48515090

Thanks for your insight, much appreciated!

However, regarding this:

> Much like operator overloading in other languages, catcode changes in TeX can indeed be misused and are sometimes confusing, but they're also a pretty useful solution to problems that would otherwise be tricky to solve.

I'm sorry, but I've never seen overloading of such fundamental characters like the comment character or escape character anywhere. Or at least if you use these characters inside a string, it's pretty clear that the string context is special. In LaTeX I have no way of knowing which catcodes a macro has modified without essentially parsing the entire thing, which breaks syntax highlighters and language servers (something that increases quality of life in other languages substantially), because the compile times are prohibitive. The decision to let users redefine %, \ and literally every character seems like a really, really bad idea to me.

Other languages and syntaxes seem to do just fine, so I'm not sure what you mean by tricky to solve.

> most of these are due to the fact that LaTeX is 40-year-old software built on a 50-year-old engine, and has remained backwards-compatible with documents throughout that entire time

I realize that, and I appreciate what LaTeX (and by extension TeX) has done. It's a giant in sciences and the software world, of absolutely critical importance, but still. We learned a lot of lessons about writing software in the last 50 years, and Typst is applying these from the ground up. Unfortunately I don't have a lot of confidence that LaTeX can be modernized.

> I'm sorry, but I've never seen overloading of such fundamental characters like the comment character or escape character anywhere.

I believe that Racket [0], Mathematica [1], Raku [2], and Rust [3] let you assign arbitrary meanings to most symbols, but these are indeed much more restricted than TeX is (and for good reason). But the issue is really more that TeX barely supports lexical scoping, and that it lets you change the global catcodes at any point in the document, since changing the meanings of characters before any code runs or only in the middle of a scope is pretty useful.

> Or at least if you use these characters inside a string, it's pretty clear that the string context is special.

Verbatim is essentially equivalent to strings in other languages, and it mostly works pretty well, aside from the huge problem that it's impossible to nest it or pass it as an argument to most macros.

> In LaTeX I have no way of knowing which catcodes a macro has modified without essentially parsing the entire thing

Agreed, this is pretty annoying, but the only consolation is that most documents don't change their catcodes very often (since it's usually a pretty terrible idea).

> Other languages and syntaxes seem to do just fine, so I'm not sure what you mean by tricky to solve.

Texinfo [4] is what I was mainly thinking of, since that is able to completely redefine TeX's syntax without needing to manually implement parsing itself (which would be the best strategy today, but was less feasible back when computers were much slower). Similarly, active characters are pretty useful (this is how ~ is defined to insert a non-breaking space, and is also useful for faux-Markdown [5]).

> We learned a lot of lessons about writing software in the last 50 years, and Typst is applying these from the ground up.

Yup, I first learned about Typst on the first day that it was released, and even then I thought that it had a good chance of suceeding, since it solved the problems that most users had (bad error messages and slow compile times), whereas the other TeX competitors focused on things like better typesetting quality, better extensibility, or easier programability, which most users don't care about at all.

I would be personally a little disappointed if Typst replaced LaTeX, but until that happens, I definitely hope that it continues to do well.

> Unfortunately I don't have a lot of confidence that LaTeX can be modernized.

There are lots of other non-LaTeX TeX formats that are quite modern (ConTeXt [6] is my personal favourite, but OpTeX [7] is nice too), and even LaTeX itself has improved quite a bit over the last 5 years or so [8]. But yeah, it's modernization process is still much slower than nearly any other piece of software, so I am also worried that this may end up being too little too late.

[0]: https://docs.racket-lang.org/guide/language-get-info.html

[1]: https://reference.wolfram.com/language/Notation/tutorial/Not...

[2]: https://docs.raku.org/language/slangs

[3]: https://doc.rust-lang.org/book/ch20-05-macros.html#function-...

[4]: https://en.wikipedia.org/wiki/Texinfo#Texinfo_source_file

[5]: https://tex.stackexchange.com/a/236457/270600

[6]: https://www.ctan.org/pkg/context

[7]: https://petr.olsak.net/optex/

[8]: https://www.latex-project.org/news/latex2e-news/ltnews.pdf#s...

> I would be personally a little disappointed if Typst replaced LaTeX, but until that happens, I definitely hope that it continues to do well.

I'm curious about why you'd be disappointed. Is it because you think typst is an irremediably inferior technology to you or is it because you are invested in LaTex?

I do not mean to ask this in accusatory way. I'm not very well informed about typst or tex (I've only used typst once and I thought it was easy and nice).

I'm just curious about what is worse about typst that would make someone disappointed if that was the reason why you would be.