Skip to content

Instantly share code, notes, and snippets.

@breuderink
Created September 30, 2011 14:16
Show Gist options
  • Save breuderink/1253855 to your computer and use it in GitHub Desktop.
Save breuderink/1253855 to your computer and use it in GitHub Desktop.
Converter for SIKS dissertation list to LaTeX
#!/usr/bin/env python
'''
Quick and dirty hack to get the SIKS dissertation list in LaTeX.
'''
import argparse, re, operator, itertools, sys
parser = argparse.ArgumentParser(
description='Convert SIKS dissertation list to LaTeX.')
parser.add_argument('txt')
parser.add_argument('tex')
parser.add_argument('-n', '--output-lines', type=int, default=100)
args = parser.parse_args()
dissertations = []
with open(args.txt, 'r') as f:
for line in f:
match = re.search(r'\d{4}-\d+', line)
if match:
diss_id = match.group(0)
author = f.next().strip()
title = f.next().strip()
dissertations.append((diss_id, author, title))
sorted_diss = sorted(dissertations, key=operator.itemgetter(0), reverse=True)
with open(args.tex, 'w') as f:
latex_cmd = r'\newcommand{\SIKSdiss}[3]{{\bf #1}\hspace*{1ex}#2, {\it #3.}\\}'
f.write('%s\n\n' % latex_cmd)
for diss in sorted_diss[:args.output_lines]:
f.write('\\SIKSdiss{%s}{%s}{%s}\n' % diss)
@joosbuijs
Copy link

Thank you for writing this! I used it to include the SIKS dissertation list in my thesis and it saved me a lot of work!

One tip: when you use Python 3, change "f.next()" to "f.readline()" on lines 21 and 22.

@fmannhardt
Copy link

fmannhardt commented Jul 27, 2017

Thanks for the work. I updated it to be a bit more flexible:

  • specify a minimum year (currently SKIS does only require the list from 2011 on)
  • added a SIKSyear command

If anyone is interested the updated version is here:
https://gist.github.com/fmannhardt/8fb552ea5a5b635d690960024b8aba07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment