A LuaLaTeX Template with Subfiles Package
- The text is written in sub
.texfiles. - Automatic generation of main and sub
.texfiles - Automatic loads of sub
.texfiles by usingluacode* -
\usepackagedirectives organized insty/*.sty - Single-file mode for small documents (
make <class>-single) - Optional auto-compile hook for Claude Code (
make claude-hook)
.
├── LICENSE
├── Makefile
├── README.md
├── claude
│ ├── compile-latex.sh
│ └── settings.hooks.json
├── assets
│ └── fig
│ ├── claude_ai_logo.{pdf,svg}
│ ├── codex_icon.{pdf,svg}
│ └── codex_logo.{pdf,svg}
├── generate.sh
├── parts
│ └── sub
│ ├── article.tex
│ ├── beamer.tex
│ ├── book.tex
│ ├── report.tex
│ └── revtex.tex
├── sty
│ ├── beamer.sty
│ └── common.sty
└── utility
├── core.lua
├── figure.lua
└── load.lua
generate.sh: use for generatingmain.texinMakefileassets/fig/*: reusable figures copied intofig/bymake <class>claude/*: Claude Code auto-compile hook, installed on demand bymake claude-hookparts/sub/*: use for generating sub.texfiles inMakefilesty/common.sty:\usepackageshared by all classessty/beamer.sty:\usepackage, theme, and environments for thebeamerclassutility/*: utility Lua codes
For beamer, the generated title slide calls \aiassistcredit, which places
the Created with Claude and Codex credit and logos in the lower-right corner.
make articleFor a small document, generate a single-file version (no sub/, write directly
in main.tex). This works for any class, e.g. make beamer-single:
make article-single\title{}
\author{}
\date{\today}2.2 Please edit sub/* as you like (subfiles version), or write directly in main.tex (single-file version).
makeor
latexmkThe generated main.pdf is at cache/main.pdf
Remove build artifacts (cache/ and stray main.* outputs), keeping your document:
make cleanRemove every generated file and return to the pristine template state.
Warning: this deletes main.tex, main.bib, sub/ and fig/.
make distclean-
Basic
book.clsarticle.clsreport.cls
-
Slide
beamer.cls
-
REVTeX
revtex4-2.cls
-
Japanese
ltjsbook.clsltjsarticle.clsltjsreport.cls
If you edit .tex files with Claude Code,
install the auto-compile hook once so the PDF rebuilds after every edit:
make claude-hookThis copies a PostToolUse hook into .claude/, which is git-ignored and local
to your working copy — other users and editors are unaffected. Requires jq and
latexmk.
Run it once per clone: it is independent of make <class> and is kept by
make distclean, so it never needs to be re-installed.
.
├── fig
├── main.bib
├── main.tex
├── sty
│ ├── beamer.sty
│ └── common.sty
├── sub
│ └── part1
│ ├── section0.tex
│ ├── section1.tex
│ ├── section10.tex
│ ├── section2.tex
│ ├── section3.tex
│ ├── section4.tex
│ ├── section5.tex
│ ├── section6.tex
│ ├── section7.tex
│ ├── section8.tex
│ └── section9.tex
└── utility
├── core.lua
├── figure.lua
└── load.lua
main.tex
\documentclass[11pt, a4paper]{article}
\usepackage{./sty/common}
\begin{luacode*}
local core = require("./utility/core")
local figure = require("./utility/figure")
\end{luacode*}
\graphicspath{{./fig/}}
\begin{document}
\title{}
\author{}
\date{\today}
\maketitle
\tableofcontents
\begin{luacode*}
local load = require("./utility/load")
local subfile = load.SubFile:new("sub", 0, 10)
subfile:article()
\end{luacode*}
\bibliography{main}
\bibliographystyle{unsrt}
\end{document}sub/part1/section0.tex
\documentclass[../../main]{subfiles}
\begin{document}
\end{document}make <class>-single generates only main.tex (no sub/ directory). The
subfile-loading luacode* block is replaced by a placeholder where you write
the body directly:
\begin{document}
\title{}
\author{}
\date{\today}
\maketitle
\tableofcontents
% Write your content here.
\bibliography{main}
\bibliographystyle{unsrt}
\end{document}This project is licensed under the MIT License - see the LICENSE file for details.