Guest User

Untitled

a guest
Jul 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. documentclass{article}
  2. usepackage[style=authoryear]{biblatex}
  3.  
  4. DeclareSourcemap{maps[datatype = bibtex]{map{
  5. %% 1. Find year in brackets and sort them as if they were without brackets
  6. step[fieldsource = year,
  7. match = regexp{A[(.+)]z}, final]
  8. step[fieldset = sortyear, fieldvalue = {$1}]
  9. %% 2. Abbreviate an entry such as Adam J[ohn] Smith to Smith, Adam J.
  10. step[fieldsource = author,
  11. match = regexp{[[^]]+]},
  12. replace = .]
  13. %% 3. Change US postal codes such as 'MA' to 'StateMA'
  14. step[fieldsource = location,
  15. match = regexp{,s*(MA|CA|NY)},
  16. replace = regexp{,~\State{$1}}]
  17. }}}
  18. % then change 'StateMA' etc. to AP style abbreviations 'Mass.' etc.
  19. defState#1{csname State#1endcsname}
  20. defStateMA{Mass.}
  21. defStateCA{Calif.}
  22. defStateNY{N.Y.}
  23.  
  24. begin{filecontents}{jobname.bib}
  25. @ARTICLE{western1889,
  26. AUTHOR = "Aug[ust] Western",
  27. TITLE = "Kurze darstellung des norwegischen lautsystems",
  28. JOURNALTITLE = "Phonetische Studien",
  29. YEAR = "1889",
  30. PAGES = "259--282",
  31. VOLUME = "2"}
  32. @BOOK{lehiste1970,
  33. AUTHOR = "Ilse Lehiste",
  34. TITLE = "Suprasegmentals",
  35. YEAR = "1970",
  36. LOCATION = "Cambridge, MA",
  37. PUBLISHER = "The M.I.T. Press"}
  38. @BOOK{hoff1946,
  39. AUTHOR = "Ingeborg Hoff",
  40. TITLE = "Skjetvem{aa}let",
  41. YEAR = "1946",
  42. LOCATION = "Oslo",
  43. NUMBER = "1",
  44. PUBLISHER = "Jacob Dybwad",
  45. SERIES = "Skrifter utgitt av Det Norske Videnskaps-Akademi i Oslo. II. Historisk-filosofisk klasse. 1946"}
  46. @INCOLLECTION{hoff1968,
  47. AUTHOR = "Ingeborg Hoff",
  48. BOOKTITLE = "Aurskog og Blaker",
  49. EDITOR = "[Eyvind Lillevold]",
  50. TITLE = "M{aa}let i Aurskog og Blaker",
  51. YEAR = "[1968]",
  52. LOCATION = "[Aurskog og Blaker]",
  53. PAGES = "685--752",
  54. PUBLISHER = "Bygdeboknemnda for Aurskog og Blaker",
  55. VOLUME = "3"}
  56. end{filecontents}
  57. addbibresource{jobname.bib}
  58.  
  59. begin{document}
  60. nocite{*}
  61. printbibliography
  62. end{document}
  63.  
  64. documentclass{article}
  65. usepackage[style=authoryear]{biblatex}
  66.  
  67. DeclareSourcemap{
  68. maps[datatype = bibtex]{
  69. map{%% 1. Find year in brackets and sort them as if they were without brackets
  70. step[fieldsource = year,
  71. match = regexp{A[(.+)]z}, final]
  72. step[fieldset = sortyear, fieldvalue = {$1}]
  73. }
  74. map{%% 2. Abbreviate an entry such as Adam J[ohn] Smith to Smith, Adam J.
  75. step[fieldsource = author,
  76. match = regexp{[[^]]+]},
  77. replace = .]
  78. }
  79. map{%% 3. Change US postal codes such as 'MA' to 'StateMA'
  80. step[fieldsource = location,
  81. match = regexp{,s*(MA|CA|NY)},
  82. replace = regexp{,~\State{$1}}]
  83. }
  84. }
  85. }
  86. % then change 'StateMA' etc. to AP style abbreviations 'Mass.' etc.
  87. newcommand{State}[1]{csname State#1endcsname}
  88. newcommand{StateMA}{Mass.}
  89. newcommand{StateCA}{Calif.}
  90. newcommand{StateNY}{N.Y.}
  91.  
  92. begin{filecontents}{jobname.bib}
  93. @ARTICLE{western1889,
  94. AUTHOR = "Aug[ust] Western",
  95. TITLE = "Kurze darstellung des norwegischen lautsystems",
  96. JOURNALTITLE = "Phonetische Studien",
  97. YEAR = "1889",
  98. PAGES = "259--282",
  99. VOLUME = "2"}
  100. @BOOK{lehiste1970,
  101. AUTHOR = "Ilse Lehiste",
  102. TITLE = "Suprasegmentals",
  103. YEAR = "1970",
  104. LOCATION = "Cambridge, MA",
  105. PUBLISHER = "The M.I.T. Press"}
  106. @BOOK{hoff1946,
  107. AUTHOR = "Ingeborg Hoff",
  108. TITLE = "Skjetvem{aa}let",
  109. YEAR = "1946",
  110. LOCATION = "Oslo",
  111. NUMBER = "1",
  112. PUBLISHER = "Jacob Dybwad",
  113. SERIES = "Skrifter utgitt av Det Norske Videnskaps-Akademi i Oslo. II. Historisk-filosofisk klasse. 1946"}
  114. @INCOLLECTION{hoff1968,
  115. AUTHOR = "Ingeborg Hoff",
  116. BOOKTITLE = "Aurskog og Blaker",
  117. EDITOR = "[Eyvind Lillevold]",
  118. TITLE = "M{aa}let i Aurskog og Blaker",
  119. YEAR = "[1968]",
  120. LOCATION = "[Aurskog og Blaker]",
  121. PAGES = "685--752",
  122. PUBLISHER = "Bygdeboknemnda for Aurskog og Blaker",
  123. VOLUME = "3"}
  124. end{filecontents}
  125. addbibresource{jobname.bib}
  126.  
  127. begin{document}
  128. nocite{*}
  129. printbibliography
  130. end{document}
Add Comment
Please, Sign In to add comment