X-Git-Url: http://git.tpope.net/?p=latex-mlastyle.git;a=blobdiff_plain;f=mlastyle.bst;h=0beb5e44a7e513998abbf89fbc0e1b5ae9a13999;hp=6055ac2adb4d23e2b4e34bec686741b614f01f43;hb=6932dd67fd8599e27580c4ea5535d066d7a64b23;hpb=c0f88d764bb0a9b3c2e030210c51bdf2b9f136fa diff --git a/mlastyle.bst b/mlastyle.bst index 6055ac2..0beb5e4 100644 --- a/mlastyle.bst +++ b/mlastyle.bst @@ -1,4 +1,5 @@ -% BibTeX standard bibliography style `plain' +% BibTeX bibliography style `mlastyle' +% Based on BibTeX standard bibliography style `plain' % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09. % Copyright (C) 1985, all rights reserved. % Copying of this file is authorized only if either @@ -40,7 +41,9 @@ ENTRY { author.duplicate author.shared } { label } -INTEGERS { output.state before.all mid.sentence after.sentence after.block after.title author.different author.last author.flast citen.used url.used } +INTEGERS { output.state before.all mid.sentence after.sentence after.block after.title author.different author.last author.flast citealp.used url.used } + +STRINGS { s t u empty.title } % Rearranged such that true values require capital letters FUNCTION {init.consts} @@ -55,25 +58,67 @@ FUNCTION {init.consts} #2 'author.flast := %#3 'author.firstlast := - #0 'citen.used := + #0 'citealp.used := #0 'url.used := + " \ \ \ \ \unskip\unskip\unskip\unskip\unskip " 'empty.title := +} + +FUNCTION {not} +{ { #0 } + { #1 } + if$ +} + +FUNCTION {and} +{ 'skip$ + { pop$ #0 } + if$ +} + +FUNCTION {or} +{ { pop$ #1 } + 'skip$ + if$ } -STRINGS { s t u } % Added u +INTEGERS {chars i j} + +% text.length$ does not include braces +% ...this is probably unnecessary +FUNCTION {num.chars} +{ + #0 'chars := + { duplicate$ duplicate$ #1 chars substring$ = not } + { duplicate$ duplicate$ text.length$ swap$ #1 chars + substring$ text.length$ - chars + #1 + 'chars := } + while$ + { duplicate$ duplicate$ #1 chars #1 - substring$ = } + { chars #1 - 'chars := } + while$ + pop$ chars +} % Puts the period inside any quotes FUNCTION {do.period} -{ - duplicate$ #-1 #3 substring$ "'''" = - { duplicate$ text.length$ #3 - text.prefix$ add.period$ "'\thinspace''" * } - { duplicate$ #-1 #3 substring$ "''}" = - { #2 global.max$ substring$ duplicate$ - text.length$ #2 - text.prefix$ add.period$ "{" swap$ * "''}" * } - { duplicate$ #-1 #2 substring$ "''" = - { duplicate$ text.length$ #2 - text.prefix$ add.period$ "''" * } - { add.period$ } - if$ +{ + duplicate$ #-1 #2 substring$ "''" = + { #2 'i := + { duplicate$ #-1 i - #11 substring$ "'\thinspace" = } + { i #11 + 'i := } + while$ + duplicate$ #-1 i - global.max$ substring$ + add.period$ swap$ #-1 i substring$ * + } + { + duplicate$ #-1 #3 substring$ "''}" = + { #3 'i := + { duplicate$ #-1 i - #11 substring$ "'\thinspace" = } + { i #11 + 'i := } + while$ + duplicate$ #-1 i - global.max$ substring$ + add.period$ swap$ #-1 i substring$ * } + { add.period$ } if$ } if$ @@ -156,24 +201,6 @@ FUNCTION {new.sentence} % if$ %} -FUNCTION {not} -{ { #0 } - { #1 } - if$ -} - -FUNCTION {and} -{ 'skip$ - { pop$ #0 } - if$ -} - -FUNCTION {or} -{ { pop$ #1 } - 'skip$ - if$ -} - FUNCTION {new.block.checka} { empty$ 'skip$ @@ -216,7 +243,51 @@ FUNCTION {field.or.null} FUNCTION {emphasize} { duplicate$ empty$ { pop$ "" } - { "{\em " swap$ * "}" * } + { "\emph{" swap$ * "}" * } + if$ +} + +FUNCTION {enquote} +{ duplicate$ empty$ + { pop$ "" } + { + #1 'i := + #0 'j := + { duplicate$ i #1 substring$ "" = not } + { duplicate$ duplicate$ i #1 substring$ quote$ = + swap$ i #1 - #1 substring$ "\" = not and %" + { duplicate$ #1 i #1 - substring$ swap$ + i #1 + global.max$ substring$ + j + { swap$ duplicate$ #-1 #1 substring$ "'" = + { swap$ "\thinspace'" } + { swap$ "'" } + if$ + #0 'j := + } + { duplicate$ #1 #1 substring$ "`" = + { "`\thinspace" } + { "`" } + if$ + #1 'j := + } + if$ + swap$ * * + } + 'skip$ + if$ + i #1 + 'i := + } + while$ + duplicate$ #1 #1 substring$ "`" = + { "``\thinspace" swap$ * } + { "``" swap$ *} + if$ + duplicate$ #-1 #1 substring$ "'" = + { "\thinspace''" * } + { "''" *} + if$ + } if$ } @@ -265,7 +336,7 @@ FUNCTION {format.names.beginning} { nameptr #1 = { s nameptr "{vv~}{ll}{, ff}{, jj}" format.name$ duplicate$ #1 #1 substring$ "u" change.case$ swap$ - duplicate$ #-1 swap$ text.length$ #1 - substring$ * 't := } + #2 global.max$ substring$ * 't := } { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't := } if$ nameptr #1 > @@ -342,14 +413,7 @@ FUNCTION {format.publisher} % Changed to preserve case and use quotes FUNCTION {format.title} -{ title empty$ - { "" } - { title #1 text.prefix$ "`" = - { "``\thinspace" title * "''" * } - { "``" title * "''" *} - if$ - } - if$ +{ title enquote } FUNCTION {n.dashify} @@ -394,8 +458,13 @@ FUNCTION {format.date} if$ } +INTEGERS {xx} FUNCTION {format.btitle} { title emphasize + %title num.chars int.to.str$ top$ + %#0 'xx := + %{ xx title num.chars < } + %{ title xx #1 + duplicate$ 'xx := #1 substring$ top$ } while$ } FUNCTION {tie.or.space.connect} @@ -640,9 +709,8 @@ FUNCTION {format.article.crossref} %} %{ "In " key * } %if$ - pages empty$ { " \citeN" } { " \citeN[" format.chapter.pages * "]" * } if$ + pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$ "{" * crossref * "}" * - citen.used #1 + 'citen.used := } FUNCTION {format.crossref.editor} @@ -687,9 +755,8 @@ FUNCTION {format.book.crossref} % } % { format.crossref.editor * } % if$ - pages empty$ { " \citeN" } { " \citeN[" format.chapter.pages * "]" * } if$ + pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$ "{" * crossref * "}" * - citen.used #1 + 'citen.used := } FUNCTION {format.incoll.inproc.crossref} @@ -710,9 +777,8 @@ FUNCTION {format.incoll.inproc.crossref} % } % { "In " format.crossref.editor * } % if$ - pages empty$ { " \citeN" } { " \citeN[" format.chapter.pages * "]" * } if$ + pages empty$ { "\citealp" } { "\citealp[" format.chapter.pages * "]" * } if$ "{" * crossref * "}" * - citen.used #1 + 'citen.used := } FUNCTION {cite.title} @@ -737,7 +803,7 @@ FUNCTION {cite.title} type$ "techreport" = type$ "unpublished" = or or or or or or - {"``" swap$ * "''" * } + { enquote } {} if$ } @@ -764,21 +830,25 @@ FUNCTION {cite.label} { author } if$ duplicate$ empty$ - { pop$ cite.title } - { + { cite.title * + "(" * empty.title * ")" * } + { duplicate$ author.shared author.different = - { "{vv~}{ll}" format.names.custom } + { "{vv~}{ll}" format.names.custom 's := } { author.shared author.last = - { "{f.~}{vv~}{ll}{, jj}" format.names.custom } + { "{f.~}{vv~}{ll}{, jj}" format.names.custom 's := } { author.shared author.flast = - { "{ff~}{vv~}{ll}{, jj}" format.names.custom } - { "{vv~}{ll}" format.names.custom ", " * cite.title * } + { "{ff~}{vv~}{ll}{, jj}" format.names.custom 's := } + { "{vv~}{ll}" format.names.custom ", " * cite.title * 's := "WTF" warning$ } if$ } if$ } if$ - author.duplicate { ", " * cite.title * }{} if$ + s + "(" * empty.title * + author.duplicate { cite.title * }{} if$ + ")" * swap$ "{ff~}{vv~}{ll}{, jj}" format.names.custom * } if$ %} @@ -809,6 +879,7 @@ FUNCTION {article} new.block crossref missing$ { journal emphasize "journal" output.check after.title 'output.state := + address empty$ skip$ { "[" address * "]" * output } if$ %format.date "year" output.check %edition output format.vol.num.year.pages output @@ -832,9 +903,9 @@ FUNCTION {book} if$ new.block format.btitle "title" output.check - new.sentence + new.block crossref missing$ - { author empty$ 'skip$ { format.editors.mid output new.sentence } if$ + { author empty$ 'skip$ { format.editors.mid output new.block } if$ format.edition output new.sentence format.bvolume.or.num.series output @@ -878,7 +949,7 @@ FUNCTION {inbook} format.btitle "title" output.check new.block crossref missing$ - { author empty$ 'skip$ { format.editors.mid output new.sentence } if$ + { author empty$ 'skip$ { format.editors.mid output new.block } if$ format.edition output new.sentence format.bvolume.or.num.series output @@ -913,7 +984,7 @@ FUNCTION {incollection} crossref missing$ { booktitle emphasize "booktitle" output.check - new.sentence + new.block format.editors.mid "editor" output.check new.block format.edition output @@ -948,7 +1019,7 @@ FUNCTION {inproceedings} booktitle "booktitle" output.check new.sentence format.editors.mid output - new.sentence + new.block format.edition output new.sentence format.bvolume.or.num.series output @@ -1000,7 +1071,7 @@ FUNCTION {manual} if$ new.block format.btitle "title" output.check - new.sentence + new.block format.edition output new.sentence author empty$ @@ -1030,7 +1101,7 @@ FUNCTION {mastersthesis} new.block format.title "title" output.check new.block - "Diss." format.thesis.type output.nonnull + "Diss." format.thesis.type do.period output.nonnull after.title 'output.state := school "school" output.check address output @@ -1065,7 +1136,7 @@ FUNCTION {phdthesis} new.block format.btitle "title" output.check new.block - "Diss." format.thesis.type output.nonnull + "Diss." format.thesis.type do.period output.nonnull after.title 'output.state := school "school" output.check address output @@ -1357,7 +1428,6 @@ ITERATE {presort} SORT STRINGS {a b} -INTEGERS {i j} FUNCTION {init.vars} { #0 int.to.chr$ 'a := @@ -1369,7 +1439,7 @@ FUNCTION {init.vars} FUNCTION {forward.author.dup.check} { url empty$ 'skip$ { url.used #1 + 'url.used := } if$ - crossref empty$ 'skip$ { citen.used #1 + 'citen.used := } if$ + crossref empty$ 'skip$ { citealp.used #1 + 'citealp.used := } if$ author empty$ { editor empty$ { organization field.or.null 'a := }{ editor 'a :=} if$} { author 'a := } @@ -1463,12 +1533,14 @@ REVERSE {reverse.author} FUNCTION {begin.bib} { - citen.used - { "\ifx\undefined\citeN\let\citeN\cite\fi" write$ newline$ } + citealp.used + { "\expandafter\ifx\csname citealp\endcsname\relax\let\citealp\cite\fi" + write$ newline$ } 'skip$ if$ url.used - { "\ifx\undefined\url\let\url\relax\fi" write$ newline$ } + { "\expandafter\ifx\csname citealp\endcsname\relax\url\let\url\relax\fi" + write$ newline$ } 'skip$ if$ preamble$ empty$