Skip to content

Instantly share code, notes, and snippets.

@yassu
Created February 16, 2017 13:36
Show Gist options
  • Save yassu/7fe6cbf71214bc0898ea87dc6911789a to your computer and use it in GitHub Desktop.
Save yassu/7fe6cbf71214bc0898ea87dc6911789a to your computer and use it in GitHub Desktop.
simple file for tex project by pyinvoke
from invoke import task
AUTHOR = 'yassu'
MAIN_BASENAME = 'main'
LATEX = 'platex'
DVIP = 'dvipdfmx'
VIEW_PDF = 'evince'
@task
def compile(ctx):
""" コンパイルする """
ctx.run('{} {}'.format(LATEX, MAIN_BASENAME + '.tex'))
ctx.run('{} {}'.format(DVIP, MAIN_BASENAME + '.dvi'))
@task
def comp(ctx):
""" コンパイルする """
compile(ctx)
@task(compile)
def view(ctx):
""" コンパイルして pdfファイルを開く """
ctx.run('{} {}'.format(VIEW_PDF, MAIN_BASENAME + '.pdf'))
def get_junk_filenames():
yield 'x.log'
for filename in (MAIN_BASENAME + ext for ext in (
'.aux', '.dvi', '.log', '.pdf')):
yield filename
@task
def clean(ctx):
""" コンパイル時にできたファイルを削除する """
for filename in get_junk_filenames():
ctx.run('rm {}'.format(filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment