# /u/sy/beebe/tex/bib/fmtwords.awk, Wed Oct 6 13:37:23 1993 # Edit by Nelson H. F. Beebe # ======================================================================== # Reformat the output of keywords.awk into input suitable for LaTeX. Each # line from keywords.awk is a tab-separated quadruple of sort key, word, # citation key, and entrytype. The entrytype allows simple selection # of subsets of the output with egrep to create separate address, # author, editor, institution, journal, publisher, and title word # indexes when desired. # # Usage: # biblex foo.bib | \ # gawk -f keywords.awk | \ # egrep 'entrytype$' | \ # gawk -f fmtwords.awk >foo.ltx # # [24-Sep-1994] # ======================================================================== BEGIN { FS = "\t" IGNORECASE = 1 "date" | getline date "hostname" | getline hostname "echo $USER" | getline user print "%%======================================================================" print "%% WARNING: Do NOT edit this file. It was produced automatically" print "%% with the UNIX pipeline" print "%%" print "%% biblex xxx.bib | \\" print "%% gawk -f keywords.awk | \\" print "%% egrep 'entrytype$' | \\" print "%% gawk -f fmtwords.awk >xxx.xwx" print "%%" print "%% by " user "@" hostname " on " date print "%%======================================================================" print "" print "\\ifx \\NAMECITE \\undefined % User can override this definition " print " \\def \\NAMECITE #1#2{{\\bf #1} \\cite{#2}}" print "\\fi" print "" } { gsub(/ +$/, "", $2) # trim trailing space gsub(/\\-/, "", $2) # remove discretionary hyphens sub (/\\$/, "", $2) # remove space command at end of word if (initial != tolower(substr($1,1,1))) { dump_cites() initial = tolower(substr($1,1,1)) print "\n" # two empty lines for readability } if (tolower(sortkey) == tolower($1)) # additional cites for same word { # some bibliographies generate very long citation lists which # eventually overflow TeX's input buffer for .aux file lines. # Too bad that LaTeX doesn't do this line wrapping itself! if (length(citelist) > 2000) { dump_cites() sortkey = $1 word = $2 citelist = "\t\t" $3 } else citelist = citelist ",%\n\t\t" $3 } else # new word { dump_cites() sortkey = $1 word = $2 citelist = "\t\t" $3 } } END \ { dump_cites() } function dump_cites() { if (citelist != "") print "\\NAMECITE{" word "}{%\n" citelist "%\n\t\t}." citelist = "" word = "" sortkey = "" }