generator-latex-template
generator-latex-template copied to clipboard
Generates latextemplates (e.g., for thesis, workshops, conferences, IEEEtran, LNCS, ...)
LaTeX Template Generator 
Generates latex templates (e.g., for thesis, workshops, conferences, IEEEtran, LNCS, ...) out of "micro-templates"
See the talk about the generator for an overview on the aims and the general concept.
Background information
There are many latex templates out there.
All of them make use of certain packages such as hyperref, listings, or minted.
The packages have to be a) included in the .tex file somehow and b) configured.
Moreover, some packages offer interfaces (such as new commands or new environments) to users.
Minimal examples help to understand how a package works.
The aim of the repository is to provide for each common latex package
- Configuration
- Usage example
and a generation into templates:
- Support for ACM, IEEE, LNCS, KOMA-Script
- Support for separate documents which require
--shell-escapeand not. - Support for integrated pdflatex and lualatex documents
Talks
- Oliver Kopp - The LaTeX Template Generator - TUG 2023 - first international presentation of the generator
- Oliver Kopp - The LaTeX Template Generator - DANTE Herbsttagung 2019 - a talk on the motivation, user experience, and the contribution
Precondition for the generator
One has to install Node.js version 18 (or later) to get this generator running. For simple installation, just head to https://nodejs.org/ and follow the installation instructions.
Using the generator
One can start using the generator directly using the node execution wrapper npx:
npx -p yo -p generator-latex-template -c 'yo latex-template'
Permanent installation (and simpler command line usage)
In case one wants to have the generator installed permanently (or npx does work as expected), one can install generator-latex-template using following command:
npm install -g generator-latex-template
Then, one can invoke the generator as follows:
yo latex-template
How to update the document
⚠️ The template generator overwrites main.tex on each run. This will destroy your work. ⚠️
You can use the magic of git to prevent that:
-
After repository initialization:
git committo save your workgit checkout -b template- to create a branch with initial template (required for updating)git checkout mainswitch back to your thesis
-
Work on the
mainbranch -
In case an update comes in, update the
templatebranchgit checkout template- switch to thetemplatebranchyo latex-template- generate new templategit commit- save the new templategit checkout main- switch to your workgit merge template- merge in the template changes- resolve conflicts ^^ (Hint: IntelliJ Community Edition has a great conflict resolving tool)
Resources
- IEEE - example: paper-conference-minted.tex
- LNCS - example: paper.tex
- scientific-thesis-template - example: latexhints-english.tex
- alpenwasser/TeX
Development roadmap
- [x] Create directory structure
- [ ] Sort in examples from the scientific-thesis-template
- [ ] Have scientific-thesis-template generated completely.
- [x] Have LNCS generated completely.
- [ ] Have uni-stuttgart-dissertation-template generated automatically.
In the long run, the contents of the paper.tex (and similar) files in repositories of the latextemplates organization should be generated automatically.
Development hints
- Templating language: https://ejs.co/
- Conditional questions: https://stackoverflow.com/a/18706640/873282.
- Types of prompts: https://github.com/SBoudrias/Inquirer.js#prompt-types
- E.g., Question
- Add a new question
- Also adapt
__tests__/app.js - Execute tests with
npx jest
- Also adapt
- Update npm dependencies
npx npm-update-all. See FreeCodeCamp for more details.npx npm-check-updates -u. [Source]- See https://github.com/yeoman/generator/releases for changes in the generator.
- Generate
package-lock.jsononly:npm i --package-lock-only
- When one encounters
Cannot find module 'yeoman-generator', please update the npm dependencies. That error occurred when using version4.13.0and5.4.2was available. - In case of the error "Error: EACCES, permission denied '/root/.config/configstore/insight-yo.json'", one needs to execute
chmod g+rwx /root /root/.config /root/.config/configstore - Check GitHub actions
- Use actionlint
- Use vs.code GitHub actions plugin
- Use act for checking:
act --rm --platform ubuntu-latest=fwilhe2/act-runner:latest -W .github/workflows/check-ieee-conference-a4-pdflatex-bibtex-2023-true.yml
- When adding a new package:
- execute
npxwith--generatereitzig(in a clean directory) - run
pdflatex - run
{repository-root}/generate-texlivefile.sh - copy
Texlivefileto the root of the{repository-root}/generators/app/templates - adapt
Texlivefileas required
- execute
Test locally
- Create empty directory ("target directory")
- Change to the target directory
- Run
npx [email protected] <path-to-git-repository> - Windows:
npx [email protected] c:\git-repositories\latextemplates\generator-latex-template
- Note: yo 5.0.0 cannot be used due to yo#797
Linux
Parameters can be set using command line
- lncs:
npx [email protected] /tmp/repo --documentclass=lncs --papersize=a4 --latexcompiler=pdflatex --bibtextool=bibtex --overleaf=false --texlive=2023 --docker=false --lang=en --font=default --listings=listings --enquotes=csquotes --tweakouterquote=babel --todo=pdfcomment --examples=true --howtotext=true
Windows
Parameters can be set using command line
- IEEE template (with pdflatex and bibtex):
npx [email protected] c:\git-repositories\latextemplates\generator-latex-template --documentclass=ieee --ieeevariant=conference --papersize=a4 --latexcompiler=pdflatex --bibtextool=bibtex --overleaf=false --texlive=2023 --docker=reitzig --lang=en --font=default --listings=listings --enquotes=csquotes --tweakouterquote=babel --todo=pdfcomment --examples=true --howtotext=true - LNCS template (with pdflatex and bibtex):
npx [email protected] c:\git-repositories\latextemplates\generator-latex-template --documentclass=lncs ---papersize=a4 --latexcompiler=pdflatex --bibtextool=bibtex --overleaf=false --texlive=2023 --docker=false --lang=en --font=default --listings=listings --enquotes=csquotes --tweakouterquote=babel --todo=pdfcomment --examples=true --howtotext=true - Scientific Thesis Template:
npx [email protected] c:\git-repositories\latextemplates\generator-latex-template --documentclass=scientific-thesis --papersize=a4 --latexcompiler=pdflatex --bibtextool=bibtex --overleaf=false --texlive=2023 --lang=en --font=default --listings=listings --enquotes=csquotes --tweakouterquote=babel --todo=pdfcomment --examples=true --howtotext=true
- Run
latexmkto build the PDF
Useful snippets
<% if (howtotext) { -%>
<% } else { -%>
<% } -%>
<% switch (documentclass) { case "lncs": -%>
<% break; case "ieee": -%>
<% break; default: -%>
<% break; } -%>
Debugging
A launch.json configured for Windows and Visual Studio Code is included.
Just press F5 and the generator should run in debug mode.
ejslint.cmd c:\git-repositories\latextemplates\generator-latex-template\generators\app\templates\main.en.tex
Releasing a new version
-
Update
CHANGELOG.md -
Update
package.json, publish to npmjs, create GitHub release. Use release-it (do not create a release on GitHub) and github-release-from-changelog.npx release-itnpx github-release-from-changelog
License
The code is licensed 0BSD, the snippets (both LaTeX and text) 0BSD, too. See benbalter/talks#15, for a reasoning, why CC0 cannot be used.
generators/app/templates/splncs04nat.bst is taken from tpavlic/splncs04nat and is MIT-licensed.