1 % $Id: mlastyle.bst,v 1.14 2003-11-23 00:15:32 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
1185 school "school" output.check
1187 format.date "year" output.check
1197 format.authors output
1198 title howpublished new.block.checkb
1201 %howpublished new.block.checka
1212 FUNCTION {phdthesis}
1214 format.authors "author" output.check
1216 format.btitle "title" output.check
1218 "Diss." format.thesis.type output.nonnull
1219 school "school" output.check
1221 format.date "year" output.check
1229 FUNCTION {proceedings}
1232 { organization output }
1233 { format.editors output.nonnull }
1236 format.btitle "title" output.check
1238 format.bvolume.or.num.series output
1241 { publisher new.sentence.checka }
1242 { organization publisher new.sentence.checkb
1247 format.date "year" output.check
1249 { address output.nonnull
1250 format.date "year" output.check
1254 { organization output }
1266 FUNCTION {techreport}
1268 format.authors "author" output.check
1270 format.title "title" output.check
1272 format.tr.number output.nonnull
1274 institution "institution" output.check
1276 format.date "year" output.check
1282 FUNCTION {unpublished}
1284 format.authors "author" output.check
1286 format.title "title" output.check
1290 note "note" output.check
1295 FUNCTION {default.type} { misc }
1297 MACRO {jan} {"Jan."}
1299 MACRO {feb} {"Feb."}
1301 MACRO {mar} {"Mar."}
1303 MACRO {apr} {"Apr."}
1307 MACRO {jun} {"June"}
1309 MACRO {jul} {"July"}
1311 MACRO {aug} {"Aug."}
1313 MACRO {sep} {"Sept."}
1315 MACRO {oct} {"Oct."}
1317 MACRO {nov} {"Nov."}
1319 MACRO {dec} {"Dec."}
1321 % Currently left in to help with compatibility
1323 MACRO {acmcs} {"ACM Computing Surveys"}
1325 MACRO {acta} {"Acta Informatica"}
1327 MACRO {cacm} {"Communications of the ACM"}
1329 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1331 MACRO {ibmsj} {"IBM Systems Journal"}
1333 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1335 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1338 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1340 MACRO {ipl} {"Information Processing Letters"}
1342 MACRO {jacm} {"Journal of the ACM"}
1344 MACRO {jcss} {"Journal of Computer and System Sciences"}
1346 MACRO {scp} {"Science of Computer Programming"}
1348 MACRO {sicomp} {"SIAM Journal on Computing"}
1350 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1352 MACRO {tods} {"ACM Transactions on Database Systems"}
1354 MACRO {tog} {"ACM Transactions on Graphics"}
1356 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1358 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1360 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1362 MACRO {tcs} {"Theoretical Computer Science"}
1368 FUNCTION {chop.word}
1371 s #1 len substring$ =
1372 { s len #1 + global.max$ substring$ }
1377 FUNCTION {sort.format.names}
1381 s num.names$ 'numnames :=
1382 numnames 'namesleft :=
1388 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1389 nameptr numnames = t "others" = and
1393 nameptr #1 + 'nameptr :=
1394 namesleft #1 - 'namesleft :=
1399 FUNCTION {sort.format.title}
1414 #1 global.max$ substring$
1417 FUNCTION {author.sort}
1420 { "to sort, need author or key in " cite$ * warning$
1426 { author sort.format.names }
1430 FUNCTION {author.editor.sort}
1434 { "to sort, need author, editor, or key in " cite$ * warning$
1440 { editor sort.format.names }
1443 { author sort.format.names }
1447 FUNCTION {author.organization.sort}
1449 { organization empty$
1451 { "to sort, need author, organization, or key in " cite$ * warning$
1457 { "The " #4 organization chop.word sortify }
1460 { author sort.format.names }
1464 FUNCTION {editor.organization.sort}
1466 { organization empty$
1468 { "to sort, need editor, organization, or key in " cite$ * warning$
1474 { "The " #4 organization chop.word sortify }
1477 { editor sort.format.names }
1486 { type$ "proceedings" =
1487 'editor.organization.sort
1489 'author.organization.sort
1496 duplicate$ empty$ 'skip$ { " " * } if$
1498 { title field.or.null sort.format.title * " " * booktitle field.or.null sort.format.title * }
1503 year field.or.null sortify
1505 #1 entry.max$ substring$
1515 FUNCTION {init.vars}
1516 { #0 int.to.chr$ 'a :=
1517 #0 int.to.chr$ 'b :=
1522 % Function name is not strictly accurate
1523 FUNCTION {forward.author.dup.check}
1525 url empty$ urlpath empty$ urldate empty$ and and
1527 { url.used #1 + 'url.used := }
1529 crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$
1531 { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1537 { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1538 a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1539 { #1 'author.duplicate := }
1540 { #0 'author.duplicate := }
1547 FUNCTION {forward.author.share.check}
1549 % Pass through all entries, comparing current author to last one.
1551 { author.duplicate author empty$ or
1552 { author.duplicate { i 'author.shared := }{} if$}
1553 { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1554 author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1555 { author.flast 'author.shared := }
1556 { b "{vv~}{ll}" format.names.custom purify$
1557 author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1558 { author.last 'author.shared := }
1559 { author.different 'author.shared := }
1564 author field.or.null 'b :=
1569 FUNCTION {reverse.author}
1573 { i 'author.shared := }
1578 { author.shared i 'author.shared := 'i := }
1579 { author.shared 'i := }
1583 j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1584 author.duplicate 'j :=
1587 EXECUTE {init.consts}
1590 ITERATE {forward.author.dup.check}
1593 ITERATE {forward.author.share.check}
1596 REVERSE {reverse.author}
1598 %INTEGERS { number.label longest.label.width }
1600 %FUNCTION {initialize.longest.label}
1601 %{ "" 'longest.label :=
1602 % #1 'number.label :=
1603 % #0 'longest.label.width :=
1606 %FUNCTION {longest.label.pass}
1607 %{ number.label int.to.str$ 'label :=
1608 % number.label #1 + 'number.label :=
1609 % label width$ longest.label.width >
1610 % { label 'longest.label :=
1611 % label width$ 'longest.label.width :=
1617 %EXECUTE {initialize.longest.label}
1619 %ITERATE {longest.label.pass}
1621 FUNCTION {begin.bib}
1624 { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi"
1630 { "\expandafter\ifx\csname url\endcsname\relax\let\url\relax\fi"
1632 "\expandafter\ifx\csname theurldate\endcsname\relax"
1634 "\let\theurldate\today\fi"
1641 { preamble$ write$ newline$ }
1643 "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1648 ITERATE {call.type$}
1652 "\end{thebibliography}" write$ newline$