Skip to content

Instantly share code, notes, and snippets.

@avonmoll
Last active February 1, 2017 18:47
Show Gist options
  • Save avonmoll/852e6f1ffc6ffd0d58c82ca72cf1dc4c to your computer and use it in GitHub Desktop.
Save avonmoll/852e6f1ffc6ffd0d58c82ca72cf1dc4c to your computer and use it in GitHub Desktop.
LaTeX grunt Workflow

For compiling LaTeX documents using grunt.

Requirements

  • Node.js and npm
  • LaTeX distribution

Installation

  1. Download and extract this gist
  2. Run npm install in the gist's folder
  3. Modify file variable and cmd in the Gruntfile as necessary
    • pdflatex is used here, but you can use whatever build string you like
  4. Place LaTeX working document in this folder

Usage

  • Run grunt
  • Edit source document, save, ✨

Modification Ideas

  • watch ALL LaTeX files for the case of \includeing multiple subdocuments
var grunt = require('grunt');
module.exports = function(grunt) {
var file = 'source';
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
exec: {
compile: {
cmd: [
`pdflatex --halt-on-error --interaction=batchmode --aux-directory=build ${file}.tex`,
`biber.exe --input-directory=build --output-directory=build ${file}`,
`pdflatex --interaction=batchmode --aux-directory=build ${file}.tex`
].join('&&')
},
options: {
// shell: 'git-bash'
}
},
watch: {
files: [`${file}.tex`],
tasks: ['exec']
}
});
grunt.registerTask('default', ['watch']);
};
{
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-watch": "^1.0.0",
"grunt-exec": "^1.0.1",
"load-grunt-tasks": "^3.5.2"
},
"author": "Alex Von Moll",
"license": "ISC"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment