Instantly share code, notes, and snippets.

What would you like to do?
LaTeX `\cite{...}` order
#!/usr/bin/env ruby
# Author: Dmitry V. Luciv
# License: WTFPL 2.0
When typing many \bibitem's manually, instead of using BibTeX and friends,
it often becomes a pain to sort the bibliography in case when it should
appear in order of citations.
Use it as `citeorder.rb <my_lovely_article.tex >ordering.txt`
This tool is not unique, but at least is very lightweight.
src =
cites = src.scan /\\cite\{(.+?)\}/m
refs = {|v| v[0].split ','} {|v| v.gsub('%', '').strip}.uniq
refs.each &method(:puts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment