TexProject is a LaTeX project manager that performs basic project templating and also includes other utilities for compiling and exporting your files in a well-defined way.
Jump to:
If you have something like fisher, you can
fisher install alexrutar/tprOtherwise, the function is in functions/tpr.fish and the completions are in completions/tpr.fish and you can just copy them to the relevant folders.
In order to use tpr, you need a few dependencies.
- A working LaTeX distribution which supports
latexmk(such as TeX Live). - git, for managing version control.
- fd, for basic file system management.
If you want to use the tpr init and tpr template commands, you need
- copier, for template management.
If you want to use the tpr remote command, you need:
- The github cli, for managing remote repositories.
- yq, for reading configuration files.
If you want to use the tpr archive --bare command, you may want the following additional dependency.
- arxiv_latex_cleaner, for removal of comments and additional cleaning of export folder.
Visit the linked pages for precise installation instructions.
In order to use tpr, we first need to install some templates.
We can use this preprint template.
Simply run
tpr template install preprint https://github.com/rutar-academic/template-preprintThis installs the template located at the URL https://github.com/rutar-academic/template-preprint under the name preprint.
You can install templates from any valid git URL or a local git repository.
List available templates with tpr template list.
Templates are installed in the directory $XDG_DATA_HOME/tpr/templates.
Now, create a new directory, change to it, and initialize:
mkdir my-project
cd my-project
tpr init preprintThis will copy a number of files to the current directory and initialize a git repository.
To build a PDF file from the project, run
tpr compile out.pdfThis generates a file out.pdf in the current directory by compiling the file <main>.tex specified by <main>.tex.latexmain.
The compilation may take a while since it ignores any intermediate files already in the folder.
To export the project, run
tpr archive out.tar.gzto create an archive file out.tar.gz.
You can include additional files in the archive with -I and strip unnecessary comments and unneeded files with --bare.
For example, to prepare files for submission to arXiv, one might run
tpr archive --bare -I bbl arxiv.tar.gzRun
tpr --helpor
tpr $subcommand --helpfor more information.
Some commands, such as tpr compile or tpr archive, take an optional COMMIT argument.
This can be any git tree-ish reference, as accepted by git archive.
For instance, if you have a tag v0.1, you can run
tpr archive out.tar.gz v0.1to create an export using the v0.1 tag.
It is often useful to visualize changes between two versions of a .tex file.
A convenient tool for doing this is the latexdiff script.
The tpr diff tool provides a wrapper around latexdiff to automatically generate the diff file and compile it.
For example
tpr diff diff.pdf HEAD~3creates a file diff.pdf showing the changes made between HEAD~3 and HEAD.
Note that the file diff.pdf is compiled against the project files in HEAD.
This may cause compilation issues if there are substantial changes in other project files.
You can create remote repositories on GitHub using the tpr remote subcommand.
Simply run with
tpr remote username/repoto create a private GitHub repository at https://github.com/username/repo.
Note that tpr remote reads some default settings from $XDG_CONFIG_HOME/tpr/config.toml.
You can update all existing templates with
tpr template updateUninstall template $name with
tpr template uninstall $nameTemplates for tpr are managed using copier.
A valid template is any copier template that contains a file at the root <main>.tex as well as an empty file <main>.tex.latexmain.
Of course, <main> can be anything you would like: the .latexmain file is used to determine the main TeX file in the current directory.
You can view my preprint template for some quick-start information, and otherwise read the copier documentation for more detail.
It is recommended that you include a reasonable .gitignore file which includes some common ignores for .tex files.
The GitHub TeX Gitignore is a good starting point.