------------------------------------------------------------------------ Convert Chicago bibliographic style to sequential numbers ------------------------------------------------------------------------ The standard bibliographic style for astronomy is that specified by the "Chicago Manual of Style" (Hale 1910). Other examples: Hale & Zwicky (1930) or Kulkarni et al. (2010). At the end of the paper the references are listed alphabetically. This style is not prone to error but it does not make for good reading (distracting the reader from the message) and also takes up space. In contrast, the style favored by magazines like Nature is to assign an Arabic number to each reference (as a superscript) which increases with every new reference. This "Nature" style is compact and far less distracting to the reader. However, this style is prone to errors and also fragile (as in that adding a new reference will require revising the index of all references that follow the newly inserted reference). LaTeX has powerful "bibtex" features which allow for robust implementation of Nature style. However, I find it cumbersome to use bibtex for proposals. My preferred approach is to use an abbreviated Chicago style as in [EB17], [BR+12] or [Z34]. Before submitting the proposal I change these references to Arabic numerals. It would be helpful to have a map of references (abbreviated Chicago style) and Arabic numbers (in the order the references were inserted). This table can be built up manually (which is what I have done in the past). SOLUTION: First list the references (in any order) in a separate file. You may find convenient to list references alphabetically File: refs.tex [BR+12] J. S. Bloom et al., PASP 124, 1175 (2012) \\ [BF+87] B. J. Boyle et al., MNRAS 227, 717 (1987) \\ [CK+15] Y. Cao et al., Nature 521, 328 (2015) \\ [CS+14] A. M. Cody et al., AJ 147, 82 (2014) \\ [CB+12] S. B. Cenko et al., MNRAS 420, 2684 (2012) \\ [CK+13] S. B. Cenko et al., ApJ 769, 130 (2013) \\ [CU+15] S. B. Cenko et al., ApJ 803, 24 (2015) \\ [EB17] E. Bellm \&\ S. Kulkarni, Nat.\ Astron.\ 1, 71 (2017) \\ [GA+14] A. Gal-Yam et al., Nature 508, 471 (2014) \\ [HL+15] Z-Y Huo et al., RAA 15, 1438 (2013) \\ [NS+11] P. Nugent et al., Nature 480, 344 (2011) \\ [TB+13] S. Tang et al., ApJ 767, 23 (2013) \\ Say my input file is "Kulkarni2017B.tex" (my Keck proposal). NOTE: every reference should be listed separately. Thus [EB12,GA+14] is not valid. Instead, it has to be [EB12],[GA+14]. First we need to extract the list of abbreviated references. It is convenient to use extended regular expressions (whence "grep -E"). We are also interested in the matched expression (when "grep -o"). $ grep -E -o '\[[A-Z][A-Z]?\+?[0-9][0-9]\]' Kulkarni2017B.tex [EB17] [BR+12] [CB+12] [CK+13] [CU+15] [GA+14] [NS+11] [CK+15] [CS+14] [HL+15] [TB+13] [BF+87] [EB17] [TB+13] [BF+87] [CK+15] However, as you can see some references are used more than once (e.g. [EB17]) and so we need to remove all -subsequent- ocurrences. Thus one cannot use "sort" or "uniq" (since these utilities sort the input list). Thanks to associative nature of awk arrays the desired action can be done with very little typing $ grep -E -o '\[[A-Z][A-Z]?\+?[0-9][0-9]\]' Kulkarni2017B.tex | awk '!a[$0]++' [EB17] [BR+12] [CB+12] [CK+13] [CU+15] [GA+14] [NS+11] [CK+15] [CS+14] [HL+15] [TB+13] [BF+87] Now it would be nice to have a table to map these references to numbers. So we simply pipe the output to "nl". $ grep -E -o '\[[A-Z][A-Z]?\+?[0-9][0-9]\]' Kulkarni2017B.tex | awk '!a[$0]++' | nl > UniqueRefs $ cat UniqueRefs 1 [EB17] 2 [BR+12] 3 [CB+12] 4 [CK+13] 5 [CU+15] 6 [GA+14] 7 [NS+11] 8 [CK+15] 9 [CS+14] 10 [HL+15] 11 [TB+13] 12 [BF+87] Now we need to reorder file "refs.tex" in the fashion of file "UniqueRefs". Thus we need to combine these two files using the abbreviated Chicago reference as the key. In UNIX to "join" on a key the input files have to be sorted. So we sort each file using the Chicago references as the key $ sort refs.tex > refs_sorted.tex #column 1 is default $ cat refs_sorted.tex [BF+87] B. J. Boyle et al., MNRAS 227, 717 (1987) \\ [BR+12] J. S. Bloom et al., PASP 124, 1175 (2012) \\ [CB+12] S. B. Cenko et al., MNRAS 420, 2684 (2012) \\ [CK+13] S. B. Cenko et al., ApJ 769, 130 (2013) \\ [CK+15] Y. Cao et al., Nature 521, 328 (2015) \\ [CS+14] A. M. Cody et al., AJ 147, 82 (2014) \\ [CU+15] S. B. Cenko et al., ApJ 803, 24 (2015) \\ [EB17] E. Bellm \&\ S. Kulkarni, Nat.\ Astron.\ 1, 71 (2017) \\ [GA+14] A. Gal-Yam et al., Nature 508, 471 (2014) \\ [HL+15] Z-Y Huo et al., RAA 15, 1438 (2013) \\ [NS+11] P. Nugent et al., Nature 480, 344 (2011) \\ [TB+13] S. Tang et al., ApJ 767, 23 (2013) \\ $ sort -k 2 UniqueRefs > UniqueRefs_sorted #sort on column 2 $ cat UniqueRefs_sorted 12 [BF+87] 2 [BR+12] 3 [CB+12] 4 [CK+13] 8 [CK+15] 9 [CS+14] 5 [CU+15] 1 [EB17] 6 [GA+14] 10 [HL+15] 7 [NS+11] 11 [TB+13] Now we join column 2 of file "refs_sorted" and column 1 of file "UniqueRefs_sorted" $ join -1 2 -2 1 UniqueRefs_sorted refs_sorted.tex [BF+87] 12 B. J. Boyle et al., MNRAS 227, 717 (1987) \\ [BR+12] 2 J. S. Bloom et al., PASP 124, 1175 (2012) \\ [CB+12] 3 S. B. Cenko et al., MNRAS 420, 2684 (2012) \\ [CK+13] 4 S. B. Cenko et al., ApJ 769, 130 (2013) \\ [CK+15] 8 Y. Cao et al., Nature 521, 328 (2015) \\ [CS+14] 9 A. M. Cody et al., AJ 147, 82 (2014) \\ [CU+15] 5 S. B. Cenko et al., ApJ 803, 24 (2015) \\ [EB17] 1 E. Bellm \&\ S. Kulkarni, Nat.\ Astron.\ 1, 71 (2017) \\ [GA+14] 6 A. Gal-Yam et al., Nature 508, 471 (2014) \\ [HL+15] 10 Z-Y Huo et al., RAA 15, 1438 (2013) \\ [NS+11] 7 P. Nugent et al., Nature 480, 344 (2011) \\ [TB+13] 11 S. Tang et al., ApJ 767, 23 (2013) \\ We have now merged the files on a common key (references) but we need to order the file by the Arabic number index. $ join -1 2 -2 1 UniqueRefs_sorted refs_sorted.tex | sort -k 2 -n [EB17] 1 E. Bellm \&\ S. Kulkarni, Nat.\ Astron.\ 1, 71 (2017) \\ [BR+12] 2 J. S. Bloom et al., PASP 124, 1175 (2012) \\ [CB+12] 3 S. B. Cenko et al., MNRAS 420, 2684 (2012) \\ [CK+13] 4 S. B. Cenko et al., ApJ 769, 130 (2013) \\ [CU+15] 5 S. B. Cenko et al., ApJ 803, 24 (2015) \\ [GA+14] 6 A. Gal-Yam et al., Nature 508, 471 (2014) \\ [NS+11] 7 P. Nugent et al., Nature 480, 344 (2011) \\ [CK+15] 8 Y. Cao et al., Nature 521, 328 (2015) \\ [CS+14] 9 A. M. Cody et al., AJ 147, 82 (2014) \\ [HL+15] 10 Z-Y Huo et al., RAA 15, 1438 (2013) \\ [TB+13] 11 S. Tang et al., ApJ 767, 23 (2013) \\ [BF+87] 12 B. J. Boyle et al., MNRAS 227, 717 (1987) \\ At this point it is useful to do a sanity check -- search for "[" in the proposal file and verify that the sequence above is correct. However, a better output is obtained as follows $ join -1 2 -2 1 UniqueRefs_sorted refs_sorted.tex | sort -k 2 -n | awk '{a=$1;$1="";print $0, "%", a}' 1 E. Bellm \&\ S. Kulkarni, Nat.\ Astron.\ 1, 71 (2017) \\ % [EB17] 2 J. S. Bloom et al., PASP 124, 1175 (2012) \\ % [BR+12] 3 S. B. Cenko et al., MNRAS 420, 2684 (2012) \\ % [CB+12] 4 S. B. Cenko et al., ApJ 769, 130 (2013) \\ % [CK+13] 5 S. B. Cenko et al., ApJ 803, 24 (2015) \\ % [CU+15] 6 A. Gal-Yam et al., Nature 508, 471 (2014) \\ % [GA+14] 7 P. Nugent et al., Nature 480, 344 (2011) \\ % [NS+11] 8 Y. Cao et al., Nature 521, 328 (2015) \\ % [CK+15] 9 A. M. Cody et al., AJ 147, 82 (2014) \\ % [CS+14] 10 Z-Y Huo et al., RAA 15, 1438 (2013) \\ % [HL+15] 11 S. Tang et al., ApJ 767, 23 (2013) \\ % [TB+13] 12 B. J. Boyle et al., MNRAS 227, 717 (1987) \\ % [BF+87] !Voila! -------------------------------------------------------------------------- Finally, you can avoid creating the intermediate files by taking advantage that UNIX treats the sub-shells as files! THUS YOU CAN ACCOMPLISH THIS ENTIRE EXERCISE WITH TWO COMMANDS $ grep -E -o '\[[A-Z][A-Z]?\+?[0-9][0-9]\]' Kulkarni2017B.tex | awk '!a[$0]++' | nl > UniqueRefs $ gjoin -1 2 -2 1 <(sort -k 2 UniqueRefs) <(sort refs.tex) | sort -k 2 -n | awk '{a=$1;$1="";print $0, "%", a}' [Note: this sub-shell feature does not work with BSD join and requires GNU join, when “gjoin”].