# SJTUThesis: the Shanghai Jiao Tong University LaTeX thesis template

> SJTUThesis is the user-facing example document for the SJTUTeX document class, maintained by the SJTUG student group. It handles the formatting rules of an SJTU degree thesis so you can write content instead of preamble, but it tracks the newest TeX distribution and only the latest version is maintained.

**sjtug/SJTUThesis** — 上海交通大学 LaTeX 论文模板 | Shanghai Jiao Tong University LaTeX Thesis Template

- Repository: https://github.com/sjtug/SJTUThesis
- Stars: 3,869 · Forks: 792
- Language: TeX
- License: Apache-2.0
- Published: 2026-09-23 · Updated: 2026-09-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/sjtug-sjtuthesis

## What SJTUThesis solves for SJTU thesis writers

A university thesis is mostly a formatting contract: cover page layout, Chinese and English abstracts, a table of contents with the right numbering, chapter styles, bibliography format, and page geometry that the print shop will accept. Writing that contract by hand in LaTeX means reading a specification document and translating every clause into class and package options. SJTUThesis exists so that translation is already done. The README describes it as "a complete implementation" of the SJTUThesis document class, demonstrating formulas, tables, algorithms and references, and says users can write their thesis directly on top of the example document.

The audience is narrow and specific: students at Shanghai Jiao Tong University who are writing an undergraduate, master's or doctoral thesis and who are willing to use LaTeX. It is not a general-purpose thesis class, and it does not try to be. If you are at another university, the formatting decisions baked into the class are the wrong ones for you.

One structural detail matters more than it looks. The repository you clone is the example template; the actual document class lives in a separate project called SJTUTeX, which the README says has been accepted into CTAN. That split means the class is installed like any other TeX package, while the repository gives you the sample document, figures, bibliography and build scripts.

## How the template, the SJTUTeX class and the build scripts fit together

The data flow is the ordinary LaTeX one, with two layers. Your source files live in contents/, references in refs.bib, images in figures/, and main.tex is the entry point that pulls everything together. main.tex loads the SJTUTeX document class, which is not vendored in the repository but resolved from your TeX distribution's package tree. The README states plainly that you need the newest TeX distribution installed and that you should update packages regularly to get the newest SJTUTeX.

Compilation is driven by latexmk. The Makefile sets THESIS = main and passes latexmk the options -time -file-line-error -halt-on-error -interaction=nonstopmode. Because a thesis has a bibliography and cross-references, a single pass is not enough; latexmk handles the repeated runs and the BibTeX or biber step for you. The class itself is meant to be run under XeTeX or LuaTeX, and the README says character encoding is UTF-8 only.

There is also a word count path. The Makefile's wordcount target inspects main.tex, checks whether the document class options contain lang = en, and then calls texcount either with -char-only or with -ch-only, followed by a second texcount -chinese run that reports total words as English words plus Chinese characters. That second number is the one most students actually need, because the school's word count rules treat Chinese characters and English words differently.

## Installing the toolchain and compiling your first PDF

The README does not ship a TeX distribution; it points to a wiki page on installing a TeX distribution and says you must install the newest version, then keep packages updated so SJTUTeX is current. In practice that means a full TeX Live or MiKTeX installation rather than a minimal scheme, because the class and its dependencies come from CTAN. Once the distribution is in place, get the template itself:

```bash
git clone https://github.com/sjtug/SJTUThesis.git
```

The README also lists a mirror at https://mirror.sjtu.edu.cn/git/SJTUThesis.git/ if the GitHub clone is slow. After cloning, the recommended path on Linux and macOS is the bundled Makefile. Running make all invokes latexmk on main.tex and produces main.pdf; expect several compilation passes and a bibliography run before the PDF settles.

```bash
make all
make wordcount
make clean
```

The three targets above build the thesis, print a word count, and delete intermediate files respectively. make cleanall additionally removes main.pdf. On Windows the README offers Compile.bat instead, which can be double-clicked or driven from a command prompt:

```bash
.\Compile.bat thesis
.\Compile.bat wordcount
```

If you would rather not install anything locally, the README links ready-made templates on Overleaf and TeXPage. It also warns that online editors generally default to pdfLaTeX and that you must switch the compiler to XeLaTeX and use a recent TeX distribution. For VS Code, the README says to install the LaTeX Workshop extension and pick the preset recipe latexmk (xelatex), or set latex-workshop.latex.recipe.default to that recipe. TeXstudio works out of the box because the template carries magic comments.

## Where SJTUThesis will fight you

The most consequential limitation is stated in the README itself: the template is updated frequently and only the latest version is maintained. If your thesis is half-written against an older release and a class update changes spacing or a cover page, you either upgrade and re-check your formatting or you pin an old TeX distribution and stop receiving fixes. Neither option is free, and the README's suggested remedy for problems is to try upgrading the template first.

The second constraint is the engine. XeTeX and LuaTeX are supported; pdfLaTeX is not, which is why the README repeatedly tells online-editor users to change the compiler. If your department's submission pipeline or a collaborator's editor is pdfLaTeX-only, this template is the wrong tool, and the mismatch will surface as font and encoding errors rather than a clear message.

