2 %% This is file `elsarticle-num.bst',
4 %% Copyright 2007, 2008, 2009 Elsevier Ltd
6 %% This file is part of the 'Elsarticle Bundle'.
7 %% ---------------------------------------------
9 %% It may be distributed under the conditions of the LaTeX Project Public
10 %% License, either version 1.2 of this license or (at your option) any
11 %% later version. The latest version of this license is in
12 %% http://www.latex-project.org/lppl.txt
13 %% and version 1.2 or later is part of all distributions of LaTeX
14 %% version 1999/12/01 or later.
16 %% The list of all files belonging to the 'Elsarticle Bundle' is
17 %% given in the file `manifest.txt'.
20 %% $Id: elsarticle-num.bst 19 2009-12-17 07:07:52Z rishi $
23 %% ----------------------------------------
56 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
58 STRINGS { urlintro eprinturl eprintprefix doiprefix doiurl openinlinelink closeinlinelink } % urlbst...
59 INTEGERS { hrefform inlinelinks makeinlinelink addeprints adddoiresolver }
60 FUNCTION {init.urlbst.variables}
62 "Available from: " 'urlintro := % prefix before URL
63 "http://arxiv.org/abs/" 'eprinturl := % prefix to make URL from eprint ref
64 "arXiv:" 'eprintprefix := % text prefix printed before eprint ref
65 "http://dx.doi.org/" 'doiurl := % prefix to make URL from DOI
66 "doi:" 'doiprefix := % text prefix printed before DOI ref
67 #1 'addeprints := % 0=no eprints; 1=include eprints
68 #1 'adddoiresolver := % 0=no DOI resolver; 1=include it
69 #2 'hrefform := % 0=no crossrefs; 1=hypertex xrefs; 2=hyperref refs
70 #1 'inlinelinks := % 0=URLs explicit; 1=URLs attached to titles
71 % the following are internal state variables, not config constants
72 #0 'makeinlinelink := % state variable managed by setup.inlinelink
73 "" 'openinlinelink := % ditto
74 "" 'closeinlinelink := % ditto
83 FUNCTION {init.state.consts}
84 { #0 'outside.brackets := % urlbst
86 #2 'within.brackets :=
97 FUNCTION {output.nonnull.original}
99 output.state mid.sentence =
101 { output.state after.block =
106 { output.state before.all =
108 { add.period$ " " * write$ }
112 mid.sentence 'output.state :=
118 FUNCTION {setup.inlinelink}
120 { hrefform #1 = % hypertex
121 { "\special {html:<a href=" quote$ * url * quote$ * "> }{" * 'openinlinelink :=
122 "\special {html:</a>}" 'closeinlinelink :=
124 { hrefform #2 = % hyperref
125 { "\href{" url * "}{" * 'openinlinelink :=
126 "}" 'closeinlinelink :=
132 #0 'makeinlinelink :=
137 FUNCTION {add.inlinelink}
138 { openinlinelink empty$
140 { openinlinelink swap$ * closeinlinelink *
141 "" 'openinlinelink :=
145 FUNCTION {output.nonnull}
146 { % Save the thing we've been asked to output
148 % If the bracket-state is close.brackets, then add a close-bracket to
149 % what is currently at the top of the stack, and set bracket.state
150 % to outside.brackets
151 bracket.state close.brackets =
153 outside.brackets 'bracket.state :=
157 bracket.state outside.brackets =
158 { % We're outside all brackets -- this is the normal situation.
159 % Write out what's currently at the top of the stack, using the
160 % original output.nonnull function.
163 output.nonnull.original % invoke the original output.nonnull
165 { % Still in brackets. Add open-bracket or (continuation) comma, add the
166 % new text (in s) to the top of the stack, and move to the close-brackets
167 % state, ready for next time (unless inbrackets resets it). If we come
168 % into this branch, then output.state is carefully undisturbed.
169 bracket.state open.brackets =
171 { ", " * } % bracket.state will be within.brackets
174 close.brackets 'bracket.state :=
179 FUNCTION {inbrackets}
180 { bracket.state close.brackets =
181 { within.brackets 'bracket.state := } % reset the state: not open nor closed
182 { open.brackets 'bracket.state := }
186 FUNCTION {format.lastchecked}
189 { inbrackets "cited " lastchecked * }
200 FUNCTION {output.check}
203 { pop$ "empty " t * " in " * cite$ * warning$ }
208 FUNCTION {fin.entry.original}
215 { output.state before.all =
217 { after.block 'output.state := }
221 FUNCTION {new.sentence}
222 { output.state after.block =
224 { output.state before.all =
226 { after.sentence 'output.state := }
233 { " " * before.all 'output.state :=
236 FUNCTION {date.block}
259 FUNCTION {new.block.checka}
266 FUNCTION {new.block.checkb}
275 FUNCTION {new.sentence.checka}
282 FUNCTION {new.sentence.checkb}
291 FUNCTION {field.or.null}
301 FUNCTION {capitalize}
302 { "u" change.case$ "t" change.case$ }
304 FUNCTION {space.word}
305 { " " swap$ * " " * }
307 % Here are the language-specific definitions for explicit words.
308 % Each function has a name bbl.xxx where xxx is the English word.
309 % The language selected here is ENGLISH
316 FUNCTION {bbl.editors}
319 FUNCTION {bbl.editor}
325 FUNCTION {bbl.edition}
328 FUNCTION {bbl.volume}
334 FUNCTION {bbl.number}
349 FUNCTION {bbl.chapter}
352 FUNCTION {bbl.techrep}
355 FUNCTION {bbl.mthesis}
356 { "Master's thesis" }
358 FUNCTION {bbl.phdthesis}
364 FUNCTION {bbl.second}
370 FUNCTION {bbl.fourth}
413 { duplicate$ "1" swap$ *
414 #-2 #1 substring$ "1" =
416 { duplicate$ #-1 #1 substring$
433 MACRO {acmcs} {"ACM Comput. Surv."}
435 MACRO {acta} {"Acta Inf."}
437 MACRO {cacm} {"Commun. ACM"}
439 MACRO {ibmjrd} {"IBM J. Res. Dev."}
441 MACRO {ibmsj} {"IBM Syst.~J."}
443 MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
445 MACRO {ieeetc} {"IEEE Trans. Comput."}
448 {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
450 MACRO {ipl} {"Inf. Process. Lett."}
452 MACRO {jacm} {"J.~ACM"}
454 MACRO {jcss} {"J.~Comput. Syst. Sci."}
456 MACRO {scp} {"Sci. Comput. Programming"}
458 MACRO {sicomp} {"SIAM J. Comput."}
460 MACRO {tocs} {"ACM Trans. Comput. Syst."}
462 MACRO {tods} {"ACM Trans. Database Syst."}
464 MACRO {tog} {"ACM Trans. Gr."}
466 MACRO {toms} {"ACM Trans. Math. Softw."}
468 MACRO {toois} {"ACM Trans. Office Inf. Syst."}
470 MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
472 MACRO {tcs} {"Theoretical Comput. Sci."}
477 { "\newline\urlprefix\url{" url * "}" * write$ newline$ }
481 INTEGERS { nameptr namesleft numnames }
483 FUNCTION {format.names}
486 s num.names$ 'numnames :=
487 numnames 'namesleft :=
490 "{f.~}{vv~}{ll}{, jj}" format.name$
498 s nameptr "{ll}" format.name$ duplicate$ "others" =
513 nameptr #1 + 'nameptr :=
514 namesleft #1 - 'namesleft :=
518 FUNCTION {format.names.ed}
520 FUNCTION {format.authors}
523 { author format.names }
527 FUNCTION {format.editors}
530 { editor format.names
531 editor num.names$ #1 >
532 { " (" * bbl.editors * ")" * }
533 { " (" * bbl.editor * ")" * }
539 FUNCTION {format.in.editors}
542 { editor format.names.ed
543 editor num.names$ #1 >
544 { " (" * bbl.editors * ")" * }
545 { " (" * bbl.editor * ")" * }
551 FUNCTION {format.note}
555 { note #1 #1 substring$
558 { output.state mid.sentence =
565 note #2 global.max$ substring$ *
570 FUNCTION {format.title}
573 { title "t" change.case$
578 FUNCTION {output.bibitem.original}
585 before.all 'output.state :=
593 { t #1 #1 substring$ "-" =
594 { t #1 #2 substring$ "--" = not
596 t #2 global.max$ substring$ 't :=
598 { { t #1 #1 substring$ "-" = }
600 t #2 global.max$ substring$ 't :=
606 { t #1 #1 substring$ *
607 t #2 global.max$ substring$ 't :=
619 FUNCTION {format.date}
623 { "there's a month but no year in " cite$ * warning$
630 { month " " * year * }
637 before.all 'output.state :=
643 FUNCTION{format.year}
644 { year duplicate$ empty$
645 { "empty year in " cite$ * warning$ pop$ "" }
646 { "(" swap$ * ")" * }
650 FUNCTION {format.btitle}
654 FUNCTION {tie.or.space.connect}
655 { duplicate$ text.length$ #3 <
662 FUNCTION {either.or.check}
665 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
669 FUNCTION {format.bvolume}
672 { bbl.volume volume tie.or.space.connect
675 { bbl.of space.word * series emphasize * }
677 "volume and number" number either.or.check
682 FUNCTION {format.number.series}
685 { series field.or.null }
686 { output.state mid.sentence =
688 { bbl.number capitalize }
690 number tie.or.space.connect
692 { "there's a number but no series in " cite$ * warning$ }
693 { bbl.in space.word * series * }
704 duplicate$ "0" chr.to.int$ < not
705 swap$ "9" chr.to.int$ > not and
708 FUNCTION {extract.num}
713 t #2 global.max$ substring$ 't :=
726 FUNCTION {convert.edition}
727 { edition extract.num "l" change.case$ 's :=
728 s "first" = s "1" = or
730 { s "second" = s "2" = or
732 { s "third" = s "3" = or
734 { s "fourth" = s "4" = or
736 { s "fifth" = s "5" = or
738 { s #1 #1 substring$ is.num
755 FUNCTION {format.edition}
758 { output.state mid.sentence =
759 { convert.edition "l" change.case$ " " * bbl.edition * }
760 { convert.edition "t" change.case$ " " * bbl.edition * }
766 INTEGERS { multiresult }
768 FUNCTION {multi.page.check}
777 swap$ duplicate$ "," =
780 { #1 'multiresult := }
781 { t #2 global.max$ substring$ 't := }
788 FUNCTION {format.pages}
791 { pages multi.page.check
792 { bbl.pages pages n.dashify tie.or.space.connect }
793 { bbl.page pages tie.or.space.connect }
799 FUNCTION {format.journal.pages}
803 { pop$ format.pages }
814 FUNCTION {format.vol.num.pages}
816 % volume field.or.null
825 "~(" number * ")" * *
827 { "there's a number but no volume in " cite$ * warning$ }
834 FUNCTION {format.chapter.pages}
839 { type "l" change.case$ }
841 chapter tie.or.space.connect
846 FUNCTION {format.in.ed.booktitle}
850 { word.in booktitle * }
851 { word.in format.in.editors * ", " *
858 FUNCTION {empty.misc.check}
859 { author empty$ title empty$ howpublished empty$
860 month empty$ year empty$ note empty$
862 { "all relevant fields are empty in " cite$ * warning$ }
867 FUNCTION {format.thesis.type}
871 type "t" change.case$
876 FUNCTION {format.tr.number}
883 { number tie.or.space.connect }
887 FUNCTION {format.article.crossref}
891 { "need key or journal for " cite$ * " to crossref " * crossref *
895 { word.in journal emphasize * }
898 { word.in key * " " *}
900 " \cite{" * crossref * "}" *
903 FUNCTION {format.crossref.editor}
904 { editor #1 "{vv~}{ll}" format.name$
905 editor num.names$ duplicate$
912 { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
916 { bbl.and space.word * editor #2 "{vv~}{ll}" format.name$
925 FUNCTION {format.book.crossref}
927 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
930 { bbl.volume volume tie.or.space.connect
935 editor field.or.null author field.or.null =
939 { "need editor, key, or series for " cite$ * " to crossref " *
943 { series emphasize * }
949 { format.crossref.editor * }
951 " \cite{" * crossref * "}" *
954 FUNCTION {format.incoll.inproc.crossref}
957 editor field.or.null author field.or.null =
961 { "need editor, key, or booktitle for " cite$ * " to crossref " *
965 { word.in booktitle * }
968 { word.in key * " " *}
971 { word.in format.crossref.editor * " " *}
973 " \cite{" * crossref * "}" *
976 FUNCTION {format.org.or.pub}
980 { "empty year in " cite$ * warning$ }
983 address empty$ t empty$ and
1002 { t empty$ address empty$ and
1013 FUNCTION {format.publisher.address}
1015 { "empty publisher in " cite$ * warning$
1023 FUNCTION {format.organization.address}
1024 { organization empty$
1031 FUNCTION {make.href.null}
1035 FUNCTION {make.href.hypertex}
1037 "\special {html:<a href=" quote$ *
1038 swap$ * quote$ * "> }" * swap$ *
1039 "\special {html:</a>}" *
1041 FUNCTION {make.href.hyperref}
1043 "\href {" swap$ * "} {\path{" * swap$ * "}}" *
1045 FUNCTION {make.href}
1047 'make.href.hyperref % hrefform = 2
1049 'make.href.hypertex % hrefform = 1
1050 'make.href.null % hrefform = 0 (or anything else)
1056 FUNCTION {format.url}
1057 { inlinelinks #1 = url empty$ or
1060 { % special case -- add HyperTeX specials
1061 urlintro "\url{" url * "}" * url make.href.hypertex * }
1062 { urlintro "\url{" * url * "}" * }
1068 FUNCTION {format.eprint}
1071 { eprintprefix eprint * eprinturl eprint * make.href }
1075 FUNCTION {format.doi}
1078 { doiprefix doi * doiurl doi * make.href }
1082 FUNCTION {output.url}
1087 format.lastchecked output
1092 FUNCTION {output.web.refs}
1096 addeprints eprint empty$ not and
1097 { format.eprint output.nonnull }
1100 adddoiresolver doi empty$ not and
1101 { format.doi output.nonnull }
1106 FUNCTION {output.bibitem}
1107 { outside.brackets 'bracket.state :=
1108 output.bibitem.original
1109 inlinelinks url empty$ not and
1110 { #1 'makeinlinelink := }
1111 { #0 'makeinlinelink := }
1115 FUNCTION {fin.entry}
1116 { output.web.refs % urlbst
1117 makeinlinelink % ooops, it appears we didn't have a title for inlinelink
1118 { setup.inlinelink % add some artificial link text here, as a fallback
1119 "[link]" output.nonnull }
1122 bracket.state close.brackets = % urlbst
1133 'skip$ % author and editor both optional
1134 { format.editors output.nonnull }
1138 { format.authors output.nonnull }
1139 { "can't use both author and editor fields in " cite$ * warning$ }
1144 title empty$ 'skip$ 'setup.inlinelink if$
1145 format.title "title" output.check
1146 inbrackets "online" output
1150 { format.date "year" output.check }
1152 % We don't need to output the URL details ('lastchecked' and 'url'),
1153 % because fin.entry does that for us, using output.web.refs. The only
1154 % reason we would want to put them here is if we were to decide that
1155 % they should go in front of the rather miscellaneous information in 'note'.
1163 format.authors "author" output.check
1164 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1165 format.title "title" output.check
1168 "journal" output.check
1170 before.all 'output.state :=
1171 format.vol.num.pages output
1173 { format.article.crossref output.nonnull
1177 format.journal.pages
1186 { format.editors "author and editor" output.check
1188 { format.authors output.nonnull
1190 { "author and editor" editor either.or.check }
1195 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1196 format.btitle "title" output.check
1198 { format.edition output
1199 format.bvolume output
1200 format.number.series output
1201 format.publisher.address output
1204 format.book.crossref output.nonnull
1214 format.authors output
1215 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1216 format.title "title" output.check
1228 { format.editors "author and editor" output.check
1230 { format.authors output.nonnull
1232 { "author and editor" editor either.or.check }
1237 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1238 format.btitle "title" output.check
1241 format.edition output
1242 format.bvolume output
1243 format.number.series output
1244 format.publisher.address output
1245 format.chapter.pages "chapter and pages" output.check
1248 format.chapter.pages "chapter and pages" output.check
1249 format.book.crossref output.nonnull
1252 format.pages "pages" output.check
1258 FUNCTION {incollection}
1260 format.authors "author" output.check
1261 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1262 format.title "title" output.check
1264 { format.in.ed.booktitle "booktitle" output.check
1265 format.edition output
1266 format.bvolume output
1267 format.number.series output
1268 format.publisher.address output
1269 format.chapter.pages output
1271 { format.incoll.inproc.crossref output.nonnull
1272 format.chapter.pages output
1275 format.pages "pages" output.check
1281 FUNCTION {inproceedings}
1283 format.authors "author" output.check
1284 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1285 format.title "title" output.check
1287 { format.in.ed.booktitle "booktitle" output.check
1288 format.edition output
1289 format.bvolume output
1290 format.number.series output
1292 { format.organization.address output }
1293 { organization output
1294 format.publisher.address output
1298 { format.incoll.inproc.crossref output.nonnull
1301 format.pages "pages" output.check
1307 FUNCTION {conference} { inproceedings }
1312 { organization empty$
1314 { organization output.nonnull
1319 { format.authors output.nonnull }
1321 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1322 format.btitle "title" output.check
1324 { organization empty$
1336 format.edition output
1343 FUNCTION {mastersthesis}
1345 format.authors "author" output.check
1346 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1347 format.title "title" output.check
1348 bbl.mthesis format.thesis.type output.nonnull
1349 school "school" output.check
1352 format.date "year" output.check
1359 format.authors output
1360 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1370 FUNCTION {phdthesis}
1372 format.authors "author" output.check
1373 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1374 format.title "title" output.check
1375 bbl.phdthesis format.thesis.type output.nonnull
1376 school "school" output.check
1379 format.date "year" output.check
1384 FUNCTION {proceedings}
1387 { organization output }
1388 { format.editors output.nonnull }
1390 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1391 format.btitle "title" output.check
1392 format.bvolume output
1393 format.number.series output
1398 format.publisher.address output
1404 format.organization.address output }
1407 format.publisher.address output
1417 FUNCTION {techreport}
1419 format.authors "author" output.check
1420 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1421 format.title "title" output.check
1422 format.tr.number output.nonnull
1423 institution "institution" output.check
1426 format.date "year" output.check
1431 FUNCTION {unpublished}
1433 format.authors "author" output.check
1434 title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
1435 format.title "title" output.check
1436 format.note "note" output.check
1442 FUNCTION {default.type} { misc }
1446 STRINGS { longest.label }
1448 INTEGERS { number.label longest.label.width }
1450 FUNCTION {initialize.longest.label}
1451 { "" 'longest.label :=
1453 #0 'longest.label.width :=
1456 FUNCTION {longest.label.pass}
1457 { number.label int.to.str$ 'label :=
1458 number.label #1 + 'number.label :=
1459 label width$ longest.label.width >
1460 { label 'longest.label :=
1461 label width$ 'longest.label.width :=
1467 EXECUTE {initialize.longest.label}
1469 ITERATE {longest.label.pass}
1471 FUNCTION {begin.bib}
1474 { preamble$ write$ newline$ }
1476 "\begin{thebibliography}{" longest.label * "}" *
1478 "\expandafter\ifx\csname url\endcsname\relax"
1480 " \def\url#1{\texttt{#1}}\fi"
1482 "\expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi"
1484 "\expandafter\ifx\csname href\endcsname\relax"
1486 " \def\href#1#2{#2} \def\path#1{#1}\fi"
1492 EXECUTE {init.urlbst.variables}
1493 EXECUTE {init.state.consts}
1495 ITERATE {call.type$}
1499 "\end{thebibliography}" write$ newline$
1503 %% End of customized bst file
1505 %% End of file `elsarticle-num.bst'.