# Write TeX Engine

What do I required if I want to write a TeX engine.

Now I am reading The TeXBook, when I finished, I will read source2e next. Thus I am pretty curious about how to write a TeX engine myself, and what knowledge do I need to know.

SinceI am an undergraduate student, there will be many opportunities to get in touch with TeX in the future, so this is not an eagerness to achieve.

• In TeXLive, there are source2e.pdf and source3.pdf. – Iydon Nov 17 '18 at 9:23
• You probably mean a TeX format rather than engine. – egreg Nov 17 '18 at 9:28

Just to clarify: A TeX engine (like pdftex, xetex, luatex) compiles TeX code. Hence, reading source2e (or source3) won't show you anything you could not have learned in the TeX Book. Basically, you only need to understand the primitives and TeX's algorithms, everything else should be handled by the format (like LaTeX).

If you want to write your own TeX engine and call it a TeX engine you are required to pass the trip test and implement all the basic algorithms used in TeX (the program). This may be extended by new primitives for Unicode input (like in XeTeX, LuaTeX and others) and support of more features. Please note that reproducing this level of optimized code already is quite a large amount of work.

Furthermore, you might be interested in projects like NTS or ExTeX which have tried to write a completely different TeX engine (in Java). They have never reached a stable state to take over a userbase from other engines.

So just to answer your question: You need to know about TeX's primitives and internal workings (which you may find documented in the WEB code of TeX and the TeX code).

A comment (personal view): If you are an undergraduate student and want to understand TeX more in depth, try writing your own format first (working with primitives).

• Thank you very much! There's a still long way to go. Maybe you will find another (unstable) TeX engine after a few years :P – Iydon Nov 17 '18 at 14:54