Third, the repository is the example document, not the class. A bug in the class is fixed in SJTUTeX, so an issue filed against SJTUThesis may be redirected. The README is explicit about this division and asks contributors who want to change the document class to go to the SJTUTeX repository instead.

Finally, the licence is split. The README says the SJTU logo and name images are copyright Shanghai Jiao Tong University, the sjtutex class files are under the LaTeX Project Public License 1.3c, and the rest of the repository is Apache-2.0. If you fork the template and redistribute it, those three parts carry different obligations, and the university marks carry none of the freedoms the code does.

## SJTUThesis compared with thuthesis and a hand-rolled preamble

The closest comparison people search for is thuthesis, the Tsinghua University thesis template. Both are university-specific LaTeX classes with a long history and both are maintained by student groups rather than by the university administration. The difference is institutional, not technical: each encodes its own school's cover page, heading styles, bibliography conventions and word count rules, and neither is a drop-in substitute for the other. Choosing between them is not a matter of quality; it is a matter of which university will read your PDF.

The more realistic alternative is writing your own preamble on top of ctex and the standard report or book class. That gives you total control and no dependency on a class that changes under you. The cost is that you reimplement the cover page, the abstract environments, the chapter style and the reference format yourself, and you verify each against the current formatting rules. For a student who enjoys LaTeX this is a legitimate path; for most, it is a week of work that SJTUThesis has already done, with the trade-off that you inherit its release cadence.

## Maintenance, releases and what upgrading costs you

The repository is not archived and the most recent push recorded for it is 2026-05-20, so it is being touched. The release history shows v2.3.1 on 2026-03-12, v2.2.1 on 2025-04-02 and v2.1.5 on 2024-11-07: a major-ish bump roughly once a year, with the 2.3 line arriving about eleven months after 2.2. That cadence is slow enough that you should not expect a fix for a formatting edge case within days, and the README's own advice is to search the wiki and the discussions before opening an issue.

Upgrade cost is real but bounded. Because the class comes from CTAN, updating your TeX distribution can change the class version without any action in your repository. That means a thesis that compiled in March can produce a slightly different PDF in September after a package update, and the diff is exactly the kind of thing a formatting check will notice. Pinning a TeX Live release for the duration of your writing is the usual mitigation, at the price of missing later fixes. The RELEASES.md file in the repository is where the project records what changed between versions, and it is worth reading before you bump anything mid-thesis.

On licensing, nothing here requires legal advice to state: Apache-2.0 covers the repository contents, LPPL 1.3c covers the class files, and the SJTU marks remain the university's. If you plan to publish a modified template publicly, keep those three categories separate.

## Conclusion

Adopt SJTUThesis if you are writing a degree thesis at Shanghai Jiao Tong University and can keep a current TeX Live or MiKTeX installation on hand; the Makefile and Compile.bat wrappers plus the Overleaf and TeXPage templates remove most of the setup work. Do not adopt it if you are locked to an old TeX distribution, since the class is pulled from CTAN and the project maintains only the latest version, or if you need pdfLaTeX, because the README states the template is built for XeTeX and LuaTeX. Before you commit, clone the repository, run make all once on your own machine, and confirm that the resulting main.pdf matches the current school formatting rules rather than an older release.

## FAQ

### Can SJTUThesis be used to write a thesis?

Yes. The repository is a complete example implementation of the SJTUThesis document class, and the README says users can write their thesis by referring to it or building directly on the example document.

### How do I install and compile SJTUThesis?

Install the newest TeX distribution first, since the SJTUTeX class is resolved from CTAN, then clone the repository and run make all on Linux or macOS, or .\Compile.bat thesis on Windows. The build uses latexmk and produces main.pdf.

### Does SJTUThesis work on Overleaf?

The README links an Overleaf template that can be used directly, and notes that online editors usually default to pdfLaTeX, so you must switch the compiler to XeLaTeX and use a recent TeX distribution.

### Which TeX engines does SJTUThesis support?

The README states that SJTUThesis supports the XeTeX and LuaTeX engines, and that character encoding is UTF-8 only. pdfLaTeX is not among the supported engines.

### How do I count the words in my SJTUThesis document?

Run make wordcount on Linux or macOS, or .\Compile.bat wordcount on Windows. The Makefile calls texcount and reports either a character count or a Chinese character count depending on the document class language option, plus a combined total of English words and Chinese characters.

### Where should I report a bug in the SJTUThesis document class?

The README separates the two repositories: this one is the user-facing example template, and changes to the document class itself belong in the SJTUTeX repository. General usage questions go to the GitHub discussions first.

## Sources

- [Issues](https://github.com/sjtug/SJTUThesis/issues)
- [License: Apache-2.0](https://github.com/sjtug/SJTUThesis/blob/master/LICENSE)
- [README](https://github.com/sjtug/SJTUThesis/blob/master/README.md)
- [Releases](https://github.com/sjtug/SJTUThesis/releases)
- [sjtug/SJTUThesis on GitHub](https://github.com/sjtug/SJTUThesis)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/sjtug-sjtuthesis
