This is GitHub copy of the source code of the New Typesetting System, which is a Java reimplementation of Donald Knuth's original version of TeX.
This code was completed in 2001 and actually works! However, for various reasons it was decided not to continue the project (i.e., support more modern flavors of TeX), and there has been no further development on this code since.
This copy exists to:
-
Have a nice way to browse the source code of NTS, especially for those who are thinking of developing new implementations of TeX.
-
Ensure that the code can still be compiled in modern versions of Java so this artifact lives on.
The code was written for Java 2 (aka 1.2) originally. It has been successfully compiled with Java 16, and so should theoretically work for all intermediate versions too.
Compile: From the repo root,
javac -classpath src -d build src/Nts.java
jar --create --file nts.jar --main-class=Nts -C build Nts.class build/nts
The compiled artifact is nts.jar
.
Run: Invoke java -jar nts.jar <tex file>
.
Note that NTS only provides the core TeX execution engine and needs to be combined with
some kind of "TeX format" to product anything meaningful.
A good place to start is Knuth's own plain TeX format;
compiling plain.tex
from that page yields an actual document!
- MacOS:
Install OpenJDK using brew (
brew install java
) and then perform the sym-linking command as described inbrew info java
.
Running the tests is really easy. Because there are no tests, to run the tests you just do nothing.
NTS has a custom open source license with extremely strange clauses around modification. Presumably it was inspired by Donald Knuth's own original "license" for TeX.
The code as hosted here has small modifications versus the original that are fully detailed in the changelog. Specifically,
- The internal layout of the repository has been changed.
- Some warnings issued by recent Java compilers have been resolved by tweaks to the Java code.
- The code was formatted using the Google Java formatter.