1 % $Id: mlastyle.bst,v 1.20 2005-02-09 03:53:11 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.
45 { author.duplicate author.shared }
48 INTEGERS { output.state before.all mid.phrase mid.sentence after.sentence after.block author.different author.last author.flast citealp.used url.used }
50 STRINGS { s t u empty.title }
52 % Rearranged such that true values require capital letters
53 FUNCTION {init.consts}
60 #0 'author.different :=
63 %#3 'author.firstlast :=
67 " \ \ \ \ \unskip\unskip\unskip\unskip\unskip " 'empty.title :=
75 "duplicate should be duplicate$" warning$
98 % text.length$ does not include braces
99 % This function is probably a bad idea
103 { duplicate$ duplicate$ #1 chars substring$ = not }
104 { duplicate$ duplicate$ text.length$ swap$ #1 chars
105 substring$ text.length$ - chars + #1 + 'chars := }
107 { duplicate$ duplicate$ #1 chars #1 - substring$ = }
108 { chars #1 - 'chars := }
113 % Puts the period inside any quotes
116 duplicate$ #-1 #2 substring$ "''" =
118 { duplicate$ #-1 i - #11 substring$ "'\thinspace" = }
121 duplicate$ #-1 i - global.max$ substring$
122 add.period$ swap$ #-1 i substring$ *
125 duplicate$ #-1 #3 substring$ "''}" =
127 { duplicate$ #-1 i - #11 substring$ "'\thinspace" = }
130 duplicate$ #-1 i - global.max$ substring$
131 add.period$ swap$ #-1 i substring$ *
140 { duplicate$ duplicate$ do.period =
146 % Switched to do.period and added mid.phrase
147 FUNCTION {output.nonnull}
149 output.state mid.sentence =
151 { output.state after.block =
156 { output.state before.all =
158 { output.state mid.phrase =
160 { do.period " " * write$ }
166 mid.sentence 'output.state :=
179 FUNCTION {output.check}
182 { pop$ "empty " t * " in " * cite$ * warning$ }
187 % Switched to do.period
195 { output.state before.all =
197 { after.block 'output.state := }
201 FUNCTION {new.sentence}
202 { output.state after.block =
204 { output.state before.all =
206 { after.sentence 'output.state := }
212 FUNCTION {continue.sentence}
213 { output.state after.block =
215 { output.state before.all =
217 { mid.phrase 'output.state := }
223 FUNCTION {new.block.checka}
230 FUNCTION {new.block.checkb}
239 FUNCTION {new.sentence.checka}
246 FUNCTION {new.sentence.checkb}
255 FUNCTION {field.or.null}
270 { "\emph{" swap$ * "}" * }
280 { duplicate$ i #1 substring$ "" = not }
281 { duplicate$ duplicate$ i #1 substring$ quote$ =
282 swap$ i #1 - #1 substring$ "\" = not and %"
283 { duplicate$ #1 i #1 - substring$ swap$
284 i #1 + global.max$ substring$
286 { swap$ duplicate$ #-1 #1 substring$ "'" =
287 { swap$ "\thinspace'" }
292 { duplicate$ #1 #1 substring$ "`" =
307 { "odd number of quotation marks in " cite$ * warning$ }
310 duplicate$ #1 #1 substring$ "`" =
311 { "``\thinspace" swap$ * }
314 duplicate$ #-1 #1 substring$ "'" =
322 FUNCTION {selective.emphasize}
323 { field.or.null duplicate$ sortify 's :=
324 s #1 #8 substring$ duplicate$ "rev. of " = swap$ "rev.~of " = or
325 s #1 #9 substring$ "rev.\ of " = or
327 s "america online" = or
333 FUNCTION {selective.enquote}
334 { field.or.null duplicate$ sortify 's :=
335 s #1 #8 substring$ duplicate$ "rev. of " = swap$ "rev.~of " = or
336 s #1 #9 substring$ "rev.\ of " = or
337 s "introduction" = or
347 INTEGERS { nameptr namesleft numnames }
349 FUNCTION {format.names.custom}
353 s num.names$ 'numnames :=
354 numnames 'namesleft :=
356 { s nameptr u format.name$ 't :=
373 nameptr #1 + 'nameptr :=
374 namesleft #1 - 'namesleft :=
379 FUNCTION {format.names}
380 { "{ff~}{vv~}{ll}{, jj}" format.names.custom }
382 % Changed first author to last name first
383 FUNCTION {format.names.beginning}
386 s num.names$ 'numnames :=
387 numnames 'namesleft :=
390 { s nameptr "{vv~}{ll}{, ff}{, jj}" format.name$
391 duplicate$ #1 #1 substring$ duplicate$ "{" =
395 swap$ #2 global.max$ substring$ * 't :=
397 { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't := }
415 nameptr #1 + 'nameptr :=
416 namesleft #1 - 'namesleft :=
421 % Added check for duplicate authors
422 FUNCTION {format.authors}
425 { author.duplicate #1 =
427 { author format.names.beginning }
433 % Changed to MLA editor abbreviations
434 % author.duplicate also applies
435 FUNCTION {format.editors}
438 { author empty$ author.duplicate #1 = and
440 { editor format.names.beginning }
442 editor num.names$ #1 >
450 FUNCTION {format.editors.mid}
454 editor num.names$ #1 >
458 editor format.names *
463 % Formats the address and publisher
464 FUNCTION {format.publisher}
467 { address ": " * publisher * }
471 % Changed to preserve case and use quotes
472 FUNCTION {format.title}
473 { title selective.enquote
480 { t #1 #1 substring$ "-" =
481 { t #1 #2 substring$ "--" = not
483 t #2 global.max$ substring$ 't :=
485 { { t #1 #1 substring$ "-" = }
487 t #2 global.max$ substring$ 't :=
493 { t #1 #1 substring$ *
494 t #2 global.max$ substring$ 't :=
501 FUNCTION {format.year}
505 duplicate$ duplicate$ num.chars #10 =
506 swap$ #5 #2 substring$ "--" = and
507 { duplicate$ duplicate$ #1 #2 substring$ swap$ #7 #2 substring$ =
508 { duplicate$ #1 #6 substring$ swap$ #9 #2 substring$ * }
518 FUNCTION {format.month}
520 month #-1 #1 substring$ chr.to.int$ duplicate$ #47 > swap$ #58 < and
522 month #-2 #1 substring$ chr.to.int$ duplicate$ #47 > swap$ #58 < and
526 month #-2 i - #2 substring$ "\ " =
527 { month #0 i - i substring$
528 month #-2 i - #2 substring$
529 month #-3 i - global.max$ i - #2 - substring$
533 month #-1 i - #1 substring$ duplicate$ " " = swap$ "~" = or
534 { month #0 i - i substring$
535 month #-1 i - #1 substring$
536 month #-2 i - global.max$ i - #1 - substring$
548 FUNCTION {format.date}
552 { "there's a month but no year in " cite$ * warning$
559 { format.month do.space format.year * }
566 FUNCTION {format.btitle}
567 { title selective.emphasize
570 FUNCTION {tie.or.space.connect}
571 { duplicate$ text.length$ #3 <
573 { swap$ do.space swap$ * }
577 FUNCTION {either.or.check}
580 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
584 FUNCTION {abbreviate}
585 { duplicate$ sortify 's := 't :=
587 "10th" "tenth" "9th" "ninth" "8th" "eighth" "7th" "seventh" "6th" "sixth"
588 "5th" "fifth" "4th" "fourth" "3rd" "third" "2nd" "second" "1st" "first"
589 "Rev." "revised" "Abr." "abridged"
590 {duplicate$ empty$ { pop$ #0 }{ #1 } if$ }{ s = { 't := }{ pop$ } if$ }
595 FUNCTION {format.bvolume.or.num.series}
598 { series field.or.null }
601 { number "there's a number but no series in " cite$ * warning$ }
603 %output.state mid.sentence =
607 number tie.or.space.connect
613 { "Vol." volume tie.or.space.connect
616 { " of " * series selective.emphasize * add.period$ }
620 { number * " vols." * }
622 %"volume and number" number either.or.check
627 % Changed edition to MLA abbreviation
628 FUNCTION {format.edition}
632 { "Vers.~" version *}
636 duplicate$ sortify "revised" =
640 duplicate$ sortify "abridged" =
645 "edition and version" version either.or.check
650 INTEGERS { multiresult }
652 FUNCTION {multi.page.check}
661 swap$ duplicate$ "," =
664 { #1 'multiresult := }
665 { t #2 global.max$ substring$ 't := }
672 FUNCTION {format.pages}
676 % j is positive if pages contains a comma
677 % (not fully implemented)
679 pages n.dashify duplicate$ 't :=
680 { duplicate$ empty$ not }
682 duplicate$ #1 #1 substring$ duplicate$
691 duplicate$ #1 #2 substring$ ", " =
695 #2 global.max$ substring$
699 { t #1 #2 substring$ "--" = j not and
700 { t #3 global.max$ substring$ 't :=
701 duplicate$ num.chars 'i :=
705 { duplicate$ #1 i #2 - substring$
706 t #1 i #2 - substring$ =
707 { t i #1 - global.max$ substring$ * "" 't := #2 'i := }
716 { t #1 #1 substring$ duplicate$ "," = swap$ "-" = or j and
718 { t #1 #1 substring$ *
719 t #2 global.max$ substring$ 't :=
730 FUNCTION {format.vol.num.year.pages}
735 "there's a number but no volume in " cite$ * warning$ }
742 { "." * number n.dashify * }
744 " (" * format.date * ")" *
749 { ", " * format.edition * }
751 type field.or.null sortify duplicate$ "sec." = swap$ "section" = or
753 { "section type requires chapter in " cite$ warning$ }
754 { ", sec." chapter n.dashify tie.or.space.connect }
759 type field.or.null sortify "review" = chapter empty$ not and
760 { ", sec." chapter n.dashify tie.or.space.connect }
765 { ": " * format.pages * }
769 % chapter might be useful if type is set to "pars."
770 FUNCTION {format.chapter.pages}
772 type field.or.null sortify duplicate$ "def." = swap$ "definition" = or
776 { "chapter ignored in " cite$ * warning$ }
777 { type "t" change.case$
778 chapter n.dashify tie.or.space.connect
790 FUNCTION {empty.misc.check}
791 { author empty$ title empty$ howpublished empty$
792 month empty$ year empty$ note empty$
795 { "all relevant fields are empty in " cite$ * warning$ }
800 FUNCTION {format.thesis.type}
804 type "t" change.case$
809 FUNCTION {format.tr.number}
811 { "Technical Report" }
816 { number tie.or.space.connect }
820 FUNCTION {format.urldate}
823 { database selective.emphasize output.nonnull new.block }
827 { cite$ " has no urldate field" * warning$
830 { "accessdate in " cite$ * " is depreciated; use urldate instead" *
838 FUNCTION {output.url}
843 { format.urldate output }
847 " $<$\url{" * url * "}$>$" *
853 { "Path: " urlpath * output.nonnull }
857 FUNCTION {format.crossref}
859 pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$
860 "{" * crossref * "}" *
864 FUNCTION {cite.title}
865 { title empty$ journal empty$ not and
866 { key empty$ { journal }{ key } if$ selective.emphasize }
867 { title empty$ key empty$ and
868 { "empty title and key in " cite$ * warning$ "" }
869 { key empty$ {title}{key} if$
875 type$ "proceedings" =
877 { selective.emphasize }
880 type$ "incollection" =
881 type$ "inproceedings" =
882 type$ "mastersthesis" =
885 type$ "unpublished" =
887 { selective.enquote }
898 FUNCTION {cite.label}
901 % { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
915 "(" * empty.title * ")" * }
917 author.shared author.different =
918 { "{vv~}{ll}" format.names.custom 's := }
919 { author.shared author.last =
920 { "{f.~}{vv~}{ll}{, jj}" format.names.custom 's := }
921 { author.shared author.flast =
922 { "{ff~}{vv~}{ll}{, jj}" format.names.custom 's := }
923 { "{vv~}{ll}" format.names.custom ", " *
924 cite.title * 's := "WTF" warning$ }
932 author.duplicate { cite.title * }{} if$
933 "){" * swap$ "{ff~}{vv~}{ll}{, jj}" format.names.custom * "}" *
944 FUNCTION {output.bibitem}
953 before.all 'output.state :=
958 format.authors "author" output.check
960 format.title "title" output.check
965 { type sortify "review" =
966 { "Rev.\ of " booktitle selective.emphasize *
967 "booktitle" output.check new.block
969 { "Ignoring invalid type in " cite$ warning$ }
973 journal selective.emphasize "journal" output.check
977 { "[" address * "]" * output
988 { series abbreviate do.space "ser." * "l" change.case$ }
996 format.vol.num.year.pages output
998 { format.crossref output.nonnull
1012 { format.editors "author and editor" output.check }
1013 { format.authors output.nonnull }
1016 format.btitle "title" output.check
1019 { author empty$ 'skip$ { format.editors.mid output new.block } if$
1020 format.edition output
1022 format.bvolume.or.num.series output
1024 format.publisher "publisher" output.check
1025 format.date "year" output.check
1027 {% format.date "year" output
1029 format.crossref output.nonnull
1041 format.authors output
1043 format.btitle "title" output.check
1044 howpublished address new.block.checkb
1056 { format.editors "author and editor" output.check }
1057 { format.authors output.nonnull }
1060 format.btitle "title" output.check
1063 { author empty$ 'skip$ { format.editors.mid output new.block } if$
1064 format.edition output
1066 format.bvolume.or.num.series output
1068 format.publisher "publisher" output.check
1069 format.date "year" output.check
1071 format.chapter.pages "chapter and pages" output.check
1076 format.crossref output.nonnull
1085 FUNCTION {incollection}
1087 format.authors "author" output.check
1089 { new.block type output }
1093 format.title "title" output.check
1094 type field.or.null sortify duplicate$ "definition" = swap$ "def." = or
1095 { new.block "Def.~" chapter field.or.null * "chapter" output.check }
1101 booktitle selective.emphasize "booktitle" output.check
1103 format.editors.mid "editor" output.check
1105 format.edition output
1107 format.bvolume.or.num.series output
1109 format.publisher "publisher" output.check
1111 format.date "year" output.check
1113 format.chapter.pages output
1115 { format.crossref output.nonnull
1116 %format.chapter.pages output
1126 FUNCTION {inproceedings}
1128 format.authors "author" output.check
1130 format.title "title" output.check
1134 booktitle "booktitle" output.check
1136 format.editors.mid output
1138 format.edition output
1140 format.bvolume.or.num.series output
1142 format.edition output
1144 format.publisher output
1145 format.date "year" output.check
1147 %{ organization publisher new.sentence.checkb
1148 % organization output
1150 % format.date "year" output.check
1152 %{ address output.nonnull
1153 % format.date "year" output.check
1155 % organization output
1162 { format.crossref output.nonnull
1172 FUNCTION {conference} { inproceedings }
1177 { organization empty$
1179 { organization output.nonnull
1184 { format.authors output.nonnull }
1187 format.btitle "title" output.check
1189 format.edition output
1192 { organization empty$
1193 { address new.block.checka
1199 { organization address new.block.checkb
1212 FUNCTION {mastersthesis}
1214 format.authors "author" output.check
1216 format.title "title" output.check
1218 "Diss." format.thesis.type output.nonnull
1220 school "school" output.check
1222 format.date "year" output.check
1232 format.authors output
1233 title howpublished new.block.checkb
1236 %howpublished new.block.checka
1247 FUNCTION {phdthesis}
1249 format.authors "author" output.check
1251 format.btitle "title" output.check
1253 "Diss." format.thesis.type output.nonnull
1255 school "school" output.check
1257 format.date "year" output.check
1265 FUNCTION {proceedings}
1268 { organization output }
1269 { format.editors output.nonnull }
1272 format.btitle "title" output.check
1274 format.bvolume.or.num.series output
1277 { publisher new.sentence.checka }
1278 { organization publisher new.sentence.checkb
1283 format.date "year" output.check
1285 { address output.nonnull
1286 format.date "year" output.check
1290 { organization output }
1302 FUNCTION {techreport}
1304 format.authors "author" output.check
1306 format.title "title" output.check
1308 format.tr.number output.nonnull
1310 institution "institution" output.check
1312 format.date "year" output.check
1318 FUNCTION {unpublished}
1320 format.authors "author" output.check
1322 format.title "title" output.check
1326 note "note" output.check
1331 FUNCTION {default.type} { misc }
1333 MACRO {jan} {"Jan."}
1335 MACRO {feb} {"Feb."}
1337 MACRO {mar} {"Mar."}
1339 MACRO {apr} {"Apr."}
1343 MACRO {jun} {"June"}
1345 MACRO {jul} {"July"}
1347 MACRO {aug} {"Aug."}
1349 MACRO {sep} {"Sept."}
1351 MACRO {oct} {"Oct."}
1353 MACRO {nov} {"Nov."}
1355 MACRO {dec} {"Dec."}
1357 % Currently left in to help with compatibility
1359 MACRO {acmcs} {"ACM Computing Surveys"}
1361 MACRO {acta} {"Acta Informatica"}
1363 MACRO {cacm} {"Communications of the ACM"}
1365 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1367 MACRO {ibmsj} {"IBM Systems Journal"}
1369 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1371 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1374 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1376 MACRO {ipl} {"Information Processing Letters"}
1378 MACRO {jacm} {"Journal of the ACM"}
1380 MACRO {jcss} {"Journal of Computer and System Sciences"}
1382 MACRO {scp} {"Science of Computer Programming"}
1384 MACRO {sicomp} {"SIAM Journal on Computing"}
1386 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1388 MACRO {tods} {"ACM Transactions on Database Systems"}
1390 MACRO {tog} {"ACM Transactions on Graphics"}
1392 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1394 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1396 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1398 MACRO {tcs} {"Theoretical Computer Science"}
1404 FUNCTION {chop.word}
1407 s #1 len substring$ =
1408 { s len #1 + global.max$ substring$ }
1413 FUNCTION {sort.format.names}
1417 s num.names$ 'numnames :=
1418 numnames 'namesleft :=
1424 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1425 nameptr numnames = t "others" = and
1429 nameptr #1 + 'nameptr :=
1430 namesleft #1 - 'namesleft :=
1435 FUNCTION {sort.format.title}
1450 #1 global.max$ substring$
1453 FUNCTION {author.sort}
1456 { "to sort, need author or key in " cite$ * warning$
1462 { author sort.format.names }
1466 FUNCTION {author.editor.sort}
1470 { "to sort, need author, editor, or key in " cite$ * warning$
1476 { editor sort.format.names }
1479 { author sort.format.names }
1483 FUNCTION {author.organization.sort}
1485 { organization empty$
1487 { "to sort, need author, organization, or key in " cite$ * warning$
1493 { "The " #4 organization chop.word sortify }
1496 { author sort.format.names }
1500 FUNCTION {editor.organization.sort}
1502 { organization empty$
1504 { "to sort, need editor, organization, or key in " cite$ * warning$
1510 { "The " #4 organization chop.word sortify }
1513 { editor sort.format.names }
1522 { type$ "proceedings" =
1523 'editor.organization.sort
1525 'author.organization.sort
1532 duplicate$ empty$ 'skip$ { " " * } if$
1534 { title field.or.null sort.format.title * " " * booktitle field.or.null sort.format.title * }
1539 year field.or.null sortify
1541 #1 entry.max$ substring$
1551 FUNCTION {init.vars}
1552 { #0 int.to.chr$ 'a :=
1553 #0 int.to.chr$ 'b :=
1558 % Function name is not strictly accurate
1559 FUNCTION {forward.author.dup.check}
1561 url empty$ urlpath empty$ urldate empty$ and and
1563 { url.used #1 + 'url.used := }
1565 crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$
1567 { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1573 { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1574 a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1575 { #1 'author.duplicate := }
1576 { #0 'author.duplicate := }
1583 FUNCTION {forward.author.share.check}
1585 % Pass through all entries, comparing current author to last one.
1587 { author.duplicate author empty$ or
1588 { author.duplicate { i 'author.shared := }{} if$}
1589 { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1590 author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1591 { author.flast 'author.shared := }
1592 { b "{vv~}{ll}" format.names.custom purify$
1593 author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1594 { author.last 'author.shared := }
1595 { author.different 'author.shared := }
1600 author field.or.null 'b :=
1605 FUNCTION {reverse.author}
1609 { i 'author.shared := }
1614 { author.shared i 'author.shared := 'i := }
1615 { author.shared 'i := }
1619 j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1620 author.duplicate 'j :=
1623 EXECUTE {init.consts}
1626 ITERATE {forward.author.dup.check}
1629 ITERATE {forward.author.share.check}
1632 REVERSE {reverse.author}
1634 %INTEGERS { number.label longest.label.width }
1636 %FUNCTION {initialize.longest.label}
1637 %{ "" 'longest.label :=
1638 % #1 'number.label :=
1639 % #0 'longest.label.width :=
1642 %FUNCTION {longest.label.pass}
1643 %{ number.label int.to.str$ 'label :=
1644 % number.label #1 + 'number.label :=
1645 % label width$ longest.label.width >
1646 % { label 'longest.label :=
1647 % label width$ 'longest.label.width :=
1653 %EXECUTE {initialize.longest.label}
1655 %ITERATE {longest.label.pass}
1657 FUNCTION {begin.bib}
1660 { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi"
1666 { "\providecommand\url[1]{\texttt{#1}}"
1668 "\providecommand\theurldate{\today}"
1675 { preamble$ write$ newline$ }
1677 "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1682 ITERATE {call.type$}
1686 "\end{thebibliography}" write$ newline$