1 % $Id: mlastyle.bst,v 1.13 2003-11-22 19:15: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.
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}
593 % j is positive if pages contains a comma
594 % (not fully implemented)
596 pages n.dashify 't :=
599 { t #1 #2 substring$ "--" =
600 { t #3 global.max$ substring$ 't :=
601 duplicate$ num.chars 'i :=
605 { duplicate$ #1 i #2 - substring$
606 t #1 i #2 - substring$ =
607 { t i #1 - global.max$ substring$ * "" 't := #2 'i := }
616 { t #1 #1 substring$ *
617 t #2 global.max$ substring$ 't :=
626 FUNCTION {format.year}
630 duplicate$ duplicate$ num.chars #10 =
631 swap$ #5 #2 substring$ "--" = and
632 { duplicate$ duplicate$ #1 #2 substring$ swap$ #7 #2 substring$ =
633 { duplicate$ #1 #6 substring$ swap$ #8 #2 substring$ * }
643 FUNCTION {format.vol.num.year.pages}
647 { "there's a number but no volume in " cite$ * warning$ }
656 " (" * format.date * ")" *
661 { ", " * format.edition * }
665 { ": " * pages n.dashify * }
670 FUNCTION {format.vol.num.pages}
671 { volume field.or.null
674 { "(" number * ")" * *
676 { "there's a number but no volume in " cite$ * warning$ }
684 { pop$ format.pages }
685 { ":" * pages n.dashify * }
691 % chapter might be useful if type is set to "pars."
692 FUNCTION {format.chapter.pages}
694 type field.or.null sortify duplicate$ "def." = swap$ "definition" = or
699 { type "t" change.case$ }
701 chapter n.dashify tie.or.space.connect
704 { ", " * format.pages * }
710 FUNCTION {empty.misc.check}
711 { author empty$ title empty$ howpublished empty$
712 month empty$ year empty$ note empty$
715 { "all relevant fields are empty in " cite$ * warning$ }
720 FUNCTION {format.thesis.type}
724 type "t" change.case$
729 FUNCTION {format.tr.number}
731 { "Technical Report" }
736 { number tie.or.space.connect }
740 FUNCTION {format.url}
745 { "there's a url but no urldate in " cite$ * warning$ "\today" }
746 { "accessdate in " cite$ * " depreciated; use urldate instead" *
747 warning$ accessdate }
752 " $<$\url{" * url * "}$>$" *
755 { do.period " Path: " * urlpath * }
761 FUNCTION {format.crossref}
763 pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$
764 "{" * crossref * "}" *
768 FUNCTION {cite.title}
769 { title empty$ journal empty$ not and
770 { key empty$ { journal }{ key } if$ emphasize }
771 { title empty$ key empty$ and
772 { "empty title and key in " cite$ * warning$ "" }
773 { key empty$ {title}{key} if$
779 type$ "proceedings" =
784 type$ "incollection" =
785 type$ "inproceedings" =
786 type$ "mastersthesis" =
789 type$ "unpublished" =
791 { selective.enquote }
802 FUNCTION {cite.label}
805 % { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
819 "(" * empty.title * ")" * }
821 author.shared author.different =
822 { "{vv~}{ll}" format.names.custom 's := }
823 { author.shared author.last =
824 { "{f.~}{vv~}{ll}{, jj}" format.names.custom 's := }
825 { author.shared author.flast =
826 { "{ff~}{vv~}{ll}{, jj}" format.names.custom 's := }
827 { "{vv~}{ll}" format.names.custom ", " * cite.title * 's := "WTF" warning$ }
835 author.duplicate { cite.title * }{} if$
836 ")" * swap$ "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ *
847 FUNCTION {output.bibitem}
856 before.all 'output.state :=
861 format.authors "author" output.check
863 format.title "title" output.check
868 { type sortify "review" =
869 { "Rev.\ of " booktitle emphasize *
870 "booktitle" output.check new.block
872 { "Ignoring invalid type in " cite$ warning$ }
876 journal emphasize "journal" output.check after.title 'output.state :=
879 { "[" address * "]" * output
880 after.title 'output.state :=
883 %format.date "year" output.check
885 format.vol.num.year.pages output
887 { format.crossref output.nonnull
901 { format.editors "author and editor" output.check }
902 { format.authors output.nonnull }
905 format.btitle "title" output.check
908 { author empty$ 'skip$ { format.editors.mid output new.block } if$
909 format.edition output
911 format.bvolume.or.num.series output
913 format.publisher "publisher" output.check
914 format.date "year" output.check
916 {% format.date "year" output
918 format.crossref output.nonnull
930 format.authors output
932 format.btitle "title" output.check
933 howpublished address new.block.checkb
945 { format.editors "author and editor" output.check }
946 { format.authors output.nonnull }
949 format.btitle "title" output.check
952 { author empty$ 'skip$ { format.editors.mid output new.block } if$
953 format.edition output
955 format.bvolume.or.num.series output
957 format.publisher "publisher" output.check
958 format.date "year" output.check
960 format.chapter.pages "chapter and pages" output.check
965 format.crossref output.nonnull
974 FUNCTION {incollection}
976 format.authors "author" output.check
978 { new.block type output }
982 format.title "title" output.check
983 type field.or.null sortify duplicate$ "definition" = swap$ "def." = or
984 { new.block "Def.~" chapter field.or.null * "chapter" output.check }
990 booktitle emphasize "booktitle" output.check
992 format.editors.mid "editor" output.check
994 format.edition output
996 format.bvolume.or.num.series output
998 format.publisher "publisher" output.check
1000 format.date "year" output.check
1002 format.chapter.pages output
1004 { format.crossref output.nonnull
1005 %format.chapter.pages output
1015 FUNCTION {inproceedings}
1017 format.authors "author" output.check
1019 format.title "title" output.check
1023 booktitle "booktitle" output.check
1025 format.editors.mid output
1027 format.edition output
1029 format.bvolume.or.num.series output
1031 format.edition output
1033 format.publisher output
1034 format.date "year" output.check
1036 %{ organization publisher new.sentence.checkb
1037 % organization output
1039 % format.date "year" output.check
1041 %{ address output.nonnull
1042 % format.date "year" output.check
1044 % organization output
1051 { format.crossref output.nonnull
1061 FUNCTION {conference} { inproceedings }
1066 { organization empty$
1068 { organization output.nonnull
1073 { format.authors output.nonnull }
1076 format.btitle "title" output.check
1078 format.edition output
1081 { organization empty$
1082 { address new.block.checka
1088 { organization address new.block.checkb
1101 FUNCTION {mastersthesis}
1103 format.authors "author" output.check
1105 format.title "title" output.check
1107 "Diss." format.thesis.type do.period output.nonnull
1108 after.title 'output.state :=
1109 school "school" output.check
1111 format.date "year" output.check
1121 format.authors output
1122 title howpublished new.block.checkb
1125 %howpublished new.block.checka
1136 FUNCTION {phdthesis}
1138 format.authors "author" output.check
1140 format.btitle "title" output.check
1142 "Diss." format.thesis.type do.period output.nonnull
1143 after.title 'output.state :=
1144 school "school" output.check
1146 format.date "year" output.check
1154 FUNCTION {proceedings}
1157 { organization output }
1158 { format.editors output.nonnull }
1161 format.btitle "title" output.check
1163 format.bvolume.or.num.series output
1166 { publisher new.sentence.checka }
1167 { organization publisher new.sentence.checkb
1172 format.date "year" output.check
1174 { address output.nonnull
1175 format.date "year" output.check
1179 { organization output }
1191 FUNCTION {techreport}
1193 format.authors "author" output.check
1195 format.title "title" output.check
1197 format.tr.number output.nonnull
1199 institution "institution" output.check
1201 format.date "year" output.check
1207 FUNCTION {unpublished}
1209 format.authors "author" output.check
1211 format.title "title" output.check
1215 note "note" output.check
1220 FUNCTION {default.type} { misc }
1222 MACRO {jan} {"Jan."}
1224 MACRO {feb} {"Feb."}
1226 MACRO {mar} {"Mar."}
1228 MACRO {apr} {"Apr."}
1232 MACRO {jun} {"June"}
1234 MACRO {jul} {"July"}
1236 MACRO {aug} {"Aug."}
1238 MACRO {sep} {"Sept."}
1240 MACRO {oct} {"Oct."}
1242 MACRO {nov} {"Nov."}
1244 MACRO {dec} {"Dec."}
1246 % Currently left in to help with compatibility
1248 MACRO {acmcs} {"ACM Computing Surveys"}
1250 MACRO {acta} {"Acta Informatica"}
1252 MACRO {cacm} {"Communications of the ACM"}
1254 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1256 MACRO {ibmsj} {"IBM Systems Journal"}
1258 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1260 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1263 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1265 MACRO {ipl} {"Information Processing Letters"}
1267 MACRO {jacm} {"Journal of the ACM"}
1269 MACRO {jcss} {"Journal of Computer and System Sciences"}
1271 MACRO {scp} {"Science of Computer Programming"}
1273 MACRO {sicomp} {"SIAM Journal on Computing"}
1275 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1277 MACRO {tods} {"ACM Transactions on Database Systems"}
1279 MACRO {tog} {"ACM Transactions on Graphics"}
1281 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1283 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1285 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1287 MACRO {tcs} {"Theoretical Computer Science"}
1293 FUNCTION {chop.word}
1296 s #1 len substring$ =
1297 { s len #1 + global.max$ substring$ }
1302 FUNCTION {sort.format.names}
1306 s num.names$ 'numnames :=
1307 numnames 'namesleft :=
1313 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1314 nameptr numnames = t "others" = and
1318 nameptr #1 + 'nameptr :=
1319 namesleft #1 - 'namesleft :=
1324 FUNCTION {sort.format.title}
1339 #1 global.max$ substring$
1342 FUNCTION {author.sort}
1345 { "to sort, need author or key in " cite$ * warning$
1351 { author sort.format.names }
1355 FUNCTION {author.editor.sort}
1359 { "to sort, need author, editor, or key in " cite$ * warning$
1365 { editor sort.format.names }
1368 { author sort.format.names }
1372 FUNCTION {author.organization.sort}
1374 { organization empty$
1376 { "to sort, need author, organization, or key in " cite$ * warning$
1382 { "The " #4 organization chop.word sortify }
1385 { author sort.format.names }
1389 FUNCTION {editor.organization.sort}
1391 { organization empty$
1393 { "to sort, need editor, organization, or key in " cite$ * warning$
1399 { "The " #4 organization chop.word sortify }
1402 { editor sort.format.names }
1411 { type$ "proceedings" =
1412 'editor.organization.sort
1414 'author.organization.sort
1421 duplicate$ empty$ 'skip$ { " " * } if$
1423 { title field.or.null sort.format.title * " " * booktitle field.or.null sort.format.title * }
1428 year field.or.null sortify
1430 #1 entry.max$ substring$
1440 FUNCTION {init.vars}
1441 { #0 int.to.chr$ 'a :=
1442 #0 int.to.chr$ 'b :=
1447 FUNCTION {forward.author.dup.check}
1449 url empty$ 'skip$ { url.used #1 + 'url.used := } if$
1450 crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$
1452 { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1458 { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1459 a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1460 { #1 'author.duplicate := }
1461 { #0 'author.duplicate := }
1468 FUNCTION {forward.author.share.check}
1470 % Pass through all entries, comparing current author to last one.
1472 { author.duplicate author empty$ or
1473 { author.duplicate { i 'author.shared := }{} if$}
1474 { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1475 author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1476 { author.flast 'author.shared := }
1477 { b "{vv~}{ll}" format.names.custom purify$
1478 author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1479 { author.last 'author.shared := }
1480 { author.different 'author.shared := }
1485 author field.or.null 'b :=
1490 FUNCTION {reverse.author}
1494 { i 'author.shared := }
1499 { author.shared i 'author.shared := 'i := }
1500 { author.shared 'i := }
1504 j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1505 author.duplicate 'j :=
1508 EXECUTE {init.consts}
1511 ITERATE {forward.author.dup.check}
1514 ITERATE {forward.author.share.check}
1517 REVERSE {reverse.author}
1519 %INTEGERS { number.label longest.label.width }
1521 %FUNCTION {initialize.longest.label}
1522 %{ "" 'longest.label :=
1523 % #1 'number.label :=
1524 % #0 'longest.label.width :=
1527 %FUNCTION {longest.label.pass}
1528 %{ number.label int.to.str$ 'label :=
1529 % number.label #1 + 'number.label :=
1530 % label width$ longest.label.width >
1531 % { label 'longest.label :=
1532 % label width$ 'longest.label.width :=
1538 %EXECUTE {initialize.longest.label}
1540 %ITERATE {longest.label.pass}
1542 FUNCTION {begin.bib}
1545 { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi"
1550 { "\expandafter\ifx\csname citealp\endcsname\relax\url\let\url\relax\fi"
1556 { preamble$ write$ newline$ }
1558 "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1563 ITERATE {call.type$}
1567 "\end{thebibliography}" write$ newline$