1 % $Id: mlastyle.bst,v 1.18 2003-11-27 05:11:13 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.date}
522 { "there's a month but no year in " cite$ * warning$
529 { month do.space format.year * }
536 FUNCTION {format.btitle}
537 { title selective.emphasize
540 FUNCTION {tie.or.space.connect}
541 { duplicate$ text.length$ #3 <
548 FUNCTION {either.or.check}
551 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
555 FUNCTION {abbreviate}
556 { duplicate$ sortify 's := 't :=
558 "10th" "tenth" "9th" "ninth" "8th" "eighth" "7th" "seventh" "6th" "sixth"
559 "5th" "fifth" "4th" "fourth" "3rd" "third" "2nd" "second" "1st" "first"
560 "Rev." "revised" "Abr." "abridged"
561 {duplicate$ empty$ { pop$ #0 }{ #1 } if$ }{ s = { 't := }{ pop$ } if$ }
566 FUNCTION {format.bvolume.or.num.series}
569 { series field.or.null }
572 { number "there's a number but no series in " cite$ * warning$ }
574 %output.state mid.sentence =
578 number tie.or.space.connect
584 { "Vol." volume tie.or.space.connect
587 { " of " * series selective.emphasize * add.period$ }
591 { number * " vols." * }
593 %"volume and number" number either.or.check
598 % Changed edition to MLA abbreviation
599 FUNCTION {format.edition}
603 { "Vers.~" version *}
607 duplicate$ sortify "revised" =
611 duplicate$ sortify "abridged" =
616 "edition and version" version either.or.check
621 INTEGERS { multiresult }
623 FUNCTION {multi.page.check}
632 swap$ duplicate$ "," =
635 { #1 'multiresult := }
636 { t #2 global.max$ substring$ 't := }
643 FUNCTION {format.pages}
647 % j is positive if pages contains a comma
648 % (not fully implemented)
650 pages n.dashify duplicate$ 't :=
651 { duplicate$ empty$ not }
653 duplicate$ #1 #1 substring$ duplicate$
662 duplicate$ #1 #2 substring$ ", " =
666 #2 global.max$ substring$
670 { t #1 #2 substring$ "--" = j not and
671 { t #3 global.max$ substring$ 't :=
672 duplicate$ num.chars 'i :=
676 { duplicate$ #1 i #2 - substring$
677 t #1 i #2 - substring$ =
678 { t i #1 - global.max$ substring$ * "" 't := #2 'i := }
687 { t #1 #1 substring$ duplicate$ "," = swap$ "-" = or j and
689 { t #1 #1 substring$ *
690 t #2 global.max$ substring$ 't :=
701 FUNCTION {format.vol.num.year.pages}
706 "there's a number but no volume in " cite$ * warning$ }
713 { "." * number n.dashify * }
715 " (" * format.date * ")" *
720 { ", " * format.edition * }
722 type field.or.null sortify duplicate$ "sec." = swap$ "section" = or
724 { "section type requires chapter in " cite$ warning$ }
725 { ", sec." chapter n.dashify tie.or.space.connect }
730 type field.or.null sortify "review" = chapter empty$ not and
731 { ", sec." chapter n.dashify tie.or.space.connect }
736 { ": " * format.pages * }
740 % chapter might be useful if type is set to "pars."
741 FUNCTION {format.chapter.pages}
743 type field.or.null sortify duplicate$ "def." = swap$ "definition" = or
747 { "chapter ignored in " cite$ * warning$ }
748 { type "t" change.case$
749 chapter n.dashify tie.or.space.connect
761 FUNCTION {empty.misc.check}
762 { author empty$ title empty$ howpublished empty$
763 month empty$ year empty$ note empty$
766 { "all relevant fields are empty in " cite$ * warning$ }
771 FUNCTION {format.thesis.type}
775 type "t" change.case$
780 FUNCTION {format.tr.number}
782 { "Technical Report" }
787 { number tie.or.space.connect }
791 FUNCTION {format.urldate}
794 { database selective.emphasize output.nonnull new.block }
798 { cite$ " has no urldate field" * warning$
801 { "accessdate in " cite$ * " is depreciated; use urldate instead" *
809 FUNCTION {output.url}
814 { format.urldate output }
818 " $<$\url{" * url * "}$>$" *
824 { "Path: " urlpath * output.nonnull }
828 FUNCTION {format.crossref}
830 pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$
831 "{" * crossref * "}" *
835 FUNCTION {cite.title}
836 { title empty$ journal empty$ not and
837 { key empty$ { journal }{ key } if$ selective.emphasize }
838 { title empty$ key empty$ and
839 { "empty title and key in " cite$ * warning$ "" }
840 { key empty$ {title}{key} if$
846 type$ "proceedings" =
848 { selective.emphasize }
851 type$ "incollection" =
852 type$ "inproceedings" =
853 type$ "mastersthesis" =
856 type$ "unpublished" =
858 { selective.enquote }
869 FUNCTION {cite.label}
872 % { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
886 "(" * empty.title * ")" * }
888 author.shared author.different =
889 { "{vv~}{ll}" format.names.custom 's := }
890 { author.shared author.last =
891 { "{f.~}{vv~}{ll}{, jj}" format.names.custom 's := }
892 { author.shared author.flast =
893 { "{ff~}{vv~}{ll}{, jj}" format.names.custom 's := }
894 { "{vv~}{ll}" format.names.custom ", " *
895 cite.title * 's := "WTF" warning$ }
903 author.duplicate { cite.title * }{} if$
904 "){" * swap$ "{ff~}{vv~}{ll}{, jj}" format.names.custom * "}" *
915 FUNCTION {output.bibitem}
924 before.all 'output.state :=
929 format.authors "author" output.check
931 format.title "title" output.check
936 { type sortify "review" =
937 { "Rev.\ of " booktitle selective.emphasize *
938 "booktitle" output.check new.block
940 { "Ignoring invalid type in " cite$ warning$ }
944 journal selective.emphasize "journal" output.check
948 { "[" address * "]" * output
959 { series abbreviate do.space "ser." * "l" change.case$ }
967 format.vol.num.year.pages output
969 { format.crossref output.nonnull
983 { format.editors "author and editor" output.check }
984 { format.authors output.nonnull }
987 format.btitle "title" output.check
990 { author empty$ 'skip$ { format.editors.mid output new.block } if$
991 format.edition output
993 format.bvolume.or.num.series output
995 format.publisher "publisher" output.check
996 format.date "year" output.check
998 {% format.date "year" output
1000 format.crossref output.nonnull
1012 format.authors output
1014 format.btitle "title" output.check
1015 howpublished address new.block.checkb
1027 { format.editors "author and editor" output.check }
1028 { format.authors output.nonnull }
1031 format.btitle "title" output.check
1034 { author empty$ 'skip$ { format.editors.mid output new.block } if$
1035 format.edition output
1037 format.bvolume.or.num.series output
1039 format.publisher "publisher" output.check
1040 format.date "year" output.check
1042 format.chapter.pages "chapter and pages" output.check
1047 format.crossref output.nonnull
1056 FUNCTION {incollection}
1058 format.authors "author" output.check
1060 { new.block type output }
1064 format.title "title" output.check
1065 type field.or.null sortify duplicate$ "definition" = swap$ "def." = or
1066 { new.block "Def.~" chapter field.or.null * "chapter" output.check }
1072 booktitle selective.emphasize "booktitle" output.check
1074 format.editors.mid "editor" output.check
1076 format.edition output
1078 format.bvolume.or.num.series output
1080 format.publisher "publisher" output.check
1082 format.date "year" output.check
1084 format.chapter.pages output
1086 { format.crossref output.nonnull
1087 %format.chapter.pages output
1097 FUNCTION {inproceedings}
1099 format.authors "author" output.check
1101 format.title "title" output.check
1105 booktitle "booktitle" output.check
1107 format.editors.mid output
1109 format.edition output
1111 format.bvolume.or.num.series output
1113 format.edition output
1115 format.publisher output
1116 format.date "year" output.check
1118 %{ organization publisher new.sentence.checkb
1119 % organization output
1121 % format.date "year" output.check
1123 %{ address output.nonnull
1124 % format.date "year" output.check
1126 % organization output
1133 { format.crossref output.nonnull
1143 FUNCTION {conference} { inproceedings }
1148 { organization empty$
1150 { organization output.nonnull
1155 { format.authors output.nonnull }
1158 format.btitle "title" output.check
1160 format.edition output
1163 { organization empty$
1164 { address new.block.checka
1170 { organization address new.block.checkb
1183 FUNCTION {mastersthesis}
1185 format.authors "author" output.check
1187 format.title "title" output.check
1189 "Diss." format.thesis.type output.nonnull
1191 school "school" output.check
1193 format.date "year" output.check
1203 format.authors output
1204 title howpublished new.block.checkb
1207 %howpublished new.block.checka
1218 FUNCTION {phdthesis}
1220 format.authors "author" output.check
1222 format.btitle "title" output.check
1224 "Diss." format.thesis.type output.nonnull
1226 school "school" output.check
1228 format.date "year" output.check
1236 FUNCTION {proceedings}
1239 { organization output }
1240 { format.editors output.nonnull }
1243 format.btitle "title" output.check
1245 format.bvolume.or.num.series output
1248 { publisher new.sentence.checka }
1249 { organization publisher new.sentence.checkb
1254 format.date "year" output.check
1256 { address output.nonnull
1257 format.date "year" output.check
1261 { organization output }
1273 FUNCTION {techreport}
1275 format.authors "author" output.check
1277 format.title "title" output.check
1279 format.tr.number output.nonnull
1281 institution "institution" output.check
1283 format.date "year" output.check
1289 FUNCTION {unpublished}
1291 format.authors "author" output.check
1293 format.title "title" output.check
1297 note "note" output.check
1302 FUNCTION {default.type} { misc }
1304 MACRO {jan} {"Jan."}
1306 MACRO {feb} {"Feb."}
1308 MACRO {mar} {"Mar."}
1310 MACRO {apr} {"Apr."}
1314 MACRO {jun} {"June"}
1316 MACRO {jul} {"July"}
1318 MACRO {aug} {"Aug."}
1320 MACRO {sep} {"Sept."}
1322 MACRO {oct} {"Oct."}
1324 MACRO {nov} {"Nov."}
1326 MACRO {dec} {"Dec."}
1328 % Currently left in to help with compatibility
1330 MACRO {acmcs} {"ACM Computing Surveys"}
1332 MACRO {acta} {"Acta Informatica"}
1334 MACRO {cacm} {"Communications of the ACM"}
1336 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1338 MACRO {ibmsj} {"IBM Systems Journal"}
1340 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1342 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1345 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1347 MACRO {ipl} {"Information Processing Letters"}
1349 MACRO {jacm} {"Journal of the ACM"}
1351 MACRO {jcss} {"Journal of Computer and System Sciences"}
1353 MACRO {scp} {"Science of Computer Programming"}
1355 MACRO {sicomp} {"SIAM Journal on Computing"}
1357 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1359 MACRO {tods} {"ACM Transactions on Database Systems"}
1361 MACRO {tog} {"ACM Transactions on Graphics"}
1363 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1365 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1367 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1369 MACRO {tcs} {"Theoretical Computer Science"}
1375 FUNCTION {chop.word}
1378 s #1 len substring$ =
1379 { s len #1 + global.max$ substring$ }
1384 FUNCTION {sort.format.names}
1388 s num.names$ 'numnames :=
1389 numnames 'namesleft :=
1395 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1396 nameptr numnames = t "others" = and
1400 nameptr #1 + 'nameptr :=
1401 namesleft #1 - 'namesleft :=
1406 FUNCTION {sort.format.title}
1421 #1 global.max$ substring$
1424 FUNCTION {author.sort}
1427 { "to sort, need author or key in " cite$ * warning$
1433 { author sort.format.names }
1437 FUNCTION {author.editor.sort}
1441 { "to sort, need author, editor, or key in " cite$ * warning$
1447 { editor sort.format.names }
1450 { author sort.format.names }
1454 FUNCTION {author.organization.sort}
1456 { organization empty$
1458 { "to sort, need author, organization, or key in " cite$ * warning$
1464 { "The " #4 organization chop.word sortify }
1467 { author sort.format.names }
1471 FUNCTION {editor.organization.sort}
1473 { organization empty$
1475 { "to sort, need editor, organization, or key in " cite$ * warning$
1481 { "The " #4 organization chop.word sortify }
1484 { editor sort.format.names }
1493 { type$ "proceedings" =
1494 'editor.organization.sort
1496 'author.organization.sort
1503 duplicate$ empty$ 'skip$ { " " * } if$
1505 { title field.or.null sort.format.title * " " * booktitle field.or.null sort.format.title * }
1510 year field.or.null sortify
1512 #1 entry.max$ substring$
1522 FUNCTION {init.vars}
1523 { #0 int.to.chr$ 'a :=
1524 #0 int.to.chr$ 'b :=
1529 % Function name is not strictly accurate
1530 FUNCTION {forward.author.dup.check}
1532 url empty$ urlpath empty$ urldate empty$ and and
1534 { url.used #1 + 'url.used := }
1536 crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$
1538 { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1544 { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1545 a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1546 { #1 'author.duplicate := }
1547 { #0 'author.duplicate := }
1554 FUNCTION {forward.author.share.check}
1556 % Pass through all entries, comparing current author to last one.
1558 { author.duplicate author empty$ or
1559 { author.duplicate { i 'author.shared := }{} if$}
1560 { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1561 author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1562 { author.flast 'author.shared := }
1563 { b "{vv~}{ll}" format.names.custom purify$
1564 author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1565 { author.last 'author.shared := }
1566 { author.different 'author.shared := }
1571 author field.or.null 'b :=
1576 FUNCTION {reverse.author}
1580 { i 'author.shared := }
1585 { author.shared i 'author.shared := 'i := }
1586 { author.shared 'i := }
1590 j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1591 author.duplicate 'j :=
1594 EXECUTE {init.consts}
1597 ITERATE {forward.author.dup.check}
1600 ITERATE {forward.author.share.check}
1603 REVERSE {reverse.author}
1605 %INTEGERS { number.label longest.label.width }
1607 %FUNCTION {initialize.longest.label}
1608 %{ "" 'longest.label :=
1609 % #1 'number.label :=
1610 % #0 'longest.label.width :=
1613 %FUNCTION {longest.label.pass}
1614 %{ number.label int.to.str$ 'label :=
1615 % number.label #1 + 'number.label :=
1616 % label width$ longest.label.width >
1617 % { label 'longest.label :=
1618 % label width$ 'longest.label.width :=
1624 %EXECUTE {initialize.longest.label}
1626 %ITERATE {longest.label.pass}
1628 FUNCTION {begin.bib}
1631 { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi"
1637 { "\providecommand\url[1]{\texttt{#1}}"
1639 "\providecommand\theurldate{\today}"
1646 { preamble$ write$ newline$ }
1648 "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1653 ITERATE {call.type$}
1657 "\end{thebibliography}" write$ newline$