dorab@hilo.cs.ucla.edu (Dorab Patel) (08/28/90)
before i go off and do it myself, does anyone have a bibtex style for annotated bibliographies? email me and i'll summarize.... thanks 'dorab
dfk@duke.cs.duke.edu (David F. Kotz) (08/29/90)
In article <38398@shemp.CS.UCLA.EDU>, dorab@hilo.cs.ucla.edu (Dorab Patel) writes: > > before i go off and do it myself, does anyone have a bibtex style > for annotated bibliographies? email me and i'll summarize.... > > thanks > > 'dorab This is a combination of a bibtex style that understands keywords "comment", "abstract", and "key", and prints each in a paragraph below the bib entry. It also sorts by cite KEY, instead of author or the like, and prints the cite key instead of the usual number or alpha. This is meant for printing an entire bibtex file (and a shell script is enclosed for that purpose). With some modifications (like not printing the cite key) it could be used for a publishable annotated bibliography. I've also thrown in a shell script that will search a bibtex file for given keywords, looking only in the keyword attributes, and print all entries that match. Thus, if an entry has keyword = "file system, MIMD, parallel computing" You might search for any of these three keys, or parts of them, or even '[SM]IMD'. It is a case-insensitive search. #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # abstract # abstract.bst # bibkey # This archive created: Wed Aug 29 10:29:39 1990 # By: David F. Kotz (dfk@cs.duke.edu) # Duke University CS Dept. export PATH; PATH=/bin:$PATH if test -f 'abstract' then echo shar: will not over-write existing file "'abstract'" else sed 's/^X//' << \SHAR_EOF > 'abstract' X#!/bin/csh -f X# X# abstract - print a full bibtex bib file out X# X# David Kotz X# X# usage: X# abstract bibfile... X# X Xif ($#argv == 0) then X echo usage: abstract bibfile... X exit 1 Xendif X Xif ($1:e == "bib") then X set files=($1:r) Xelse X set files=($1) Xendif X Xshift Xforeach f ($*) X if ($f:e == "bib") then X set files="$files,$f:r" X else X set files="$files,$f" X endif Xend X Xecho creating abstract.tex for $files X Xcat > abstract.tex <<EOF X\documentstyle[11pt]{article} X\sloppy X\setlength{\textwidth}{6.5in} X\setlength{\textheight}{9in} X\setlength{\topmargin}{-0.5in} X\setlength{\oddsidemargin}{0pt} X\setlength{\evensidemargin}{0pt} X\begin{document} X\begin{center} \Large Bibliography files \large \\\\ XEOF Xecho $files >> abstract.tex Xcat >> abstract.tex <<EOF X\\\\ \today X\end{center} X\nocite{*} X\bibliographystyle{/u/dfk/lib/abstract} XEOF X Xecho "\bibliography{$files}" >> abstract.tex Xecho '\end{document}' >> abstract.tex X Xrm -f abstract.{aux,log,dvi,bbl,blg} X Xset echo Xlatex abstract Xbibtex abstract Xlatex abstract SHAR_EOF chmod +x 'abstract' fi # end of overwriting check if test -f 'abstract.bst' then echo shar: will not over-write existing file "'abstract.bst'" else sed 's/^X//' << \SHAR_EOF > 'abstract.bst' X% BibTeX bibliography style `abstract' by David Kotz X% modifed from X% BibTeX standard bibliography style `alpha' X % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09. X % Copyright (C) 1985, all rights reserved. X % Copying of this file is authorized only if either X % (1) you make absolutely no changes to your copy, including name, or X % (2) if you do make changes, you name it something other than X % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst. X % This restriction helps ensure that all standard styles are identical. X % The file btxbst.doc has the documentation for this style. X X% DFK added abstract, comment, keyword XENTRY X { abstract X address X author X booktitle X chapter X comment X edition X editor X howpublished X institution X journal X key X keyword X month X note X number X organization X pages X publisher X school X series X title X type X volume X year X } X {} X { label extra.label sort.label } X X% DFK added after.quote to signify end of something not needing period XINTEGERS { output.state before.all mid.sentence after.sentence after.block after.quote} X X% DFk added after.quote XFUNCTION {init.state.consts} X{ #0 'before.all := X #1 'mid.sentence := X #2 'after.sentence := X #3 'after.block := X #4 'after.quote := X} X XSTRINGS { s t } X X% DFK added after.quote handling so no period is printed after quotes XFUNCTION {output.nonnull} X{ 's := X output.state after.quote = X { write$ X newline$ X "\newblock " write$ X } X { output.state mid.sentence = X { ", " * write$ } X { output.state after.block = X { add.period$ write$ X newline$ X "\newblock " write$ X } X { output.state before.all = X 'write$ X { add.period$ " " * write$ } X if$ X } X if$ X mid.sentence 'output.state := X } X if$ X } X if$ X s X} X XFUNCTION {output} X{ duplicate$ empty$ X 'pop$ X 'output.nonnull X if$ X} X X% DFK added, variant of output XFUNCTION {output.quote} X{ duplicate$ empty$ X 'pop$ X { output.nonnull X after.quote 'output.state :=} X if$ X} X XFUNCTION {output.check} X{ 't := X duplicate$ empty$ X { pop$ "empty " t * " in " * cite$ * warning$ } X 'output.nonnull X if$ X} X X% DFK changed to use cite$ for the label XFUNCTION {output.bibitem} X{ newline$ X "\bibitem[" write$ X cite$ write$ X "]{" write$ X cite$ write$ X "}" write$ X newline$ X "" X before.all 'output.state := X} X X% DFK changed to not put period when after.quote XFUNCTION {fin.entry} X{ output.state after.quote = X 'skip$ X 'add.period$ X if$ X write$ X newline$ X} X XFUNCTION {new.block} X{ output.state before.all = X 'skip$ X { after.block 'output.state := } X if$ X} X XFUNCTION {new.sentence} X{ output.state after.block = X 'skip$ X { output.state before.all = X 'skip$ X { after.sentence 'output.state := } X if$ X } X if$ X} X XFUNCTION {not} X{ { #0 } X { #1 } X if$ X} X XFUNCTION {and} X{ 'skip$ X { pop$ #0 } X if$ X} X XFUNCTION {or} X{ { pop$ #1 } X 'skip$ X if$ X} X XFUNCTION {new.block.checka} X{ empty$ X 'skip$ X 'new.block X if$ X} X XFUNCTION {new.block.checkb} X{ empty$ X swap$ empty$ X and X 'skip$ X 'new.block X if$ X} X XFUNCTION {new.sentence.checka} X{ empty$ X 'skip$ X 'new.sentence X if$ X} X XFUNCTION {new.sentence.checkb} X{ empty$ X swap$ empty$ X and X 'skip$ X 'new.sentence X if$ X} X XFUNCTION {field.or.null} X{ duplicate$ empty$ X { pop$ "" } X 'skip$ X if$ X} X XFUNCTION {emphasize} X{ duplicate$ empty$ X { pop$ "" } X { "{\em " swap$ * "}" * } X if$ X} X XINTEGERS { nameptr namesleft numnames } X XFUNCTION {format.names} X{ 's := X #1 'nameptr := X s num.names$ 'numnames := X numnames 'namesleft := X { namesleft #0 > } X { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't := X nameptr #1 > X { namesleft #1 > X { ", " * t * } X { numnames #2 > X { "," * } X 'skip$ X if$ X t "others" = X { " et~al." * } X { " and " * t * } X if$ X } X if$ X } X 't X if$ X nameptr #1 + 'nameptr := X namesleft #1 - 'namesleft := X } X while$ X} X XFUNCTION {format.authors} X{ author empty$ X { "" } X { author format.names } X if$ X} X XFUNCTION {format.editors} X{ editor empty$ X { "" } X { editor format.names X editor num.names$ #1 > X { ", editors" * } X { ", editor" * } X if$ X } X if$ X} X XFUNCTION {format.title} X{ title empty$ X { "" } X { title "t" change.case$ } X if$ X} X XFUNCTION {n.dashify} X{ 't := X "" X { t empty$ not } X { t #1 #1 substring$ "-" = X { t #1 #2 substring$ "--" = not X { "--" * X t #2 global.max$ substring$ 't := X } X { { t #1 #1 substring$ "-" = } X { "-" * X t #2 global.max$ substring$ 't := X } X while$ X } X if$ X } X { t #1 #1 substring$ * X t #2 global.max$ substring$ 't := X } X if$ X } X while$ X} X XFUNCTION {format.date} X{ year empty$ X { month empty$ X { "" } X { "there's a month but no year in " cite$ * warning$ X month X } X if$ X } X { month empty$ X 'year X { month " " * year * } X if$ X } X if$ X} X XFUNCTION {format.btitle} X{ title emphasize X} X XFUNCTION {tie.or.space.connect} X{ duplicate$ text.length$ #3 < X { "~" } X { " " } X if$ X swap$ * * X} X XFUNCTION {either.or.check} X{ empty$ X 'pop$ X { "can't use both " swap$ * " fields in " * cite$ * warning$ } X if$ X} X XFUNCTION {format.bvolume} X{ volume empty$ X { "" } X { "volume" volume tie.or.space.connect X series empty$ X 'skip$ X { " of " * series emphasize * } X if$ X "volume and number" number either.or.check X } X if$ X} X XFUNCTION {format.number.series} X{ volume empty$ X { number empty$ X { series field.or.null } X { output.state mid.sentence = X { "number" } X { "Number" } X if$ X number tie.or.space.connect X series empty$ X { "there's a number but no series in " cite$ * warning$ } X { " in " * series * } X if$ X } X if$ X } X { "" } X if$ X} X XFUNCTION {format.edition} X{ edition empty$ X { "" } X { output.state mid.sentence = X { edition "l" change.case$ " edition" * } X { edition "t" change.case$ " edition" * } X if$ X } X if$ X} X XINTEGERS { multiresult } X XFUNCTION {multi.page.check} X{ 't := X #0 'multiresult := X { multiresult not X t empty$ not X and X } X { t #1 #1 substring$ X duplicate$ "-" = X swap$ duplicate$ "," = X swap$ "+" = X or or X { #1 'multiresult := } X { t #2 global.max$ substring$ 't := } X if$ X } X while$ X multiresult X} X XFUNCTION {format.pages} X{ pages empty$ X { "" } X { pages multi.page.check X { "pages" pages n.dashify tie.or.space.connect } X { "page" pages tie.or.space.connect } X if$ X } X if$ X} X XFUNCTION {format.vol.num.pages} X{ volume field.or.null X number empty$ X 'skip$ X { "(" number * ")" * * X volume empty$ X { "there's a number but no volume in " cite$ * warning$ } X 'skip$ X if$ X } X if$ X pages empty$ X 'skip$ X { duplicate$ empty$ X { pop$ format.pages } X { ":" * pages n.dashify * } X if$ X } X if$ X} X XFUNCTION {format.chapter.pages} X{ chapter empty$ X 'format.pages X { type empty$ X { "chapter" } X { type "l" change.case$ } X if$ X chapter tie.or.space.connect X pages empty$ X 'skip$ X { ", " * format.pages * } X if$ X } X if$ X} X XFUNCTION {format.in.ed.booktitle} X{ booktitle empty$ X { "" } X { editor empty$ X { "In " booktitle emphasize * } X { "In " format.editors * ", " * booktitle emphasize * } X if$ X } X if$ X} X XFUNCTION {empty.misc.check} X{ author empty$ title empty$ howpublished empty$ X month empty$ year empty$ note empty$ X and and and and and X key empty$ not and X { "all relevant fields are empty in " cite$ * warning$ } X 'skip$ X if$ X} X XFUNCTION {format.thesis.type} X{ type empty$ X 'skip$ X { pop$ X type "t" change.case$ X } X if$ X} X XFUNCTION {format.tr.number} X{ type empty$ X { "Technical Report" } X 'type X if$ X number empty$ X { "t" change.case$ } X { number tie.or.space.connect } X if$ X} X XFUNCTION {format.article.crossref} X{ key empty$ X { journal empty$ X { "need key or journal for " cite$ * " to crossref " * crossref * X warning$ X "" X } X { "In {\em " journal * "\/}" * } X if$ X } X { "In " key * } X if$ X " \cite{" * crossref * "}" * X} X XFUNCTION {format.crossref.editor} X{ editor #1 "{vv~}{ll}" format.name$ X editor num.names$ duplicate$ X #2 > X { pop$ " et~al." * } X { #2 < X 'skip$ X { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" = X { " et~al." * } X { " and " * editor #2 "{vv~}{ll}" format.name$ * } X if$ X } X if$ X } X if$ X} X XFUNCTION {format.book.crossref} X{ volume empty$ X { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ X "In " X } X { "Volume" volume tie.or.space.connect X " of " * X } X if$ X editor empty$ X editor field.or.null author field.or.null = X or X { key empty$ X { series empty$ X { "need editor, key, or series for " cite$ * " to crossref " * X crossref * warning$ X "" * X } X { "{\em " * series * "\/}" * } X if$ X } X { key * } X if$ X } X { format.crossref.editor * } X if$ X " \cite{" * crossref * "}" * X} X XFUNCTION {format.incoll.inproc.crossref} X{ editor empty$ X editor field.or.null author field.or.null = X or X { key empty$ X { booktitle empty$ X { "need editor, key, or booktitle for " cite$ * " to crossref " * X crossref * warning$ X "" X } X { "In {\em " booktitle * "\/}" * } X if$ X } X { "In " key * } X if$ X } X { "In " format.crossref.editor * } X if$ X " \cite{" * crossref * "}" * X} X X% DFK added XFUNCTION {format.abstract} X{ abstract empty$ X { "" } X { "\begin{quote} {\bf Abstract:} " abstract * " \end{quote}" *} X if$ X} X X% DFK added XFUNCTION {format.keyword} X{ keyword empty$ X { "" } X { "\begin{quote} {\bf Keyword:} " keyword * " \end{quote}" *} X if$ X} X X% DFK added XFUNCTION {format.comment} X{ comment empty$ X { "" } X { "\begin{quote} {\bf Comment:} " comment * " \end{quote}" *} X if$ X} X X% DFK added XFUNCTION {dfk.stuff} X{ new.block X format.abstract output.quote X% new.block X format.keyword output.quote X% new.block X format.comment output.quote X} X X% DFK: added a call to dfk.stuff in all entry-type functions below X XFUNCTION {article} X{ output.bibitem X format.authors "author" output.check X new.block X format.title "title" output.check X new.block X crossref missing$ X { journal emphasize "journal" output.check X format.vol.num.pages output X format.date "year" output.check X } X { format.article.crossref output.nonnull X format.pages output X } X if$ X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {book} X{ output.bibitem X author empty$ X { format.editors "author and editor" output.check } X { format.authors output.nonnull X crossref missing$ X { "author and editor" editor either.or.check } X 'skip$ X if$ X } X if$ X new.block X format.btitle "title" output.check X crossref missing$ X { format.bvolume output X new.block X format.number.series output X new.sentence X publisher "publisher" output.check X address output X } X { new.block X format.book.crossref output.nonnull X } X if$ X format.edition output X format.date "year" output.check X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {booklet} X{ output.bibitem X format.authors output X new.block X format.title "title" output.check X howpublished address new.block.checkb X howpublished output X address output X format.date output X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {inbook} X{ output.bibitem X author empty$ X { format.editors "author and editor" output.check } X { format.authors output.nonnull X crossref missing$ X { "author and editor" editor either.or.check } X 'skip$ X if$ X } X if$ X new.block X format.btitle "title" output.check X crossref missing$ X { format.bvolume output X format.chapter.pages "chapter and pages" output.check X new.block X format.number.series output X new.sentence X publisher "publisher" output.check X address output X } X { format.chapter.pages "chapter and pages" output.check X new.block X format.book.crossref output.nonnull X } X if$ X format.edition output X format.date "year" output.check X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {incollection} X{ output.bibitem X format.authors "author" output.check X new.block X format.title "title" output.check X new.block X crossref missing$ X { format.in.ed.booktitle "booktitle" output.check X format.bvolume output X format.number.series output X format.chapter.pages output X new.sentence X publisher "publisher" output.check X address output X format.edition output X format.date "year" output.check X } X { format.incoll.inproc.crossref output.nonnull X format.chapter.pages output X } X if$ X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {inproceedings} X{ output.bibitem X format.authors "author" output.check X new.block X format.title "title" output.check X new.block X crossref missing$ X { format.in.ed.booktitle "booktitle" output.check X format.bvolume output X format.number.series output X format.pages output X address empty$ X { organization publisher new.sentence.checkb X organization output X publisher output X format.date "year" output.check X } X { address output.nonnull X format.date "year" output.check X new.sentence X organization output X publisher output X } X if$ X } X { format.incoll.inproc.crossref output.nonnull X format.pages output X } X if$ X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {conference} { inproceedings } X XFUNCTION {manual} X{ output.bibitem X author empty$ X { organization empty$ X 'skip$ X { organization output.nonnull X address output X } X if$ X } X { format.authors output.nonnull } X if$ X new.block X format.btitle "title" output.check X author empty$ X { organization empty$ X { address new.block.checka X address output X } X 'skip$ X if$ X } X { organization address new.block.checkb X organization output X address output X } X if$ X format.edition output X format.date output X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {mastersthesis} X{ output.bibitem X format.authors "author" output.check X new.block X format.title "title" output.check X new.block X "Master's thesis" format.thesis.type output.nonnull X school "school" output.check X address output X format.date "year" output.check X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {misc} X{ output.bibitem X format.authors output X title howpublished new.block.checkb X format.title output X howpublished new.block.checka X howpublished output X format.date output X new.block X note output X dfk.stuff X fin.entry X empty.misc.check X} X XFUNCTION {phdthesis} X{ output.bibitem X format.authors "author" output.check X new.block X format.btitle "title" output.check X new.block X "PhD thesis" format.thesis.type output.nonnull X school "school" output.check X address output X format.date "year" output.check X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {proceedings} X{ output.bibitem X editor empty$ X { organization output } X { format.editors output.nonnull } X if$ X new.block X format.btitle "title" output.check X format.bvolume output X format.number.series output X address empty$ X { editor empty$ X { publisher new.sentence.checka } X { organization publisher new.sentence.checkb X organization output X } X if$ X publisher output X format.date "year" output.check X } X { address output.nonnull X format.date "year" output.check X new.sentence X editor empty$ X 'skip$ X { organization output } X if$ X publisher output X } X if$ X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {techreport} X{ output.bibitem X format.authors "author" output.check X new.block X format.title "title" output.check X new.block X format.tr.number output.nonnull X institution "institution" output.check X address output X format.date "year" output.check X new.block X note output X dfk.stuff X fin.entry X} X XFUNCTION {unpublished} X{ output.bibitem X format.authors "author" output.check X new.block X format.title "title" output.check X new.block X note "note" output.check X format.date output X dfk.stuff X fin.entry X} X XFUNCTION {default.type} { misc } X XMACRO {jan} {"January"} X XMACRO {feb} {"February"} X XMACRO {mar} {"March"} X XMACRO {apr} {"April"} X XMACRO {may} {"May"} X XMACRO {jun} {"June"} X XMACRO {jul} {"July"} X XMACRO {aug} {"August"} X XMACRO {sep} {"September"} X XMACRO {oct} {"October"} X XMACRO {nov} {"November"} X XMACRO {dec} {"December"} X XMACRO {acmcs} {"ACM Computing Surveys"} X XMACRO {acta} {"Acta Informatica"} X XMACRO {cacm} {"Communications of the ACM"} X XMACRO {ibmjrd} {"IBM Journal of Research and Development"} X XMACRO {ibmsj} {"IBM Systems Journal"} X XMACRO {ieeese} {"IEEE Transactions on Software Engineering"} X XMACRO {ieeetc} {"IEEE Transactions on Computers"} X XMACRO {ieeetcad} X {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"} X XMACRO {ipl} {"Information Processing Letters"} X XMACRO {jacm} {"Journal of the ACM"} X XMACRO {jcss} {"Journal of Computer and System Sciences"} X XMACRO {scp} {"Science of Computer Programming"} X XMACRO {sicomp} {"SIAM Journal on Computing"} X XMACRO {tocs} {"ACM Transactions on Computer Systems"} X XMACRO {tods} {"ACM Transactions on Database Systems"} X XMACRO {tog} {"ACM Transactions on Graphics"} X XMACRO {toms} {"ACM Transactions on Mathematical Software"} X XMACRO {toois} {"ACM Transactions on Office Information Systems"} X XMACRO {toplas} {"ACM Transactions on Programming Languages and Systems"} X XMACRO {tcs} {"Theoretical Computer Science"} X XREAD X XFUNCTION {sortify} X{ purify$ X "l" change.case$ X} X XINTEGERS { len } X XFUNCTION {chop.word} X{ 's := X 'len := X s #1 len substring$ = X { s len #1 + global.max$ substring$ } X 's X if$ X} X XINTEGERS { et.al.char.used } X XFUNCTION {initialize.et.al.char.used} X{ #0 'et.al.char.used := X} X XEXECUTE {initialize.et.al.char.used} X XFUNCTION {format.lab.names} X{ 's := X s num.names$ 'numnames := X numnames #1 > X { numnames #4 > X { #3 'namesleft := } X { numnames 'namesleft := } X if$ X #1 'nameptr := X "" X { namesleft #0 > } X { nameptr numnames = X { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" = X { "{\etalchar{+}}" * X #1 'et.al.char.used := X } X { s nameptr "{v{}}{l{}}" format.name$ * } X if$ X } X { s nameptr "{v{}}{l{}}" format.name$ * } X if$ X nameptr #1 + 'nameptr := X namesleft #1 - 'namesleft := X } X while$ X numnames #4 > X { "{\etalchar{+}}" * X #1 'et.al.char.used := X } X 'skip$ X if$ X } X { s #1 "{v{}}{l{}}" format.name$ X duplicate$ text.length$ #2 < X { pop$ s #1 "{ll}" format.name$ #3 text.prefix$ } X 'skip$ X if$ X } X if$ X} X XFUNCTION {author.key.label} X{ author empty$ X { key empty$ X { cite$ #1 #3 substring$ } X { key #3 text.prefix$ } X if$ X } X { author format.lab.names } X if$ X} X XFUNCTION {author.editor.key.label} X{ author empty$ X { editor empty$ X { key empty$ X { cite$ #1 #3 substring$ } X { key #3 text.prefix$ } X if$ X } X { editor format.lab.names } X if$ X } X { author format.lab.names } X if$ X} X XFUNCTION {author.key.organization.label} X{ author empty$ X { key empty$ X { organization empty$ X { cite$ #1 #3 substring$ } X { "The " #4 organization chop.word #3 text.prefix$ } X if$ X } X { key #3 text.prefix$ } X if$ X } X { author format.lab.names } X if$ X} X XFUNCTION {editor.key.organization.label} X{ editor empty$ X { key empty$ X { organization empty$ X { cite$ #1 #3 substring$ } X { "The " #4 organization chop.word #3 text.prefix$ } X if$ X } X { key #3 text.prefix$ } X if$ X } X { editor format.lab.names } X if$ X} X XFUNCTION {calc.label} X{ type$ "book" = X type$ "inbook" = X or X 'author.editor.key.label X { type$ "proceedings" = X 'editor.key.organization.label X { type$ "manual" = X 'author.key.organization.label X 'author.key.label X if$ X } X if$ X } X if$ X duplicate$ X year field.or.null purify$ #-1 #2 substring$ X * X 'label := X year field.or.null purify$ #-1 #4 substring$ X * X sortify 'sort.label := X} X XFUNCTION {sort.format.names} X{ 's := X #1 'nameptr := X "" X s num.names$ 'numnames := X numnames 'namesleft := X { namesleft #0 > } X { nameptr #1 > X { " " * } X 'skip$ X if$ X s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't := X nameptr numnames = t "others" = and X { "et al" * } X { t sortify * } X if$ X nameptr #1 + 'nameptr := X namesleft #1 - 'namesleft := X } X while$ X} X XFUNCTION {sort.format.title} X{ 't := X "A " #2 X "An " #3 X "The " #4 t chop.word X chop.word X chop.word X sortify X #1 global.max$ substring$ X} X XFUNCTION {author.sort} X{ author empty$ X { key empty$ X { "to sort, need author or key in " cite$ * warning$ X "" X } X { key sortify } X if$ X } X { author sort.format.names } X if$ X} X XFUNCTION {author.editor.sort} X{ author empty$ X { editor empty$ X { key empty$ X { "to sort, need author, editor, or key in " cite$ * warning$ X "" X } X { key sortify } X if$ X } X { editor sort.format.names } X if$ X } X { author sort.format.names } X if$ X} X XFUNCTION {author.organization.sort} X{ author empty$ X { organization empty$ X { key empty$ X { "to sort, need author, organization, or key in " cite$ * warning$ X "" X } X { key sortify } X if$ X } X { "The " #4 organization chop.word sortify } X if$ X } X { author sort.format.names } X if$ X} X XFUNCTION {editor.organization.sort} X{ editor empty$ X { organization empty$ X { key empty$ X { "to sort, need editor, organization, or key in " cite$ * warning$ X "" X } X { key sortify } X if$ X } X { "The " #4 organization chop.word sortify } X if$ X } X { editor sort.format.names } X if$ X} X XFUNCTION {presort} X{ calc.label X sort.label X " " X * X type$ "book" = X type$ "inbook" = X or X 'author.editor.sort X { type$ "proceedings" = X 'editor.organization.sort X { type$ "manual" = X 'author.organization.sort X 'author.sort X if$ X } X if$ X } X if$ X * X " " X * X year field.or.null sortify X * X " " X * X title field.or.null X sort.format.title X * X% DFK throw away stuff above and use cite$ for sort key X pop$ X cite$ X #1 entry.max$ substring$ X 'sort.key$ := X} X XITERATE {presort} X XSORT X XSTRINGS { longest.label last.sort.label next.extra } X XINTEGERS { longest.label.width last.extra.num } X XFUNCTION {initialize.longest.label} X{ "" 'longest.label := X #0 int.to.chr$ 'last.sort.label := X "" 'next.extra := X #0 'longest.label.width := X #0 'last.extra.num := X} X XFUNCTION {forward.pass} X{ last.sort.label sort.label = X { last.extra.num #1 + 'last.extra.num := X last.extra.num int.to.chr$ 'extra.label := X } X { "a" chr.to.int$ 'last.extra.num := X "" 'extra.label := X sort.label 'last.sort.label := X } X if$ X} X XFUNCTION {reverse.pass} X{ next.extra "b" = X { "a" 'extra.label := } X 'skip$ X if$ X label extra.label * 'label := X label width$ longest.label.width > X { label 'longest.label := X label width$ 'longest.label.width := X } X 'skip$ X if$ X extra.label 'next.extra := X} X XEXECUTE {initialize.longest.label} X XITERATE {forward.pass} X XREVERSE {reverse.pass} X XFUNCTION {begin.bib} X{ et.al.char.used X { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ } X 'skip$ X if$ X preamble$ empty$ X 'skip$ X { preamble$ write$ newline$ } X if$ X "\begin{thebibliography}{" longest.label * "}" * write$ newline$ X} X XEXECUTE {begin.bib} X XEXECUTE {init.state.consts} X XITERATE {call.type$} X XFUNCTION {end.bib} X{ newline$ X "\end{thebibliography}" write$ newline$ X} X XEXECUTE {end.bib} SHAR_EOF fi # end of overwriting check if test -f 'bibkey' then echo shar: will not over-write existing file "'bibkey'" else sed 's/^X//' << \SHAR_EOF > 'bibkey' X#!/bin/csh -f X# bibkey - look for a word in the keyword entry X# in the references in a BiBTeX file. A restricted form of looktex. X# X# David Kotz (dfk@cs.duke.edu) X# X# usage: X# bibkey keyword file... X# X# Warning: Any characters in keyword that have meanings in regexps X# used by either sed or egrep must be escaped with a \ (the most X# likely occurrence might be \ itself: use \\). Case is ignored in X# the search. X# X# Multiple keywords may be specified with an egrep alternation format: X# eg bibkey 'jones|smith' foo.bib X# X# Actually, any egrep expression is allowed. X# Be sure to quote it properly. X# X Xset L=~/lib X Xif ($#argv < 2) then X echo usage: bibkey keyword 'file...' X exit 1 Xendif X Xset keyword=`echo "$1" | tr A-Z a-z` Xshift X Xset script=/tmp/bibkey$$ Xonintr cleanup X X# Search for the keyword and get a script for extracting the X# references: X# Cat the files X# Strip comment lines and comments on lines X# translate to lower case X# Extract the keyword entries, plus number for lines with @ X# Search for the keyword X# Convert this output into a sed script Xcat $* \ X | sed -e 's/^%.*//' -e 's/\([^\\]\)%.*/\1/' \ X | tr A-Z a-z \ X | sed -n -f $L/bibkey.sed \ X | egrep '^[0-9]*$|'"($keyword)" \ X | awk -f $L/bibkey.awk > $script X X# Now have sed print out the correct entries: Xcat $* | sed -n -f $script X Xcleanup: Xrm -f $script SHAR_EOF chmod +x 'bibkey' fi # end of overwriting check # End of shell archive exit 0 -- Department of Computer Science, Duke University, Durham, NC 27706 USA ARPA: dfk@cs.duke.edu CSNET: dfk@duke UUCP: decvax!duke!dfk