1 % $Id: mlastyle.bst,v 1.19 2005-02-08 15:13:47 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 <
543 { swap$ do.space swap$ * }
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 { database selective.emphasize output.nonnull new.block }
797 { cite$ " has no urldate field" * warning$
800 { "accessdate in " cite$ * " is depreciated; use urldate instead" *
808 FUNCTION {output.url}
813 { format.urldate output }
817 " $<$\url{" * url * "}$>$" *
823 { "Path: " urlpath * output.nonnull }
827 FUNCTION {format.crossref}
829 pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$
830 "{" * crossref * "}" *
834 FUNCTION {cite.title}
835 { title empty$ journal empty$ not and
836 { key empty$ { journal }{ key } if$ selective.emphasize }
837 { title empty$ key empty$ and
838 { "empty title and key in " cite$ * warning$ "" }
839 { key empty$ {title}{key} if$
845 type$ "proceedings" =
847 { selective.emphasize }
850 type$ "incollection" =
851 type$ "inproceedings" =
852 type$ "mastersthesis" =
855 type$ "unpublished" =
857 { selective.enquote }
868 FUNCTION {cite.label}
871 % { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
885 "(" * empty.title * ")" * }
887 author.shared author.different =
888 { "{vv~}{ll}" format.names.custom 's := }
889 { author.shared author.last =
890 { "{f.~}{vv~}{ll}{, jj}" format.names.custom 's := }
891 { author.shared author.flast =
892 { "{ff~}{vv~}{ll}{, jj}" format.names.custom 's := }
893 { "{vv~}{ll}" format.names.custom ", " *
894 cite.title * 's := "WTF" warning$ }
902 author.duplicate { cite.title * }{} if$
903 "){" * swap$ "{ff~}{vv~}{ll}{, jj}" format.names.custom * "}" *
914 FUNCTION {output.bibitem}
923 before.all 'output.state :=
928 format.authors "author" output.check
930 format.title "title" output.check
935 { type sortify "review" =
936 { "Rev.\ of " booktitle selective.emphasize *
937 "booktitle" output.check new.block
939 { "Ignoring invalid type in " cite$ warning$ }
943 journal selective.emphasize "journal" output.check
947 { "[" address * "]" * output
958 { series abbreviate do.space "ser." * "l" change.case$ }
966 format.vol.num.year.pages output
968 { format.crossref output.nonnull
982 { format.editors "author and editor" output.check }
983 { format.authors output.nonnull }
986 format.btitle "title" output.check
989 { author empty$ 'skip$ { format.editors.mid output new.block } if$
990 format.edition output
992 format.bvolume.or.num.series output
994 format.publisher "publisher" output.check
995 format.date "year" output.check
997 {% format.date "year" output
999 format.crossref output.nonnull
1011 format.authors output
1013 format.btitle "title" output.check
1014 howpublished address new.block.checkb
1026 { format.editors "author and editor" output.check }
1027 { format.authors output.nonnull }
1030 format.btitle "title" output.check
1033 { author empty$ 'skip$ { format.editors.mid output new.block } if$
1034 format.edition output
1036 format.bvolume.or.num.series output
1038 format.publisher "publisher" output.check
1039 format.date "year" output.check
1041 format.chapter.pages "chapter and pages" output.check
1046 format.crossref output.nonnull
1055 FUNCTION {incollection}
1057 format.authors "author" output.check
1059 { new.block type output }
1063 format.title "title" output.check
1064 type field.or.null sortify duplicate$ "definition" = swap$ "def." = or
1065 { new.block "Def.~" chapter field.or.null * "chapter" output.check }
1071 booktitle selective.emphasize "booktitle" output.check
1073 format.editors.mid "editor" output.check
1075 format.edition output
1077 format.bvolume.or.num.series output
1079 format.publisher "publisher" output.check
1081 format.date "year" output.check
1083 format.chapter.pages output
1085 { format.crossref output.nonnull
1086 %format.chapter.pages output
1096 FUNCTION {inproceedings}
1098 format.authors "author" output.check
1100 format.title "title" output.check
1104 booktitle "booktitle" output.check
1106 format.editors.mid output
1108 format.edition output
1110 format.bvolume.or.num.series output
1112 format.edition output
1114 format.publisher output
1115 format.date "year" output.check
1117 %{ organization publisher new.sentence.checkb
1118 % organization output
1120 % format.date "year" output.check
1122 %{ address output.nonnull
1123 % format.date "year" output.check
1125 % organization output
1132 { format.crossref output.nonnull
1142 FUNCTION {conference} { inproceedings }
1147 { organization empty$
1149 { organization output.nonnull
1154 { format.authors output.nonnull }
1157 format.btitle "title" output.check
1159 format.edition output
1162 { organization empty$
1163 { address new.block.checka
1169 { organization address new.block.checkb
1182 FUNCTION {mastersthesis}
1184 format.authors "author" output.check
1186 format.title "title" output.check
1188 "Diss." format.thesis.type output.nonnull
1190 school "school" output.check
1192 format.date "year" output.check
1202 format.authors output
1203 title howpublished new.block.checkb
1206 %howpublished new.block.checka
1217 FUNCTION {phdthesis}
1219 format.authors "author" output.check
1221 format.btitle "title" output.check
1223 "Diss." format.thesis.type output.nonnull
1225 school "school" output.check
1227 format.date "year" output.check
1235 FUNCTION {proceedings}
1238 { organization output }
1239 { format.editors output.nonnull }
1242 format.btitle "title" output.check
1244 format.bvolume.or.num.series output
1247 { publisher new.sentence.checka }
1248 { organization publisher new.sentence.checkb
1253 format.date "year" output.check
1255 { address output.nonnull
1256 format.date "year" output.check
1260 { organization output }
1272 FUNCTION {techreport}
1274 format.authors "author" output.check
1276 format.title "title" output.check
1278 format.tr.number output.nonnull
1280 institution "institution" output.check
1282 format.date "year" output.check
1288 FUNCTION {unpublished}
1290 format.authors "author" output.check
1292 format.title "title" output.check
1296 note "note" output.check
1301 FUNCTION {default.type} { misc }
1303 MACRO {jan} {"Jan."}
1305 MACRO {feb} {"Feb."}
1307 MACRO {mar} {"Mar."}
1309 MACRO {apr} {"Apr."}
1313 MACRO {jun} {"June"}
1315 MACRO {jul} {"July"}
1317 MACRO {aug} {"Aug."}
1319 MACRO {sep} {"Sept."}
1321 MACRO {oct} {"Oct."}
1323 MACRO {nov} {"Nov."}
1325 MACRO {dec} {"Dec."}
1327 % Currently left in to help with compatibility
1329 MACRO {acmcs} {"ACM Computing Surveys"}
1331 MACRO {acta} {"Acta Informatica"}
1333 MACRO {cacm} {"Communications of the ACM"}
1335 MACRO {ibmjrd} {"IBM Journal of Research and Development"}
1337 MACRO {ibmsj} {"IBM Systems Journal"}
1339 MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
1341 MACRO {ieeetc} {"IEEE Transactions on Computers"}
1344 {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
1346 MACRO {ipl} {"Information Processing Letters"}
1348 MACRO {jacm} {"Journal of the ACM"}
1350 MACRO {jcss} {"Journal of Computer and System Sciences"}
1352 MACRO {scp} {"Science of Computer Programming"}
1354 MACRO {sicomp} {"SIAM Journal on Computing"}
1356 MACRO {tocs} {"ACM Transactions on Computer Systems"}
1358 MACRO {tods} {"ACM Transactions on Database Systems"}
1360 MACRO {tog} {"ACM Transactions on Graphics"}
1362 MACRO {toms} {"ACM Transactions on Mathematical Software"}
1364 MACRO {toois} {"ACM Transactions on Office Information Systems"}
1366 MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
1368 MACRO {tcs} {"Theoretical Computer Science"}
1374 FUNCTION {chop.word}
1377 s #1 len substring$ =
1378 { s len #1 + global.max$ substring$ }
1383 FUNCTION {sort.format.names}
1387 s num.names$ 'numnames :=
1388 numnames 'namesleft :=
1394 s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't :=
1395 nameptr numnames = t "others" = and
1399 nameptr #1 + 'nameptr :=
1400 namesleft #1 - 'namesleft :=
1405 FUNCTION {sort.format.title}
1420 #1 global.max$ substring$
1423 FUNCTION {author.sort}
1426 { "to sort, need author or key in " cite$ * warning$
1432 { author sort.format.names }
1436 FUNCTION {author.editor.sort}
1440 { "to sort, need author, editor, or key in " cite$ * warning$
1446 { editor sort.format.names }
1449 { author sort.format.names }
1453 FUNCTION {author.organization.sort}
1455 { organization empty$
1457 { "to sort, need author, organization, or key in " cite$ * warning$
1463 { "The " #4 organization chop.word sortify }
1466 { author sort.format.names }
1470 FUNCTION {editor.organization.sort}
1472 { organization empty$
1474 { "to sort, need editor, organization, or key in " cite$ * warning$
1480 { "The " #4 organization chop.word sortify }
1483 { editor sort.format.names }
1492 { type$ "proceedings" =
1493 'editor.organization.sort
1495 'author.organization.sort
1502 duplicate$ empty$ 'skip$ { " " * } if$
1504 { title field.or.null sort.format.title * " " * booktitle field.or.null sort.format.title * }
1509 year field.or.null sortify
1511 #1 entry.max$ substring$
1521 FUNCTION {init.vars}
1522 { #0 int.to.chr$ 'a :=
1523 #0 int.to.chr$ 'b :=
1528 % Function name is not strictly accurate
1529 FUNCTION {forward.author.dup.check}
1531 url empty$ urlpath empty$ urldate empty$ and and
1533 { url.used #1 + 'url.used := }
1535 crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$
1537 { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$}
1543 { b "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$
1544 a "{ff~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1545 { #1 'author.duplicate := }
1546 { #0 'author.duplicate := }
1553 FUNCTION {forward.author.share.check}
1555 % Pass through all entries, comparing current author to last one.
1557 { author.duplicate author empty$ or
1558 { author.duplicate { i 'author.shared := }{} if$}
1559 { b "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$
1560 author field.or.null "{f.~}{vv~}{ll}{, jj}" format.names.custom purify$ =
1561 { author.flast 'author.shared := }
1562 { b "{vv~}{ll}" format.names.custom purify$
1563 author field.or.null "{vv~}{ll}" format.names.custom purify$ =
1564 { author.last 'author.shared := }
1565 { author.different 'author.shared := }
1570 author field.or.null 'b :=
1575 FUNCTION {reverse.author}
1579 { i 'author.shared := }
1584 { author.shared i 'author.shared := 'i := }
1585 { author.shared 'i := }
1589 j #1 = author.duplicate not and { #2 'author.duplicate := } {} if$
1590 author.duplicate 'j :=
1593 EXECUTE {init.consts}
1596 ITERATE {forward.author.dup.check}
1599 ITERATE {forward.author.share.check}
1602 REVERSE {reverse.author}
1604 %INTEGERS { number.label longest.label.width }
1606 %FUNCTION {initialize.longest.label}
1607 %{ "" 'longest.label :=
1608 % #1 'number.label :=
1609 % #0 'longest.label.width :=
1612 %FUNCTION {longest.label.pass}
1613 %{ number.label int.to.str$ 'label :=
1614 % number.label #1 + 'number.label :=
1615 % label width$ longest.label.width >
1616 % { label 'longest.label :=
1617 % label width$ 'longest.label.width :=
1623 %EXECUTE {initialize.longest.label}
1625 %ITERATE {longest.label.pass}
1627 FUNCTION {begin.bib}
1630 { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi"
1636 { "\providecommand\url[1]{\texttt{#1}}"
1638 "\providecommand\theurldate{\today}"
1645 { preamble$ write$ newline$ }
1647 "\begin{thebibliography}{\rule{.5in}{0pt}}" write$ newline$
1652 ITERATE {call.type$}
1656 "\end{thebibliography}" write$ newline$