Package: preprint
Tools for preparing astrophysics papers.Preprint lets you automatically compile, typeset document differences and package the manuscript for publication.Installation requirescliff, thewatchdogpackage, theGitPython >=0.3package, and a recent version of setuptools.
Preprint also works well withlatexmkfor compiling latex, andvcfor adding version control meta data to compiled documents.To install from PyPI:pip install preprintOr to install from source, check the code out and run:python setup.py installAfter installing, trypreprint--helpfor more info.Preprint currently supports the following commands (see below for a reference):preprint maketo do a one-off compilation of the paper,preprint watchto automatically compile the paper if source is changed,preprint diffto runlatexdiffagainst a commit in Git,preprint packto package the document for journals or the arXiv.preprint initto setup your project withpreprint.jsonconfigurations.Check theGitHub Issuesto submit additional ideas.A taste of preprintPreprint is pretty easy to use.
Here’s a few commands to give a flavour of what it can do:preprint init  # this is all the setup you need
preprint make  # compiles the doc according to your compile command
preprint watch --diff 8a42f2b  # live-updating latex diff against git history
preprint pack my_paper --style arxiv  # pack it up for arXiv submissionConfiguration System / preprint.jsonpreprintconfigurations are determined from (in order of increasing precedence): internal defaults, a project-specific JSON file, and command line arguments.To create apreprint.jsonconfiguration file for your project, from your paper’s directory simply run:preprint initIt will automatically find the root latex file for your paper.
You can openpreprint.jsonto take a look at its format and modify the configurations further.
Here is an example of its format:{
    "master": "paper.tex",
    "exts": ["tex", "pdf", "eps"],
    "cmd": "latexmk -f -pdf -bibtex-cond {master}"
}If set inpreprint.json, any command line setting of the same name does not need to repeated.List of Configurationsmaster(type: string) Name of latex document to be compiled (or the root latex document containingdocumentclass).
Defaults to'article.tex', butpreprint initwill set this for you.exts(type: list of strings) List of file extensions used by thewatchcommand.
If any file with this extension in changed in the project, a compile will be triggered bypreprint watch.
This setting is also used bypreprint packto figure out your preferences for figure file types.
For example,["tex", "pdf", "eps"]will try to includepdffigures before falling back toepsfiles, while["tex", "eps", "pdf"]will have the opposite behavior.
Defaults to["tex", "pdf", "eps"].cmd(type: string) The command to run when making a document.
This is used bypreprint makeandpreprint watch(preprint diffandpreprint watch--diffwill always use latexmk).
The command string can include{master}to interpolate the path of the master tex file.
Defaults to"latexmk-f-pdf-bibtex-cond{master}".Command Referenceinitpreprint initwill create a defaultpreprint.jsonconfiguration file for your project.Usage:preprint initAfter running, take a look atpreprint.jsonto edit the configurations.
See‘Configuration System / preprint.json’(above) for more information.makepreprint makewill perform a one-off compilation of your paper.Usage:preprint [--master MASTER] make [--cmd CMD]

Optional arguments:
--master   Name of the root LaTeX file (eg, paper.tex)
--cmd      Name of command to run when a change occursIfpreprint.jsonis setup, you can just run:preprint makewatchpreprint watchwill automatically compile your paper if a TeX or graphics source file is changed.Usage:preprint [--master MASTER] watch [--exts EXT1, ..., EXTN; --cmd CMD; --diff [SHA]]

Optional arguments:
--master   Name of the root LaTeX file (eg, paper.tex)
--exts     List of file extensions (defaults to `pdf eps tex`)
--cmd      Name of command to run when a change occurs
--diff     Run a latexdiff compile against the given commit SHA from the git repository (HEAD if blank).For example, to continuously compile the document whenever.texor figures have changed, and assuming you’ve setup apreprint.jsonfile with the name of your master document, just run:preprint watchTo continuously run a latexdiff-based compile, showing all changes you’ve made against the HEAD of the git repository, run:preprint watch --diffThe document will be saved tobuild/PAPER_NAME_diff.pdf.
This is a nice way of keeping track of what you’re doing.Finally, to continuously run a latexdiff-based compile against an arbitrary commit in your git history, just copy the commit SHA fragment (say,b91688d) and run:preprint watch --diff b91688ddiffpreprint diffwill typeset the document with revisions highlighted between the currently checked-out version, and a previous git commit.
This command is powered by thelatexdiff(which is probably installed with your tex distribution).
The command also requireslatexmkto compile the difference document.
This command is compatible with documents that use\input{}to combine text documents; in fact, included documents are inlined recursively.preprint diffwas inspired bythis blog postby Andy Casey.Usage:preprint [--master MASTER] diff PREV_SHA [-n NAME]

Arguments:
PREV_SHA   A SHA fragment or tag name pointing to the previous revision.

Optional arguments:
--master   Name of the root LaTeX file (eg, paper.tex)
-n         Output name of the difference document (eg. diff.tex)packpreprint packprepares a preprint for submission to a journal.
This pipeline includes:Creating a build directory and copying over just the required manuscript files,Inlining all inputted latex files (either with\input{}or\InputIfFileExistssyntax),Copying the.bblbibliography or inlining it into the manuscript, as necessary.Moving figures to the root directory and updating tex source,Deleting comments; don’t be a tweet on @OverheardOnAph,Renaming figures to conform to AASTeX if necessary,Making JPEG versions of figures to to fulfill arXiv file size requirements, if necessary. This requiresimagemagick.This command is inspired by Erik Tollerud’sAstropysics package, but is designed around regular expressions for text transformation.
The implementation should thus be easier.Usage:preprint [--master MASTER] pack NAME [--style STYLE; --exts EXT1, ..., EXTN]

Arguments:
NAME   Name of the build. Products copied to build/NAME directory.

Optional arguments:
--master   Name of the root LaTeX file (eg, paper.tex)
--exts     File format priority for figures (e.g., ``eps, pdf``)
--style    Style for the build (default is ``aastex``, can also be ``arxiv``).
--maxsize  Maximum size of figure in MB before compressing into jpg (for
           ``arxiv``). Default is 2.5 MB.Note that the--extsoption can be used to prefer a certain file format for the build if you maintain both EPS and PDF figure sets.
For example, to generate a manuscript for a AAS journal, run:preprint pack my_aas_build --style aastex --exts epsAnd to build for the arxiv, where PDF figures are preferred, run:preprint pack my_arxiv_build --style arxiv --exts pdfAboutPreprint is developed on GitHub.
Contributions and suggestions are welcome;
readthe CONTRIBUTING guidelinesfor instructions on how to help.Copyright 2014 Jonathan Sick, @jonathansickLicensed BSD.