1 % $Id: mlastyle.bst,v 1.17 2003-11-26 19:24:27 tpope Exp $
2 % BibTeX bibliography style `mlastyle'
3 % Based on BibTeX standard bibliography style `plain'
4 % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
5 % Copyright (C) 2003 Tim Pope, all rights reserved.
6 % Copying of this file is authorized only if either
7 % (1) you make absolutely no changes to your copy, including name, or
8 % (2) if you do make changes, you name it something other than
9 % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst.
10 % This restriction helps ensure that all standard styles are identical.
11 % The file mlastyle.dvi has the documentation for this style.
44 { author.duplicate author.shared }
47 INTEGERS { output.state before.all mid.phrase mid.sentence after.sentence after.block author.different author.last author.flast citealp.used url.used }
49 STRINGS { s t u empty.title }
51 % Rearranged such that true values require capital letters
52 FUNCTION {init.consts}
59 #0 'author.different :=
62 %#3 'author.firstlast :=
66 " \ \ \ \ \unskip\unskip\unskip\unskip\unskip " 'empty.title :=
74 "duplicate should be duplicate$" warning$
97 % text.length$ does not include braces
98 % This function is probably a bad idea
102 { duplicate$ duplicate$ #1 chars substring$ = not }
103 { duplicate$ duplicate$ text.length$ swap$ #1 chars
104 substring$ text.length$ - chars + #1 + 'chars := }
106 { duplicate$ duplicate$ #1 chars #1 - substring$ = }
107 { chars #1 - 'chars := }
112 % Puts the period inside any quotes
115 duplicate$ #-1 #2 substring$ "''" =
117 { duplicate$ #-1 i - #11 substring$ "'\thinspace" = }
120 duplicate$ #-1 i - global.max$ substring$
121 add.period$ swap$ #-1 i substring$ *
124 duplicate$ #-1 #3 substring$ "''}" =
126 { duplicate$ #-1 i - #11 substring$ "'\thinspace" = }
129 duplicate$ #-1 i - global.max$ substring$
130 add.period$ swap$ #-1 i substring$ *
139 { duplicate$ duplicate$ do.period =
145 % Switched to do.period and added mid.phrase
146 FUNCTION {output.nonnull}
148 output.state mid.sentence =
150 { output.state after.block =
155 { output.state before.all =
157 { output.state mid.phrase =
159 { do.period " " * write$ }
165 mid.sentence 'output.state :=
178 FUNCTION {output.check}
181 { pop$ "empty " t * " in " * cite$ * warning$ }
186 % Switched to do.period
194 { output.state before.all =
196 { after.block 'output.state := }
200 FUNCTION {new.sentence}
201 { output.state after.block =
203 { output.state before.all =
205 { after.sentence 'output.state := }
211 FUNCTION {continue.sentence}
212 { output.state after.block =
214 { output.state before.all =
216 { mid.phrase 'output.state := }
222 FUNCTION {new.block.checka}
229 FUNCTION {new.block.checkb}
238 FUNCTION {new.sentence.checka}
245 FUNCTION {new.sentence.checkb}
254 FUNCTION {field.or.null}
269 { "\emph{" swap$ * "}" * }
279 { duplicate$ i #1 substring$ "" = not }
280 { duplicate$ duplicate$ i #1 substring$ quote$ =
281 swap$ i #1 - #1 substring$ "\" = not and %"
282 { duplicate$ #1 i #1 - substring$ swap$
283 i #1 + global.max$ substring$
285 { swap$ duplicate$ #-1 #1 substring$ "'" =
286 { swap$ "\thinspace'" }
291 { duplicate$ #1 #1 substring$ "`" =
306 { "odd number of quotation marks in " cite$ * warning$ }
309 duplicate$ #1 #1 substring$ "`" =
310 { "``\thinspace" swap$ * }
313 duplicate$ #-1 #1 substring$ "'" =
321 FUNCTION {selective.emphasize}
322 { field.or.null duplicate$ sortify 's :=
323 s #1 #8 substring$ duplicate$ "rev. of " = swap$ "rev.~of " = or
324 s #1 #9 substring$ "rev.\ of " = or
326 s "america online" = or
332 FUNCTION {selective.enquote}
333 { field.or.null duplicate$ sortify 's :=
334 s #1 #8 substring$ duplicate$ "rev. of " = swap$ "rev.~of " = or
335 s #1 #9 substring$ "rev.\ of " = or
336 s "introduction" = or
346 INTEGERS { nameptr namesleft numnames }
348 FUNCTION {format.names.custom}
352 s num.names$ 'numnames :=
353 numnames 'namesleft :=
355 { s nameptr u format.name$ 't :=
372 nameptr #1 + 'nameptr :=
373 namesleft #1 - 'namesleft :=
378 FUNCTION {format.names}
379 { "{ff~}{vv~}{ll}{, jj}" format.names.custom }
381 % Changed first author to last name first
382 FUNCTION {format.names.beginning}
385 s num.names$ 'numnames :=
386 numnames 'namesleft :=
389 { s nameptr "{vv~}{ll}{, ff}{, jj}" format.name$
390 duplicate$ #1 #1 substring$ duplicate$ "{" =
394 swap$ #2 global.max$ substring$ * 't :=
396 { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't := }
414 nameptr #1 + 'nameptr :=
415 namesleft #1 - 'namesleft :=
420 % Added check for duplicate authors
421 FUNCTION {format.authors}
424 { author.duplicate #1 =
426 { author format.names.beginning }
432 % Changed to MLA editor abbreviations
433 % author.duplicate also applies
434 FUNCTION {format.editors}
437 { author empty$ author.duplicate #1 = and
439 { editor format.names.beginning }
441 editor num.names$ #1 >
449 FUNCTION {format.editors.mid}
453 editor num.names$ #1 >
457 editor format.names *
462 % Formats the address and publisher
463 FUNCTION {format.publisher}
466 { address ": " * publisher * }
470 % Changed to preserve case and use quotes
471 FUNCTION {format.title}
472 { title selective.enquote
479 { t #1 #1 substring$ "-" =
480 { t #1 #2 substring$ "--" = not
482 t #2 global.max$ substring$ 't :=
484 { { t #1 #1 substring$ "-" = }
486 t #2 global.max$ substring$ 't :=
492 { t #1 #1 substring$ *
493 t #2 global.max$ substring$ 't :=
500 FUNCTION {format.year}
504 duplicate$ duplicate$ num.chars #10 =
505 swap$ #5 #2 substring$ "--" = and
506 { duplicate$ duplicate$ #1 #2 substring$ swap$ #7 #2 substring$ =
507 { duplicate$ #1 #6 substring$ swap$ #9 #2 substring$ * }
517 FUNCTION {format.date}
521 { "there's a month but no year in " cite$ * warning$
528 { month do.space format.year * }
535 FUNCTION {format.btitle}
536 { title selective.emphasize
539 FUNCTION {tie.or.space.connect}
540 { duplicate$ text.length$ #3 <
547 FUNCTION {either.or.check}
550 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
554 FUNCTION {abbreviate}
555 { duplicate$ sortify 's := 't :=
557 "10th" "tenth" "9th" "ninth" "8th" "eighth" "7th" "seventh" "6th" "sixth"
558 "5th" "fifth" "4th" "fourth" "3rd" "third" "2nd" "second" "1st" "first"
559 "Rev." "revised" "Abr." "abridged"
560 {duplicate$ empty$ { pop$ #0 }{ #1 } if$ }{ s = { 't := }{ pop$ } if$ }
565 FUNCTION {format.bvolume.or.num.series}
568 { series field.or.null }
571 { number "there's a number but no series in " cite$ * warning$ }
573 %output.state mid.sentence =
577 number tie.or.space.connect
583 { "Vol." volume tie.or.space.connect
586 { " of " * series selective.emphasize * add.period$ }
590 { number * " vols." * }
592 %"volume and number" number either.or.check
597 % Changed edition to MLA abbreviation
598 FUNCTION {format.edition}
602 { "Vers.~" version *}
606 duplicate$ sortify "revised" =
610 duplicate$ sortify "abridged" =
615 "edition and version" version either.or.check
620 INTEGERS { multiresult }
622 FUNCTION {multi.page.check}
631 swap$ duplicate$ "," =
634 { #1 'multiresult := }
635 { t #2 global.max$ substring$ 't := }
642 FUNCTION {format.pages}
646 % j is positive if pages contains a comma
647 % (not fully implemented)
649 pages n.dashify duplicate$ 't :=
650 { duplicate$ empty$ not }
652 duplicate$ #1 #1 substring$ duplicate$
661 duplicate$ #1 #2 substring$ ", " =
665 #2 global.max$ substring$
669 { t #1 #2 substring$ "--" = j not and
670 { t #3 global.max$ substring$ 't :=
671 duplicate$ num.chars 'i :=
675 { duplicate$ #1 i #2 - substring$
676 t #1 i #2 - substring$ =
677 { t i #1 - global.max$ substring$ * "" 't := #2 'i := }
686 { t #1 #1 substring$ duplicate$ "," = swap$ "-" = or j and
688 { t #1 #1 substring$ *
689 t #2 global.max$ substring$ 't :=
700 FUNCTION {format.vol.num.year.pages}
705 "there's a number but no volume in " cite$ * warning$ }
712 { "." * number n.dashify * }
714 " (" * format.date * ")" *
719 { ", " * format.edition * }
721 type field.or.null sortify duplicate$ "sec." = swap$ "section" = or
723 { "section type requires chapter in " cite$ warning$ }
724 { ", sec." chapter n.dashify tie.or.space.connect }
729 type field.or.null sortify "review" = chapter empty$ not and
730 { ", sec." chapter n.dashify tie.or.space.connect }
735 { ": " * format.pages * }
739 % chapter might be useful if type is set to "pars."
740 FUNCTION {format.chapter.pages}
742 type field.or.null sortify duplicate$ "def." = swap$ "definition" = or
746 { "chapter ignored in " cite$ * warning$ }
747 { type "t" change.case$
748 chapter n.dashify tie.or.space.connect
760 FUNCTION {empty.misc.check}
761 { author empty$ title empty$ howpublished empty$
762 month empty$ year empty$ note empty$
765 { "all relevant fields are empty in " cite$ * warning$ }
770 FUNCTION {format.thesis.type}
774 type "t" change.case$
779 FUNCTION {format.tr.number}
781 { "Technical Report" }
786 { number tie.or.space.connect }
790 FUNCTION {format.urldate}
793 { cite$ " has no urldate field" * warning$
796 { "accessdate in " cite$ * " is depreciated; use urldate instead" *
804 FUNCTION {output.url}
809 { format.urldate output }
813 " $<$\url{" * url * "}$>$" *
819 { "Path: " urlpath * output.nonnull }
823 FUNCTION {format.crossref}
825 pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$
826 "{" * crossref * "}" *
830 FUNCTION {cite.title}
831 { title empty$ journal empty$ not and
832 { key empty$ { journal }{ key } if$ selective.emphasize }
833 { title empty$ key empty$ and
834 { "empty title and key in " cite$ * warning$ "" }
835 { key empty$ {title}{key} if$
841 type$ "proceedings" =
843 { selective.emphasize }
846 type$ "incollection" =
847 type$ "inproceedings" =
848 type$ "mastersthesis" =
851 type$ "unpublished" =
853 { selective.enquote }
864 FUNCTION {cite.label}
867 % { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
881 "(" * empty.title * ")" * }
883 author.shared author.different =
884 { "{vv~}{ll}" format.names.custom 's := }
885 { author.shared author.last =
886 { "{f.~}{vv~}{ll}{, jj}" format.names.custom 's := }
887 { author.shared author.flast =
888 { "{ff~}{vv~}{ll}{, jj}" format.names.custom 's := }
889 { "{vv~}{ll}" format.names.custom ", " *
890 cite.title * 's := "WTF" warning$ }
898 author.duplicate { cite.title * }{} if$
899 "){" * swap$ "{ff~}{vv~}{ll}{, jj}" format.names.custom * "}" *
910 FUNCTION {output.bibitem}
919 before.all 'output.state :=
924 format.authors "author" output.check
926 format.title "title" output.check
931 { type sortify "review" =
932 { "Rev.\ of " booktitle selective.emphasize *
933 "booktitle" output.check new.block
935 { "Ignoring invalid type in " cite$ warning$ }
939 journal selective.emphasize "journal" output.check
943 { "[" address * "]" * output
954 { series abbreviate do.space "ser." * "l" change.case$ }
962 format.vol.num.year.pages output
964 { format.crossref output.nonnull
978 { format.editors "author and editor" output.check }
979 { format.authors output.nonnull }
982 format.btitle "title" output.check
985 { author empty$ 'skip$ { format.editors.mid output new.block } if$
986 format.edition output
988 format.bvolume.or.num.series output
990 format.publisher "publisher" output.check
991 format.date "year" output.check
993 {% format.date "year" output
995 format.crossref output.nonnull
1007 format.authors output
1009 format.btitle "title" output.check
1010 howpublished address new.block.checkb
1022 { format.editors "author and editor" output.check }
1023 { format.authors output.nonnull }
1026 format.btitle "title" output.check
1029 { author empty$ 'skip$ { format.editors.mid output new.block } if$
1030 format.edition output
1032 format.bvolume.or.num.series output
1034 format.publisher "publisher" output.check
1035 format.date "year" output.check
1037 format.chapter.pages "chapter and pages" output.check
1042 format.crossref output.nonnull
1051 FUNCTION {incollection}
1053 format.authors "author" output.check
1055 { new.block type output }
1059 format.title "title" output.check
1060 type field.or.null sortify duplicate$ "definition" = swap$ "def." = or
1061 { new.block "Def.~" chapter field.or.null * "chapter" output.check }
1067 booktitle selective.emphasize "booktitle" output.check
1069 format.editors.mid "editor" output.check
1071 format.edition output
1073 format.bvolume.or.num.series output
1075 format.publisher "publisher" output.check
1077 format.date "year" output.check
1079 format.chapter.pages output
1081 { format.crossref output.nonnull
1082 %format.chapter.pages output
1092 FUNCTION {inproceedings}
1094 format.authors "author" output.check
1096 format.title "title" output.check
1100 booktitle "booktitle" output.check
1102 format.editors.mid output
1104 format.edition output
1106 format.bvolume.or.num.series output
1108 format.edition output
1110 format.publisher output
1111 format.date "year" output.check
1113 %{ organization publisher new.sentence.checkb
1114 % organization output
1116 % format.date "year" output.check
1118 %{ address output.nonnull
1119 % format.date "year" output.check
1121 % organization output
1128 { format.crossref output.nonnull
1138 FUNCTION {conference} { inproceedings }
1143 { organization empty$
1145 { organization output.nonnull
1150 { format.authors output.nonnull }
1153 format.btitle "title" output.check
1155 format.edition output
1158 { organization empty$
1159 { address new.block.checka
1165 { organization address new.block.checkb
1178 FUNCTION {mastersthesis}
1180 format.authors "author" output.check
1182 format.title "title" output.check
1184 "Diss." format.thesis.type output.nonnull
1186 school "school" output.check
1188 format.date "year" output.check
1198 format.authors output
1199 title howpublished new.block.checkb
1202 %howpublished new.block.checka
1213 FUNCTION {phdthesis}
1215 format.authors "author" output.check
1217 format.btitle "title" output.check
1219 "Diss." format.thesis.type output.nonnull
1221 school "school" output.check
1223 format.date "year" output.check
1231 FUNCTION {proceedings}
1234 { organization output }
1235 { format.editors output.nonnull }
1238 format.btitle "title" output.check
1240 format.bvolume.or.num.series output
1243 { publisher new.sentence.checka }
1244 { organization publisher new.sentence.checkb
1249 format.date "year" output.check
1251 { address output.nonnull
1252 format.date "year" output.check
1256 { organization output }
1268 FUNCTION {techreport}
1270 format.authors "author" output.check
1272 format.title "title" output.check
1274 format.tr.number output.nonnull
1276 institution "institution" output.check
1278 format.date "year" output.check
1284 FUNCTION {unpublished}
1286 format.authors "author" output.check
1288 format.title "title" output.check
1292 note "note" output.check
1297 FUNCTION {default.type} { misc }
1299 MACRO {jan} {"Jan."}
1301 MACRO {feb} {"Feb."}
1303 MACRO {mar} {"Mar."}
1305 MACRO {apr} {"Apr."}
1309 MACRO {jun} {"June"}
1311 MACRO {jul} {"July"}
1313 MACRO {aug} {"Aug."}
1315 MACRO {sep} {"Sept."}
1317 MACRO {oct} {"Oct."}
1319 MACRO {nov} {"Nov."}
1321 MACRO {dec} {"Dec."}
1323 % Currently left in to help with compatibility
1325 MACRO {acmcs} {"ACM Computing Surveys"}
1327 MACRO {acta} {"Acta Informatica"}
1329 MACRO {cacm} {"Communications of the ACM"}
1331 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1333 MACRO {ibmsj} {"IBM Systems Journal"}
1335 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1337 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1340 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1342 MACRO {ipl} {"Information Processing Letters"}
1344 MACRO {jacm} {"Journal of the ACM"}
1346 MACRO {jcss} {"Journal of Computer and System Sciences"}
1348 MACRO {scp} {"Science of Computer Programming"}
1350 MACRO {sicomp} {"SIAM Journal on Computing"}
1352 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1354 MACRO {tods} {"ACM Transactions on Database Systems"}
1356 MACRO {tog} {"ACM Transactions on Graphics"}
1358 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1360 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1362 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1364 MACRO {tcs} {"Theoretical Computer Science"}
1370 FUNCTION {chop.word}
1373 s #1 len substring$ =
1374 { s len #1 + global.max$ substring$ }
1379 FUNCTION {sort.format.names}
1383 s num.names$ 'numnames :=
1384 numnames 'namesleft :=
1390 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1391 nameptr numnames = t "others" = and
1395 nameptr #1 + 'nameptr :=
1396 namesleft #1 - 'namesleft :=
1401 FUNCTION {sort.format.title}
1416 #1 global.max$ substring$
1419 FUNCTION {author.sort}
1422 { "to sort, need author or key in " cite$ * warning$
1428 { author sort.format.names }
1432 FUNCTION {author.editor.sort}
1436 { "to sort, need author, editor, or key in " cite$ * warning$
1442 { editor sort.format.names }
1445 { author sort.format.names }
1449 FUNCTION {author.organization.sort}
1451 { organization empty$
1453 { "to sort, need author, organization, or key in " cite$ * warning$
1459 { "The " #4 organization chop.word sortify }
1462 { author sort.format.names }
1466 FUNCTION {editor.organization.sort}
1468 { organization empty$
1470 { "to sort, need editor, organization, or key in " cite$ * warning$
1476 { "The " #4 organization chop.word sortify }
1479 { editor sort.format.names }
1488 { type$ "proceedings" =
1489 'editor.organization.sort
1491 'author.organization.sort
1498 duplicate$ empty$ 'skip$ { " " * } if$
1500 { title field.or.null sort.format.title * " " * booktitle field.or.null sort.format.title * }
1505 year field.or.null sortify
1507 #1 entry.max$ substring$
1517 FUNCTION {init.vars}
1518 { #0 int.to.chr$ 'a :=
1519 #0 int.to.chr$ 'b :=
1524 % Function name is not strictly accurate
1525 FUNCTION {forward.author.dup.check}
1527 url empty$ urlpath empty$ urldate empty$ and and
1529 { url.used #1 + 'url.used := }
1531 crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$
1533 { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1539 { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1540 a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1541 { #1 'author.duplicate := }
1542 { #0 'author.duplicate := }
1549 FUNCTION {forward.author.share.check}
1551 % Pass through all entries, comparing current author to last one.
1553 { author.duplicate author empty$ or
1554 { author.duplicate { i 'author.shared := }{} if$}
1555 { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1556 author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1557 { author.flast 'author.shared := }
1558 { b "{vv~}{ll}" format.names.custom purify$
1559 author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1560 { author.last 'author.shared := }
1561 { author.different 'author.shared := }
1566 author field.or.null 'b :=
1571 FUNCTION {reverse.author}
1575 { i 'author.shared := }
1580 { author.shared i 'author.shared := 'i := }
1581 { author.shared 'i := }
1585 j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1586 author.duplicate 'j :=
1589 EXECUTE {init.consts}
1592 ITERATE {forward.author.dup.check}
1595 ITERATE {forward.author.share.check}
1598 REVERSE {reverse.author}
1600 %INTEGERS { number.label longest.label.width }
1602 %FUNCTION {initialize.longest.label}
1603 %{ "" 'longest.label :=
1604 % #1 'number.label :=
1605 % #0 'longest.label.width :=
1608 %FUNCTION {longest.label.pass}
1609 %{ number.label int.to.str$ 'label :=
1610 % number.label #1 + 'number.label :=
1611 % label width$ longest.label.width >
1612 % { label 'longest.label :=
1613 % label width$ 'longest.label.width :=
1619 %EXECUTE {initialize.longest.label}
1621 %ITERATE {longest.label.pass}
1623 FUNCTION {begin.bib}
1626 { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi"
1632 { "\providecommand\url[1]{\texttt{#1}}"
1634 "\providecommand\theurldate{\today}"
1641 { preamble$ write$ newline$ }
1643 "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1648 ITERATE {call.type$}
1652 "\end{thebibliography}" write$ newline$