Published on

The workflow for my thesis

Overview

  1. Write thesis body in Pandoc Markdown.
  2. Build latex sources and pdf using Waf build system.
    1. Do with thesis pandoc template file if you need.

Example of wscript

wscript is like Makefile for Waf.

srcdir='.'
blddir='build'

def configure(ctx):
    ctx.load('tex')
    if not ctx.env.LATEX:
        ctx.fatal('The program LaTex is required')


from waflib.Configure import conf
@conf
def mktex(ctx):
    ctx.exec_command('pandoc %s -t latex --template ./pandoc-template.tex -o %s'%('mthesis.markdown', 'mthesis.tex'))

def view_pdf(bld):
    bld.exec_command("open -a Preview \"{0}/mthesis.pdf\"".format(blddir))

def build(bld):
    bld(
            features = 'tex',
            type     = 'xelatex', # pdflatex or xelatex
            source   = 'mthesis.tex', # mandatory, the source
            outs     = 'pdf', # 'pdf' or 'ps pdf'
            deps     = 'crossreferencing.lst', # to give dependencies directly
            prompt   = 1, # 0 for the batch mode
        )
    bld.install_files('${PREFIX}','output_pdf_file.pdf')

Example of 'make'-ing

./waf clean configure mktex build view_pdf

SublimeText2 build system setting

{
  "working_dir": "$filedir",
  "path": "/usr/local/texlive/2011/bin/x86_64-darwin:/usr/bin:/usr/local/bin",
  "cmd": ["./waf", "clean", "mktex", "configure", "build", "view_pdf"]
}

Press Cmd+B (on Mac) will do everything