1 % $Id: mlastyle.bst,v 1.12 2003-11-22 05:54:34 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.
43 { author.duplicate author.shared }
46 INTEGERS { output.state before.all mid.sentence after.sentence after.block after.title author.different author.last author.flast citealp.used url.used }
48 STRINGS { s t u empty.title }
50 % Rearranged such that true values require capital letters
51 FUNCTION {init.consts}
58 #0 'author.different :=
61 %#3 'author.firstlast :=
65 " \ \ \ \ \unskip\unskip\unskip\unskip\unskip " 'empty.title :=
89 % text.length$ does not include braces
90 % ...this function is probably unnecessary
94 { duplicate$ duplicate$ #1 chars substring$ = not }
95 { duplicate$ duplicate$ text.length$ swap$ #1 chars
96 substring$ text.length$ - chars + #1 + 'chars := }
98 { duplicate$ duplicate$ #1 chars #1 - substring$ = }
99 { chars #1 - 'chars := }
104 % Puts the period inside any quotes
107 duplicate$ #-1 #2 substring$ "''" =
109 { duplicate$ #-1 i - #11 substring$ "'\thinspace" = }
112 duplicate$ #-1 i - global.max$ substring$
113 add.period$ swap$ #-1 i substring$ *
116 duplicate$ #-1 #3 substring$ "''}" =
118 { duplicate$ #-1 i - #11 substring$ "'\thinspace" = }
121 duplicate$ #-1 i - global.max$ substring$
122 add.period$ swap$ #-1 i substring$ *
130 % Switched to do.period and added after.title
131 FUNCTION {output.nonnull}
133 output.state mid.sentence =
135 { output.state after.block =
140 { output.state before.all =
142 { output.state after.title =
144 { do.period " " * write$ }
150 mid.sentence 'output.state :=
163 FUNCTION {output.check}
166 { pop$ "empty " t * " in " * cite$ * warning$ }
171 % Switched to do.period
179 { output.state before.all =
181 { after.block 'output.state := }
185 FUNCTION {new.sentence}
186 { output.state after.block =
188 { output.state before.all =
190 { after.sentence 'output.state := }
197 %{ output.state after.block =
199 % { output.state before.all =
201 % { after.title 'output.state := }
207 FUNCTION {new.block.checka}
214 FUNCTION {new.block.checkb}
223 FUNCTION {new.sentence.checka}
230 FUNCTION {new.sentence.checkb}
239 FUNCTION {field.or.null}
254 { "\emph{" swap$ * "}" * }
264 { duplicate$ i #1 substring$ "" = not }
265 { duplicate$ duplicate$ i #1 substring$ quote$ =
266 swap$ i #1 - #1 substring$ "\" = not and %"
267 { duplicate$ #1 i #1 - substring$ swap$
268 i #1 + global.max$ substring$
270 { swap$ duplicate$ #-1 #1 substring$ "'" =
271 { swap$ "\thinspace'" }
276 { duplicate$ #1 #1 substring$ "`" =
291 { "odd number of quotation marks in " cite$ * warning$ }
294 duplicate$ #1 #1 substring$ "`" =
295 { "``\thinspace" swap$ * }
298 duplicate$ #-1 #1 substring$ "'" =
306 FUNCTION {selective.enquote}
307 { field.or.null duplicate$ sortify 's :=
308 s #1 #8 substring$ duplicate$ "rev. of " = swap$ "rev.~of " = or
309 s #1 #9 substring$ "rev.\ of " = or
310 s "introduction" = or
319 INTEGERS { nameptr namesleft numnames }
321 FUNCTION {format.names.custom}
325 s num.names$ 'numnames :=
326 numnames 'namesleft :=
328 { s nameptr u format.name$ 't :=
345 nameptr #1 + 'nameptr :=
346 namesleft #1 - 'namesleft :=
351 FUNCTION {format.names}
352 { "{ff~}{vv~}{ll}{, jj}" format.names.custom }
354 % Changed first author to last name first
355 FUNCTION {format.names.beginning}
358 s num.names$ 'numnames :=
359 numnames 'namesleft :=
362 { s nameptr "{vv~}{ll}{, ff}{, jj}" format.name$
363 duplicate$ #1 #1 substring$ duplicate$ "{" =
367 swap$ #2 global.max$ substring$ * 't :=
369 { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't := }
387 nameptr #1 + 'nameptr :=
388 namesleft #1 - 'namesleft :=
393 % Added check for duplicate authors
394 FUNCTION {format.authors}
397 { author.duplicate #1 =
399 { author format.names.beginning }
405 % Changed to MLA editor abbreviations
406 % author.duplicate also applies
407 FUNCTION {format.editors}
410 { author empty$ author.duplicate #1 = and
412 { editor format.names.beginning }
414 editor num.names$ #1 >
422 FUNCTION {format.editors.mid}
426 editor num.names$ #1 >
430 editor format.names *
435 % Formats the address and publisher
436 FUNCTION {format.publisher}
439 { address ": " * publisher * }
443 % Changed to preserve case and use quotes
444 FUNCTION {format.title}
445 { title selective.enquote
452 { t #1 #1 substring$ "-" =
453 { t #1 #2 substring$ "--" = not
455 t #2 global.max$ substring$ 't :=
457 { { t #1 #1 substring$ "-" = }
459 t #2 global.max$ substring$ 't :=
465 { t #1 #1 substring$ *
466 t #2 global.max$ substring$ 't :=
473 FUNCTION {format.date}
477 { "there's a month but no year in " cite$ * warning$
484 { month "~" * year * }
491 FUNCTION {format.btitle}
493 %title num.chars int.to.str$ top$
495 %{ xx title num.chars < }
496 %{ title xx #1 + duplicate$ 'xx := #1 substring$ top$ } while$
499 FUNCTION {tie.or.space.connect}
500 { duplicate$ text.length$ #3 <
507 FUNCTION {either.or.check}
510 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
514 FUNCTION {format.bvolume.or.num.series}
517 { series field.or.null }
520 { number "there's a number but no series in " cite$ * warning$ }
522 %output.state mid.sentence =
526 number tie.or.space.connect
532 { "Vol." volume tie.or.space.connect
535 { " of " * series emphasize * add.period$ }
539 { number * " vols." * }
541 %"volume and number" number either.or.check
546 % Changed edition to MLA abbreviation
547 FUNCTION {format.edition}
551 { "Vers.~" version *}
554 { edition sortify 's := edition 't :=
556 "10th" "tenth" "9th" "ninth" "8th" "eighth" "7th" "seventh" "6th" "sixth"
557 "5th" "fifth" "4th" "fourth" "3rd" "third" "2nd" "second" "1st" "first"
558 "Rev." "revised" "Abr." "abridged"
559 {duplicate$ empty$ { pop$ #0 }{ #1 } if$ }{ s = { 't := }{ pop$ } if$ }
562 "edition and version" version either.or.check
567 INTEGERS { multiresult }
569 FUNCTION {multi.page.check}
578 swap$ duplicate$ "," =
581 { #1 'multiresult := }
582 { t #2 global.max$ substring$ 't := }
589 FUNCTION {format.pages}
592 { %pages multi.page.check
593 % { "pages" pages n.dashify tie.or.space.connect }
594 % { "page" pages tie.or.space.connect }
601 FUNCTION {format.vol.num.year.pages}
605 { "there's a number but no volume in " cite$ * warning$ }
614 " (" * format.date * ")" *
619 { ", " * format.edition * }
623 { ": " * pages n.dashify * }
628 FUNCTION {format.vol.num.pages}
629 { volume field.or.null
632 { "(" number * ")" * *
634 { "there's a number but no volume in " cite$ * warning$ }
642 { pop$ format.pages }
643 { ":" * pages n.dashify * }
649 % chapter might be useful if type is set to "pars."
650 FUNCTION {format.chapter.pages}
652 type field.or.null sortify duplicate$ "def." = swap$ "definition" = or
657 { type "t" change.case$ }
659 chapter n.dashify tie.or.space.connect
662 { ", " * format.pages * }
668 FUNCTION {empty.misc.check}
669 { author empty$ title empty$ howpublished empty$
670 month empty$ year empty$ note empty$
673 { "all relevant fields are empty in " cite$ * warning$ }
678 FUNCTION {format.thesis.type}
682 type "t" change.case$
687 FUNCTION {format.tr.number}
689 { "Technical Report" }
694 { number tie.or.space.connect }
698 FUNCTION {format.url}
703 { "there's a url but no urldate in " cite$ * warning$ "\today" }
704 { "accessdate in " cite$ * " depreciated; use urldate instead" *
705 warning$ accessdate }
710 " $<$\url{" * url * "}$>$" *
713 { do.period " Path: " * urlpath * }
719 FUNCTION {format.crossref}
721 pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$
722 "{" * crossref * "}" *
726 FUNCTION {cite.title}
727 { title empty$ journal empty$ not and
728 { key empty$ { journal }{ key } if$ emphasize }
729 { title empty$ key empty$ and
730 { "empty title and key in " cite$ * warning$ "" }
731 { key empty$ {title}{key} if$
737 type$ "proceedings" =
742 type$ "incollection" =
743 type$ "inproceedings" =
744 type$ "mastersthesis" =
747 type$ "unpublished" =
749 { selective.enquote }
760 FUNCTION {cite.label}
763 % { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
777 "(" * empty.title * ")" * }
779 author.shared author.different =
780 { "{vv~}{ll}" format.names.custom 's := }
781 { author.shared author.last =
782 { "{f.~}{vv~}{ll}{, jj}" format.names.custom 's := }
783 { author.shared author.flast =
784 { "{ff~}{vv~}{ll}{, jj}" format.names.custom 's := }
785 { "{vv~}{ll}" format.names.custom ", " * cite.title * 's := "WTF" warning$ }
793 author.duplicate { cite.title * }{} if$
794 ")" * swap$ "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ *
805 FUNCTION {output.bibitem}
814 before.all 'output.state :=
819 format.authors "author" output.check
821 format.title "title" output.check
826 { type sortify "review" =
827 { "Rev.\ of " booktitle emphasize *
828 "booktitle" output.check new.block
830 { "Ignoring invalid type in " cite$ warning$ }
834 journal emphasize "journal" output.check after.title 'output.state :=
837 { "[" address * "]" * output
838 after.title 'output.state :=
841 %format.date "year" output.check
843 format.vol.num.year.pages output
845 { format.crossref output.nonnull
859 { format.editors "author and editor" output.check }
860 { format.authors output.nonnull }
863 format.btitle "title" output.check
866 { author empty$ 'skip$ { format.editors.mid output new.block } if$
867 format.edition output
869 format.bvolume.or.num.series output
871 format.publisher "publisher" output.check
872 format.date "year" output.check
874 {% format.date "year" output
876 format.crossref output.nonnull
888 format.authors output
890 format.btitle "title" output.check
891 howpublished address new.block.checkb
903 { format.editors "author and editor" output.check }
904 { format.authors output.nonnull }
907 format.btitle "title" output.check
910 { author empty$ 'skip$ { format.editors.mid output new.block } if$
911 format.edition output
913 format.bvolume.or.num.series output
915 format.publisher "publisher" output.check
916 format.date "year" output.check
918 format.chapter.pages "chapter and pages" output.check
923 format.crossref output.nonnull
932 FUNCTION {incollection}
934 format.authors "author" output.check
936 { new.block type output }
940 format.title "title" output.check
941 type field.or.null sortify duplicate$ "definition" = swap$ "def." = or
942 { new.block "Def.~" chapter field.or.null * "chapter" output.check }
948 booktitle emphasize "booktitle" output.check
950 format.editors.mid "editor" output.check
952 format.edition output
954 format.bvolume.or.num.series output
956 format.publisher "publisher" output.check
958 format.date "year" output.check
960 format.chapter.pages output
962 { format.crossref output.nonnull
963 %format.chapter.pages output
973 FUNCTION {inproceedings}
975 format.authors "author" output.check
977 format.title "title" output.check
981 booktitle "booktitle" output.check
983 format.editors.mid output
985 format.edition output
987 format.bvolume.or.num.series output
989 format.edition output
991 format.publisher output
992 format.date "year" output.check
994 %{ organization publisher new.sentence.checkb
995 % organization output
997 % format.date "year" output.check
999 %{ address output.nonnull
1000 % format.date "year" output.check
1002 % organization output
1009 { format.crossref output.nonnull
1019 FUNCTION {conference} { inproceedings }
1024 { organization empty$
1026 { organization output.nonnull
1031 { format.authors output.nonnull }
1034 format.btitle "title" output.check
1036 format.edition output
1039 { organization empty$
1040 { address new.block.checka
1046 { organization address new.block.checkb
1059 FUNCTION {mastersthesis}
1061 format.authors "author" output.check
1063 format.title "title" output.check
1065 "Diss." format.thesis.type do.period output.nonnull
1066 after.title 'output.state :=
1067 school "school" output.check
1069 format.date "year" output.check
1079 format.authors output
1080 title howpublished new.block.checkb
1083 %howpublished new.block.checka
1094 FUNCTION {phdthesis}
1096 format.authors "author" output.check
1098 format.btitle "title" output.check
1100 "Diss." format.thesis.type do.period output.nonnull
1101 after.title 'output.state :=
1102 school "school" output.check
1104 format.date "year" output.check
1112 FUNCTION {proceedings}
1115 { organization output }
1116 { format.editors output.nonnull }
1119 format.btitle "title" output.check
1121 format.bvolume.or.num.series output
1124 { publisher new.sentence.checka }
1125 { organization publisher new.sentence.checkb
1130 format.date "year" output.check
1132 { address output.nonnull
1133 format.date "year" output.check
1137 { organization output }
1149 FUNCTION {techreport}
1151 format.authors "author" output.check
1153 format.title "title" output.check
1155 format.tr.number output.nonnull
1157 institution "institution" output.check
1159 format.date "year" output.check
1165 FUNCTION {unpublished}
1167 format.authors "author" output.check
1169 format.title "title" output.check
1173 note "note" output.check
1178 FUNCTION {default.type} { misc }
1180 MACRO {jan} {"Jan."}
1182 MACRO {feb} {"Feb."}
1184 MACRO {mar} {"Mar."}
1186 MACRO {apr} {"Apr."}
1190 MACRO {jun} {"June"}
1192 MACRO {jul} {"July"}
1194 MACRO {aug} {"Aug."}
1196 MACRO {sep} {"Sept."}
1198 MACRO {oct} {"Oct."}
1200 MACRO {nov} {"Nov."}
1202 MACRO {dec} {"Dec."}
1204 % Currently left in to help with compatibility
1206 MACRO {acmcs} {"ACM Computing Surveys"}
1208 MACRO {acta} {"Acta Informatica"}
1210 MACRO {cacm} {"Communications of the ACM"}
1212 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1214 MACRO {ibmsj} {"IBM Systems Journal"}
1216 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1218 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1221 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1223 MACRO {ipl} {"Information Processing Letters"}
1225 MACRO {jacm} {"Journal of the ACM"}
1227 MACRO {jcss} {"Journal of Computer and System Sciences"}
1229 MACRO {scp} {"Science of Computer Programming"}
1231 MACRO {sicomp} {"SIAM Journal on Computing"}
1233 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1235 MACRO {tods} {"ACM Transactions on Database Systems"}
1237 MACRO {tog} {"ACM Transactions on Graphics"}
1239 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1241 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1243 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1245 MACRO {tcs} {"Theoretical Computer Science"}
1251 FUNCTION {chop.word}
1254 s #1 len substring$ =
1255 { s len #1 + global.max$ substring$ }
1260 FUNCTION {sort.format.names}
1264 s num.names$ 'numnames :=
1265 numnames 'namesleft :=
1271 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1272 nameptr numnames = t "others" = and
1276 nameptr #1 + 'nameptr :=
1277 namesleft #1 - 'namesleft :=
1282 FUNCTION {sort.format.title}
1297 #1 global.max$ substring$
1300 FUNCTION {author.sort}
1303 { "to sort, need author or key in " cite$ * warning$
1309 { author sort.format.names }
1313 FUNCTION {author.editor.sort}
1317 { "to sort, need author, editor, or key in " cite$ * warning$
1323 { editor sort.format.names }
1326 { author sort.format.names }
1330 FUNCTION {author.organization.sort}
1332 { organization empty$
1334 { "to sort, need author, organization, or key in " cite$ * warning$
1340 { "The " #4 organization chop.word sortify }
1343 { author sort.format.names }
1347 FUNCTION {editor.organization.sort}
1349 { organization empty$
1351 { "to sort, need editor, organization, or key in " cite$ * warning$
1357 { "The " #4 organization chop.word sortify }
1360 { editor sort.format.names }
1369 { type$ "proceedings" =
1370 'editor.organization.sort
1372 'author.organization.sort
1379 duplicate$ empty$ 'skip$ { " " * } if$
1381 { title field.or.null sort.format.title * " " * booktitle field.or.null sort.format.title * }
1386 year field.or.null sortify
1388 #1 entry.max$ substring$
1398 FUNCTION {init.vars}
1399 { #0 int.to.chr$ 'a :=
1400 #0 int.to.chr$ 'b :=
1405 FUNCTION {forward.author.dup.check}
1407 url empty$ 'skip$ { url.used #1 + 'url.used := } if$
1408 crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$
1410 { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1416 { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1417 a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1418 { #1 'author.duplicate := }
1419 { #0 'author.duplicate := }
1426 FUNCTION {forward.author.share.check}
1428 % Pass through all entries, comparing current author to last one.
1430 { author.duplicate author empty$ or
1431 { author.duplicate { i 'author.shared := }{} if$}
1432 { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1433 author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1434 { author.flast 'author.shared := }
1435 { b "{vv~}{ll}" format.names.custom purify$
1436 author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1437 { author.last 'author.shared := }
1438 { author.different 'author.shared := }
1443 author field.or.null 'b :=
1448 FUNCTION {reverse.author}
1452 { i 'author.shared := }
1457 { author.shared i 'author.shared := 'i := }
1458 { author.shared 'i := }
1462 j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1463 author.duplicate 'j :=
1466 EXECUTE {init.consts}
1469 ITERATE {forward.author.dup.check}
1472 ITERATE {forward.author.share.check}
1475 REVERSE {reverse.author}
1477 %INTEGERS { number.label longest.label.width }
1479 %FUNCTION {initialize.longest.label}
1480 %{ "" 'longest.label :=
1481 % #1 'number.label :=
1482 % #0 'longest.label.width :=
1485 %FUNCTION {longest.label.pass}
1486 %{ number.label int.to.str$ 'label :=
1487 % number.label #1 + 'number.label :=
1488 % label width$ longest.label.width >
1489 % { label 'longest.label :=
1490 % label width$ 'longest.label.width :=
1496 %EXECUTE {initialize.longest.label}
1498 %ITERATE {longest.label.pass}
1500 FUNCTION {begin.bib}
1503 { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi"
1508 { "\expandafter\ifx\csname citealp\endcsname\relax\url\let\url\relax\fi"
1514 { preamble$ write$ newline$ }
1516 "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1521 ITERATE {call.type$}
1525 "\end{thebibliography}" write$ newline$