Debian Codegraph @

texmf-dist/bibtex/bst/mnras/mnras.bst

raw
1 %%+
2 %% Name:
3 %% mnras.bst
4
5 %% Purpose:
6 %% BibTeX Bibliography style file for MNRAS
7
8 %% Invocation:
9 %% latex <latexfile>
10 %% bibtex <latexfile>
11 %% latex <latexfile>
12 %% latex <latexfile>
13
14 %% Description:
15 %% Provides a bibliography style that will allow bibtex to be
16 %% used when writing papers for MNRAS. This allows references
17 %% to be inserted automatically.
18
19 %% Notes:
20 %% This file should be used in conjunction with the Monthly Notices
21 %% LaTeX2e class file (mnras.cls).
22 %%
23 %% Hyperlinks:
24 %% To make the eprint and doi bibtex fields hyperlinks, you need
25 %% to have \usepackage{hyperref} in your latex preamble.
26
27 %% Authors:
28 %% John P. Sleath (MRAO)
29 %% Tim Jenness (MRAO/JAC)
30 %% Norman Gray (Glasgow University) <[email protected]>
31 %% Oren Patashnik
32 %% Susan King
33 %% Sake J. Hogeveen
34 %% Philip Hall
35 %% Simeon Bird
36
37 %% Bugs:
38 %% The formatting has been compared to the MN style, and is
39 %% believed to be compatible with it. However this comparison has
40 %% (for obvious reasons) been done most carefully for articles, so
41 %% there may be deviations from it for other entry types.
42
43 %% History:
44 %% 1988 (Oren Patashnik and Susan King)
45 %% Apalike.bst derived from the "alpha.bst" style.
46 %% 1990 (Sake J. Hogeveen)
47 %% Astron.bst derived from apalike.bst
48 %% Summer 1995 (JPS/TJ):
49 %% Extensively modified from astron.bst
50 %% 19 Jul 1995 (JPS/TJ):
51 %% First release (version 1.1b)
52 %% 02 May 2001 (NG):
53 %% Limit the author lists to eight people.
54 %% 19 Jun 2001 (TJ):
55 %% Fix inproceedings
56 %% 30 Oct 2001 (NG):
57 %% Adjust author-limiting to conform to MN style (version 1.2)
58 %% 22 Sep 2012 (Philip Hall):
59 %% Remove comma before et al when many authors.
60 %% 01 July 2013 (Simeon Bird):
61 %% Ported Antony Lewis' hyperlinked arxiv entry additions across.
62 %% Originally modified for hyperlinked arxiv eprints by Antony Lewis April 2006
63 %% August 2013 (NG):
64 %% Fixed a/b/c... year suffixes -- these now appear in the
65 %% correct order.
66 %% February 2014 (TJ):
67 %% Add MACROs for MN journal abbreviations
68 %% May 2014 (NG):
69 %% Shorten some functions, so that bibtex's 'single function
70 %% space' parameter doesn't have to be above 100.
71 %% Sep 2014 (Jared M. Gabor):
72 %% Enabled ArXiv e-print identifier to be printed for articles that
73 %% are pre-prints only (and have "ArXiv e-print" in the journal field).
74 %% Still some problems with the use of commas. Only 1 comma will appear
75 %% between the year and "arXiv..." for such preprints, but for e.g.
76 %% conference precedings there may be no comma at all.
77 %% 09 March 2015 (TJ):
78 %% At the request of Keith Smith this file has been renamed to be mnras.bst
79 %% to match the new naming convention for the MNRAS class file.
80 %%
81 %% License:
82 %% This work may be distributed and/or modified under the
83 %% conditions of the LaTeX Project Public License, either version 1.3
84 %% of this license or (at your option) any later version.
85 %% The latest version of this license is in
86 %% http://www.latex-project.org/lppl.txt
87 %% and version 1.3 or later is part of all distributions of LaTeX
88 %% version 2005/12/01 or later.
89 %%
90 %% This work has the LPPL maintenance status `maintained'.
91 %%
92 %% The Current Maintainers of this work are T. Jenness
93 %% and Norman Gray <[email protected]>
94 %%
95 %% This work consists of the file mnras.bst
96
97 %% This file is maintained on Github: https://github.com/timj/mn2e-bst/
98 %%-
99
100 ENTRY
101 { address
102 doi
103 eprint
104 archiveprefix % used by ADS
105 author
106 booktitle
107 chapter
108 edition
109 editor
110 howpublished
111 institution
112 journal
113 key
114 % month not used in apalike
115 note
116 number
117 organization
118 pages
119 publisher
120 school
121 series
122 title
123 type
124 volume
125 year
126 adsurl % for MN style
127 url
128 }
129 {}
130 { label extra.label sort.label presort.key }
131
132
133 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
134
135 FUNCTION {init.state.consts}
136 { #0 'before.all :=
137 #1 'mid.sentence :=
138 #2 'after.sentence :=
139 #3 'after.block :=
140 }
141
142 % If threeauthorvar is set to #1 in initialise.mn2e, then the bibitem for a
143 % three-author reference is generated using a \mniiiauthor command.
144 % This command should be defined in the .cls file as follows:
145 %
146 % \def\mniiiauthor#1#2#3{%
147 % \@ifundefined{mniiiauth@#1}
148 % {\global\expandafter\let\csname mniiiauth@#1\endcsname\null #2}
149 % {#3}}
150 %
151 % The effect of this is that the first time that \mniiiauthor{X}{a}{b}
152 % is evaluated, it expands to 'a', and it thereafter expands to 'b'.
153 % This implements the MN style guide stipulation that "For three
154 % authors, give all three names at first mention, e.g. (Brown, Jones &
155 % Smith 1994), but use first author et al. (in roman, not italic)
156 % thereafter, e.g. (Brown et al. 1994)."
157 %
158 % The above definition consumes a command for each such author. It's
159 % surely possible to avoid this (with some constructions involving
160 % {\\#1}; see Appendix D cleverness), but that would verge on the
161 % arcane, and not be really worth it.
162 INTEGERS { maxauthors threeauthorvar }
163
164 FUNCTION {initialise.mn2e}
165 {
166 #8 'maxauthors :=
167 #0 'threeauthorvar :=
168 }
169
170 STRINGS { s t fmt sep }
171
172 FUNCTION {output.nonnull}
173 { 's :=
174 output.state mid.sentence =
175 { ", " * write$ }
176 { output.state after.block =
177 { ". " * write$
178 newline$
179 % "\newblock " write$
180 }
181 { output.state before.all =
182 'write$
183 { ", " * write$ }
184 if$
185 }
186 if$
187 mid.sentence 'output.state :=
188 }
189 if$
190 s
191 }
192
193 % output.nonnull.extra is like output.nonnull, except that the thing
194 % we output is 'extra' to a block, so if we're in the after.block
195 % state, we append it rather than starting a new block.
196 FUNCTION {output.nonnull.extra}
197 { 's :=
198 output.state mid.sentence =
199 { ", " * write$ }
200 { output.state after.block =
201 { ", " * write$
202 newline$
203 "\newblock " write$
204 }
205 { output.state before.all =
206 'write$
207 { ", " * write$ }
208 if$
209 }
210 if$
211 mid.sentence 'output.state :=
212 }
213 if$
214 s
215 }
216
217 FUNCTION {output.nonnull.nocomma}
218 {'s :=
219 output.state mid.sentence =
220 { write$ }
221 { output.state after.block =
222 { ". " * write$
223 newline$
224 % "\newblock " write$
225 }
226 { output.state before.all =
227 'write$
228 { ", " * write$ }
229 if$
230 }
231 if$
232 mid.sentence 'output.state :=
233 }
234 if$
235 s
236 }
237
238 FUNCTION {output}
239 { duplicate$ empty$
240 'pop$
241 'output.nonnull
242 if$
243 }
244
245 FUNCTION {output.extra}
246 { duplicate$ empty$
247 'pop$
248 'output.nonnull.extra
249 if$
250 }
251
252 FUNCTION {output.check}
253 { 't :=
254 duplicate$ empty$
255 { pop$ "empty " t * " in " * cite$ * warning$ }
256 'output.nonnull
257 if$
258 }
259
260 FUNCTION {output.check.nocomma}
261 { 't :=
262 duplicate$ empty$
263 'pop$ % or warn with { pop$ "empty " t * " in " * cite$ * warning$ }
264 'output.nonnull.nocomma
265 if$
266 }
267
268 FUNCTION {output.check.extra}
269 { 't :=
270 duplicate$ empty$
271 { pop$ "empty " t * " in " * cite$ * warning$ }
272 'output.nonnull.extra
273 if$
274 }
275
276 FUNCTION {output.year.check}
277 { year empty$
278 { "empty year in " cite$ * warning$ }
279 { write$
280 " " year * extra.label *
281 mid.sentence 'output.state :=
282 }
283 if$
284 }
285
286 FUNCTION {output.bibitem}
287 { newline$
288 "\bibitem[" write$
289 label write$
290 "]{" write$
291 cite$ write$
292 "}" write$
293 % debugging: define eg \def\logsortkey#1{{[\tiny #1]}} to see this
294 %"\logsortkey{" presort.key * "/" * sort.key$ * "}" * write$
295 newline$
296 ""
297 before.all 'output.state :=
298 }
299
300 FUNCTION {fin.entry}
301 { write$
302 newline$
303 }
304
305 FUNCTION {new.block}
306 { output.state before.all =
307 'skip$
308 { after.block 'output.state := }
309 if$
310 }
311
312 FUNCTION {new.sentence}
313 { output.state after.block =
314 'skip$
315 { output.state before.all =
316 'skip$
317 { after.sentence 'output.state := }
318 if$
319 }
320 if$
321 }
322
323 FUNCTION {not}
324 { { #0 }
325 { #1 }
326 if$
327 }
328
329 FUNCTION {and}
330 { 'skip$
331 { pop$ #0 }
332 if$
333 }
334
335 FUNCTION {or}
336 { { pop$ #1 }
337 'skip$
338 if$
339 }
340
341 FUNCTION {new.block.checkb}
342 { empty$
343 swap$ empty$
344 and
345 'skip$
346 'new.block
347 if$
348 }
349
350 FUNCTION {field.or.null}
351 { duplicate$ empty$
352 { pop$ "" }
353 'skip$
354 if$
355 }
356
357 FUNCTION {boldface}
358 { duplicate$ empty$
359 { pop$ "" }
360 { "{ " swap$ * "}" * }
361 if$
362 }
363
364 FUNCTION {emphasize}
365 { duplicate$ empty$
366 { pop$ "" }
367 { "{ " swap$ * "}" * }
368 if$
369 }
370
371 % Make hyperref links.
372 % The LaTeX hyperref package supports a macro \href{URL}{text}
373 %
374 % On call, the stack contains
375 % href-url
376 % link-text
377 FUNCTION {make.href.hyperref}
378 {
379 "\href {" swap$ * "} {" * swap$ * "}" *
380 }
381
382 INTEGERS { nameptr namesleft numnames }
383
384 % Helper functions for print.all.names: print the last or 'others' name.
385 %
386 % On call, the stack contains
387 % a formatted name,
388 % and the built-up string of names so far.
389 FUNCTION {print.all.names.plain.trailer}
390 { duplicate$ "others" =
391 { pop$ " et~al.," * }
392 { " " swap$ * * }
393 if$
394 }
395
396 % as above
397 FUNCTION {print.all.names.label.trailer}
398 { duplicate$ "others" =
399 { pop$ " et~al." * }
400 { " \& " swap$ * * }
401 if$
402 }
403
404 % Print out the complete author list
405 % (because we have maxauthors or fewer).
406 %
407 % On call, the stack contains
408 % a format string (for format.name$),
409 % a name-separator string (such as ", "),
410 % an author or editor field,
411 % and one of the 'trailer' functions above.
412 FUNCTION {print.all.names}
413 { 'fmt :=
414 'sep :=
415 's :=
416 s num.names$ 'namesleft :=
417 namesleft #2 < % we're not going to need the trailer function, so discard it
418 'pop$
419 'skip$
420 if$
421 #1 'nameptr :=
422 { namesleft #0 > }
423 { s nameptr fmt format.name$ 't := % last name first
424 nameptr #1 >
425 { namesleft #1 >
426 { sep * t * }
427 { % namesleft == 1: this is the last name.
428 % Invoke the trailer function.
429 s num.names$ #2 > % _why_ do we add this extra space for long lists?
430 { " " * }
431 'skip$
432 if$
433 % This next line is a bit clever.
434 %
435 % We start with a stack
436 % string containing the list of names so far
437 % trailer function
438 %
439 % Rearrange the stack so that we have
440 % 'skip
441 % trailer function
442 % #1
443 % t
444 % names so far
445 % then call if$. This is a rather indirect way of
446 % invoking the trailer function on the stack
447 % t
448 % names so far
449 %
450 % Ta dahhhh!
451 swap$ t swap$ #1 swap$ 'skip$ if$
452 }
453 if$
454 }
455 't
456 if$
457 nameptr #1 + 'nameptr :=
458 namesleft #1 - 'namesleft :=
459 }
460 while$
461 }
462
463 % Name formatting. According to the MN instructions for authors, `In
464 % the references list [...] List all authors if eight or fewer,
465 % otherwise et al.'. This means (according to a ruling from the MN
466 % editors) that if there are eight or more authors, they should be
467 % listed as "first one plus et al."
468 %
469 % On call, the stack contains
470 % an author or editor field.
471 FUNCTION {format.names}
472 { duplicate$ num.names$ maxauthors >
473 { % Too many authors -- format as First author et al.
474 #1 "{vv }{ll}{ jj}{ f., }" format.name$ % last name first
475 " et~al.," *
476 }
477 { 'print.all.names.plain.trailer swap$ " " "{vv }{ll}{ jj}{ f., }" print.all.names }
478 if$
479 }
480
481 % Format an author/editor field, for inclusion in a label
482 % (ie, "Surname, Surname \& Surname")
483 %
484 % On call, the stack contains an author/editor field.
485 FUNCTION {format.names.label}
486 { duplicate$ num.names$ maxauthors >
487 { % Too many authors -- format as First author et al.
488 #1 "{vv }{ll}{ jj}" format.name$ % last name first
489 " et~al.," *
490 }
491 { 'print.all.names.label.trailer swap$ ", " "{vv }{ll}" print.all.names }
492 if$
493 }
494
495 FUNCTION {format.authors}
496 { author empty$
497 { "" }
498 { author format.names }
499 if$
500 }
501
502 FUNCTION {format.key} % this function is just for apalike
503 { empty$
504 { key field.or.null }
505 { "" }
506 if$
507 }
508
509 FUNCTION {format.editors}
510 { editor empty$
511 { "" }
512 { editor format.names
513 editor num.names$ #1 >
514 { " eds," * }
515 { " ed." * }
516 if$
517 }
518 if$
519 }
520
521 FUNCTION {format.editors.extra}
522 { editor empty$
523 { "" }
524 { editor format.names
525 editor num.names$ #1 >
526 { " eds" * }
527 { " ed." * }
528 if$
529 }
530 if$
531 }
532
533 FUNCTION {format.title}
534 { title empty$
535 { "" }
536 { title "t" change.case$ }
537 if$
538 }
539
540 FUNCTION {format.eprint}
541 { eprint empty$
542 { "" }
543 { " (\mn@eprint {"
544 archiveprefix empty$
545 { "" }
546 { archiveprefix }
547 if$
548 * "} {" * eprint * "})" * }
549 if$
550 }
551
552 FUNCTION {format.doi}
553 { doi empty$
554 { "" }
555 { ", \mn@doi{" * doi * "}" }
556 if$
557 }
558
559 FUNCTION {n.dashify}
560 { 't :=
561 ""
562 { t empty$ not }
563 { t #1 #1 substring$ "-" =
564 { t #1 #2 substring$ "--" = not
565 { "--" *
566 t #2 global.max$ substring$ 't :=
567 }
568 { { t #1 #1 substring$ "-" = }
569 { "-" *
570 t #2 global.max$ substring$ 't :=
571 }
572 while$
573 }
574 if$
575 }
576 { t #1 #1 substring$ *
577 t #2 global.max$ substring$ 't :=
578 }
579 if$
580 }
581 while$
582 }
583
584 FUNCTION {first.page.number}
585 { 't :=
586 ""
587 { t "" =
588 { #0 }
589 { t #1 #1 substring$ "-" = not }
590 if$
591 }
592 { t #1 #1 substring$ *
593 t #2 global.max$ substring$ 't :=
594 }
595 while$
596 }
597
598 FUNCTION {format.btitle}
599 { title
600 }
601
602 FUNCTION {tie.or.space.connect}
603 { duplicate$ text.length$ #5 <
604 { "~" }
605 { " " }
606 if$
607 swap$ * *
608 }
609
610 FUNCTION {either.or.check}
611 { empty$
612 'pop$
613 { "can't use both " swap$ * " fields in " * cite$ * warning$ }
614 if$
615 }
616
617 FUNCTION {format.bvolume}
618 { volume empty$
619 { "" }
620 { "" series tie.or.space.connect
621 volume empty$
622 'skip$
623 { " Vol. " * volume * }
624 if$
625 "volume and number" number either.or.check
626 }
627 if$
628 }
629
630 FUNCTION {format.number.series}
631 { volume empty$
632 { number empty$
633 { series field.or.null }
634 { output.state mid.sentence =
635 { "No." }
636 { "No." }
637 if$
638 number tie.or.space.connect
639 series empty$
640 { "there's a number but no series in " cite$ * warning$ }
641 { " in " * series * }
642 if$
643 }
644 if$
645 }
646 { "" }
647 if$
648 }
649
650 FUNCTION {format.edition}
651 { edition empty$
652 { "" }
653 { output.state mid.sentence =
654 { edition "l" change.case$ " edn" * }
655 { edition "t" change.case$ " edn" * }
656 if$
657 }
658 if$
659 }
660
661 INTEGERS { multiresult }
662
663 FUNCTION {multi.page.check}
664 { 't :=
665 #0 'multiresult :=
666 { multiresult not
667 t empty$ not
668 and
669 }
670 { t #1 #1 substring$
671 duplicate$ "-" =
672 swap$ duplicate$ "," =
673 swap$ "+" =
674 or or
675 { #1 'multiresult := }
676 { t #2 global.max$ substring$ 't := }
677 if$
678 }
679 while$
680 multiresult
681 }
682
683 FUNCTION {format.pages}
684 { pages empty$
685 { "" }
686 { pages multi.page.check
687 { "pp" pages n.dashify tie.or.space.connect }
688 { "p." pages tie.or.space.connect }
689 if$
690 }
691 if$
692 }
693
694 FUNCTION {format.page}
695 { pages empty$
696 { "" }
697 { "p.~" pages first.page.number * }
698 if$
699 }
700
701 % If a paper is available as a preprint only, ADS will call the
702 % journal "ArXiv e-print". In this case MN suggests the journal
703 % should be called "preprint".
704 FUNCTION {format.journal.doi}
705 { doi empty$
706 { journal "ArXiv e-prints" =
707 { "preprint" }
708 { journal }
709 if$
710 }
711 { journal "ArXiv e-prints" =
712 { "preprint" }
713 { "\mn@doi [" journal * "] {" * doi * "}" * }
714 if$
715 }
716 if$
717 }
718
719 FUNCTION {format.vol.num.pages}
720 { volume field.or.null
721 number empty$
722 'skip$
723 { "(" number * ")" * *
724 volume empty$
725 { "there's a number but no volume in " cite$ * warning$ }
726 'skip$
727 if$
728 }
729 if$
730 pages empty$
731 'skip$
732 { duplicate$ empty$
733 { pop$ format.pages }
734 { ", " * pages n.dashify * }
735 if$
736 }
737 if$
738 }
739
740 FUNCTION {format.vol.page}
741 { volume field.or.null
742 pages empty$
743 'skip$
744 { duplicate$ empty$
745 { pop$ format.pages }
746 { ", " * pages first.page.number * }
747 if$
748 }
749 if$
750 }
751
752 FUNCTION {format.vol.num.page}
753 { volume field.or.null
754 number empty$
755 'skip$
756 { "(" number * ")" * *
757 volume empty$
758 { "there's a number but no volume in " cite$ * warning$ }
759 'skip$
760 if$
761 }
762 if$
763 pages empty$
764 'skip$
765 { duplicate$ empty$
766 { pop$ format.pages }
767 { ", " * pages first.page.number * }
768 if$
769 }
770 if$
771 }
772 FUNCTION {format.chapter.pages}
773 { chapter empty$
774 'format.pages
775 { type empty$
776 { "Chapt." }
777 { type "l" change.case$ }
778 if$
779 chapter tie.or.space.connect
780 pages empty$
781 'skip$
782 { ", " * format.pages * }
783 if$
784 }
785 if$
786 }
787
788 FUNCTION {format.in.ed.booktitle}
789 { booktitle empty$
790 { "" }
791 { editor empty$
792 { "in " booktitle * }
793 { format.bvolume empty$
794 { "in " format.editors.extra * ", " * booktitle * }
795 { "in " format.editors.extra * ", " * format.bvolume * ", " * booktitle * }
796 if$
797 }
798 if$
799 }
800 if$
801 }
802
803 FUNCTION {format.in.ed.collect}
804 { booktitle empty$
805 { "" }
806 { editor empty$
807 { "in " }
808 { "in " format.editors.extra * ", " * }
809 if$
810 series empty$
811 { skip$ }
812 { series * }
813 if$
814 volume empty$
815 { number empty$
816 { }
817 { output.state mid.sentence =
818 { "No." }
819 { "No." }
820 if$
821 number tie.or.space.connect *
822 }
823 if$
824 }
825 {
826 output.state mid.sentence =
827 { ", " * }
828 { skip$ }
829 if$
830 "Vol." volume tie.or.space.connect *
831 }
832 if$
833 output.state mid.sentence =
834 { ", " * }
835 { skip$ }
836 if$
837 booktitle *
838 }
839 if$
840 }
841
842 FUNCTION {format.thesis.type}
843 { type empty$
844 'skip$
845 { pop$
846 type "t" change.case$
847 }
848 if$
849 }
850
851 % the \url{} macro is supplied by hyperref
852 FUNCTION {format.url}
853 {
854 url empty$
855 { "" }
856 { "\url {" url * "}" * }
857 if$
858 }
859
860 FUNCTION {format.tr.number}
861 {
862 type empty$
863 { "Technical Report" }
864 { type }
865 if$
866 number empty$
867 { "t" change.case$ }
868 { number tie.or.space.connect }
869 if$
870 }
871
872 FUNCTION {format.article.crossref}
873 { "in" % this is for apalike
874 " \cite{" * crossref * "}" *
875 }
876
877 FUNCTION {format.book.crossref}
878 { volume empty$
879 { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
880 "in "
881 }
882 { "Vol." volume tie.or.space.connect
883 " of " *
884 }
885 if$
886 "\cite{" * crossref * "}" * % this is for apalike
887 }
888
889 FUNCTION {format.incoll.inproc.crossref}
890 { "in" % this is for apalike
891 " \cite{" * crossref * "}" *
892 }
893
894 FUNCTION {article}
895 { output.bibitem
896 format.authors "author" output.check
897 author format.key output % special for
898 output.year.check % apalike
899 % MN style does not display eprints or DOIs on published articles,
900 % but does link the journal name to any available DOI.
901 crossref missing$
902 { format.journal.doi "journal" output.check.extra
903 % ...and links volume and page information to any available adsurl
904 adsurl empty$
905 { format.vol.page }
906 { format.vol.page adsurl make.href.hyperref }
907 if$
908 output.extra
909 }
910 { format.article.crossref output.nonnull
911 format.page output
912 }
913 if$
914
915 % If the "journal" field is the arXiv, then print out the arXiv identifier
916 journal "ArXiv e-prints" =
917 { format.eprint "eprint" output.check.nocomma }
918 { }
919 if$
920
921 fin.entry
922 }
923
924 FUNCTION {book}
925 { output.bibitem
926 author empty$
927 { format.editors "author and editor" output.check
928 editor format.key output
929 }
930 { format.authors output.nonnull
931 crossref missing$
932 { "author and editor" editor either.or.check }
933 'skip$
934 if$
935 }
936 if$
937 output.year.check % special for apalike
938 format.btitle "title" output.check
939 format.edition output
940 new.block
941 crossref missing$
942 { format.bvolume output
943 format.number.series output
944 new.sentence
945 publisher "publisher" output.check
946 address output
947 }
948 {format.book.crossref output.nonnull}
949 if$
950 format.eprint "eprint" output.check.nocomma
951 format.doi "doi" output.check.nocomma
952 format.url output
953 fin.entry
954 }
955
956 FUNCTION {booklet}
957 { output.bibitem
958 format.authors output
959 author format.key output % special for
960 output.year.check % apalike
961 format.btitle "title" output.check
962 howpublished output
963 address output
964 format.eprint "eprint" output.check.nocomma
965 format.doi "doi" output.check.nocomma
966 format.url output
967 fin.entry
968 }
969
970 FUNCTION {inbook}
971 { output.bibitem
972 author empty$
973 { format.editors "author and editor" output.check
974 editor format.key output
975 }
976 { format.authors output.nonnull
977 crossref missing$
978 { "author and editor" editor either.or.check }
979 'skip$
980 if$
981 }
982 if$
983 output.year.check % special for apalike
984 format.btitle "title" output.check
985 format.edition output
986 new.block
987 crossref missing$
988 {
989 new.sentence
990 publisher "publisher" output.check
991 address output
992 format.pages output
993 }
994 { format.chapter.pages "chapter and pages" output.check
995 format.book.crossref output.nonnull
996 }
997 if$
998 format.eprint "eprint" output.check.nocomma
999 format.doi "doi" output.check.nocomma
1000 format.url output
1001 fin.entry
1002 }
1003
1004 FUNCTION {incollection}
1005 { output.bibitem
1006 format.authors "author" output.check
1007 author format.key output % special for
1008 output.year.check % apalike
1009 crossref missing$
1010 {
1011 format.in.ed.collect "booktitle" output.check
1012 format.edition output
1013 booktitle empty$ edition empty$ =
1014 { } { new.block } if$
1015 new.sentence
1016 publisher "publisher" output.check
1017 address output
1018 }
1019 { format.incoll.inproc.crossref output.nonnull
1020 format.chapter.pages output
1021 }
1022 if$
1023 format.chapter.pages output
1024 format.eprint "eprint" output.check.nocomma
1025 format.doi "doi" output.check.nocomma
1026 format.url output
1027 fin.entry
1028 }
1029
1030 FUNCTION {inproceedings}
1031 { output.bibitem
1032 format.authors "author" output.check
1033 author format.key output % special for
1034 output.year.check % apalike
1035 crossref missing$
1036 {
1037
1038 format.in.ed.booktitle "booktitle" output.check
1039 ". " *
1040 % format.bvolume output
1041 before.all 'output.state :=
1042 new.block
1043 % format.title "title" output.check
1044 format.number.series output
1045 new.block
1046 % organization output
1047 publisher output
1048 address output
1049 format.pages output
1050 }
1051 { format.incoll.inproc.crossref output.nonnull
1052 format.pages output
1053 }
1054 if$
1055 format.eprint "eprint" output.check.nocomma
1056 format.doi "doi" output.check.nocomma
1057 format.url output
1058 fin.entry
1059 }
1060
1061 FUNCTION {conference} { inproceedings }
1062
1063 FUNCTION {manual}
1064 { output.bibitem
1065 format.authors output
1066 author format.key output % special for
1067 output.year.check % apalike
1068 format.btitle "title" output.check
1069 new.block
1070 organization address new.block.checkb
1071 organization output
1072 address output
1073 format.edition output
1074 format.eprint "eprint" output.check.nocomma
1075 format.doi "doi" output.check.nocomma
1076 format.url output
1077 fin.entry
1078 }
1079
1080 FUNCTION {mastersthesis}
1081 { output.bibitem
1082 format.authors "author" output.check
1083 author format.key output % special for
1084 output.year.check % apalike
1085 "Master's thesis" format.thesis.type output.nonnull
1086 school "school" output.check
1087 address output
1088 format.eprint "eprint" output.check.nocomma
1089 format.doi "doi" output.check.nocomma
1090 format.url output
1091 fin.entry
1092 }
1093
1094 FUNCTION {misc}
1095 { output.bibitem
1096 format.authors output
1097 author format.key output % special for apalike
1098 output.year.check
1099 format.btitle output
1100 howpublished output
1101 format.eprint "eprint" output.check.nocomma
1102 format.doi "doi" output.check.nocomma
1103 format.url output
1104 fin.entry
1105 }
1106
1107 FUNCTION {phdthesis}
1108 { output.bibitem
1109 format.authors "author" output.check
1110 author format.key output % special for
1111 output.year.check % apalike
1112 "PhD thesis" format.thesis.type output.nonnull
1113 school "school" output.check
1114 address output
1115 format.eprint "eprint" output.check.nocomma
1116 format.doi "doi" output.check.nocomma
1117 format.url output
1118 fin.entry
1119 }
1120
1121 FUNCTION {proceedings}
1122 { output.bibitem
1123 format.editors output
1124 editor format.key output % special for
1125 mid.sentence 'output.state :=
1126 output.year.check % apalike
1127 format.btitle "title" output.check
1128 " " *
1129 before.all 'output.state :=
1130 % new.block
1131 format.bvolume output
1132 format.number.series output
1133 new.block
1134 % organization output % a nonempty organization
1135 publisher output
1136 address output
1137 format.eprint "eprint" output.check.nocomma
1138 format.doi "doi" output.check.nocomma
1139 format.url output
1140 fin.entry
1141 }
1142
1143 FUNCTION {techreport}
1144 { output.bibitem
1145 format.authors "author" output.check
1146 author format.key output % special for
1147 output.year.check % apalike
1148 format.tr.number output.nonnull
1149 format.btitle "title" output.check
1150 format.url output
1151 new.block
1152 institution "institution" output.check
1153 address output
1154 format.eprint "eprint" output.check.nocomma
1155 format.doi "doi" output.check.nocomma
1156 format.url output
1157 fin.entry
1158 }
1159
1160 FUNCTION {unpublished}
1161 { output.bibitem
1162 format.authors "author" output.check
1163 author format.key output % special for
1164 output.year.check % apalike
1165 format.btitle "title" output.check
1166 note "note" output.check
1167 % the following are presumably redundant for 'unpublished'
1168 format.eprint "eprint" output.check.nocomma
1169 format.doi "doi" output.check.nocomma
1170 format.url output
1171 fin.entry
1172 }
1173
1174 FUNCTION {default.type} { misc }
1175
1176 MACRO {jan} {"Jan."}
1177
1178 MACRO {feb} {"Feb."}
1179
1180 MACRO {mar} {"Mar."}
1181
1182 MACRO {apr} {"Apr."}
1183
1184 MACRO {may} {"May"}
1185
1186 MACRO {jun} {"June"}
1187
1188 MACRO {jul} {"July"}
1189
1190 MACRO {aug} {"Aug."}
1191
1192 MACRO {sep} {"Sept."}
1193
1194 MACRO {oct} {"Oct."}
1195
1196 MACRO {nov} {"Nov."}
1197
1198 MACRO {dec} {"Dec."}
1199
1200 %% Journal macros for bib files. Should be kept synchronized with
1201 %% the entries in the class file.
1202
1203 %% Astronomy and Astrophysics
1204 MACRO {aap} {"A\&A"}
1205
1206 %% Astronomy and Astrophysics
1207 MACRO {astap} {"A\&A"}
1208
1209 %% Astronomy and Astrophysics Review (the)
1210 MACRO {aapr} {"A\&ARv"}
1211
1212 %% Astronomy and Astrophysics Supplement Series
1213 MACRO {aaps} {"A\&AS"}
1214
1215 %% Acta Astronomica
1216 MACRO {actaa} {"Acta Astron."}
1217
1218 %% Astrofizika
1219 MACRO {afz} {"Afz"}
1220
1221 %% Astronomical Journal (the)
1222 MACRO {aj} {"AJ"}
1223
1224 %% Applied Optics
1225 MACRO {ao} {"Appl. Opt."}
1226
1227 %% Applied Optics
1228 MACRO {applopt} {"Appl. Opt."}
1229
1230 %% Astrophysics Letters
1231 MACRO {aplett} {"Astrophys.~Lett."}
1232
1233 %% Astrophysical Journal
1234 MACRO {apj} {"ApJ"}
1235
1236 %% Astrophysical Journal, Letters
1237 MACRO {apjl} {"ApJ"}
1238
1239 %% Astrophysical Journal, Letters
1240 MACRO {apjlett} {"ApJ"}
1241
1242 %% Astrophysical Journal, Supplement
1243 MACRO {apjs} {"ApJS"}
1244
1245 %% Astrophysical Journal, Supplement
1246 MACRO {apjsupp} {"ApJS"}
1247
1248 %% Astrophysics and Space Science
1249 MACRO {apss} {"Ap\&SS"}
1250
1251 %% Annual Review of Astronomy and Astrophysics
1252 MACRO {araa} {"ARA\&A"}
1253
1254 %% Astronomicheskii Zhurnal
1255 MACRO {azh} {"Azh"}
1256
1257 %% Bulletin of the American Astronomical Society
1258 MACRO {baas} {"BAAS"}
1259
1260 %% Bulletin of the Astronomical Institutes of Czechoslovakia
1261 MACRO {bac} {"Bull. Astron. Inst. Czechoslovakia"}
1262
1263 %% Bulletin Astronomical Institute of the Netherlands
1264 MACRO {bain} {"Bull. Astron. Inst. Netherlands"}
1265
1266 %% Chinese Astronomy and Astrophysics
1267 MACRO {caa} {"Chinese Astron. Astrophys."}
1268
1269 %% Chinese Journal of Astronomy and Astrophysics
1270 MACRO {cjaa} {"Chinese J.~Astron. Astrophys."}
1271
1272 %% Fundamentals of Cosmic Physics
1273 MACRO {fcp} {"Fundamentals Cosmic Phys."}
1274
1275 %% Geochimica Cosmochimica Acta
1276 MACRO {gca} {"Geochimica Cosmochimica Acta"}
1277
1278 %% Geophysics Research Letters
1279 MACRO {grl} {"Geophys. Res. Lett."}
1280
1281 %% IAU Cirulars
1282 MACRO {iaucirc} {"IAU~Circ."}
1283
1284 %% Icarus
1285 MACRO {icarus} {"Icarus"}
1286
1287 %% Journal of Astrophysics and Astronomy
1288 MACRO {japa} {"J.~Astrophys. Astron."}
1289
1290 %% Journal of Cosmology and Astroparticle Physics
1291 MACRO {jcap} {"J.~Cosmology Astropart. Phys."}
1292
1293 %% Journal of Chemical Physics
1294 MACRO {jcp} {"J.~Chem.~Phys."}
1295
1296 %% Journal of Geophysics Research
1297 MACRO {jgr} {"J.~Geophys.~Res."}
1298
1299 %% Journal of Quantitiative Spectroscopy and Radiative Transfer
1300 MACRO {jqsrt} {"J.~Quant. Spectrosc. Radiative Transfer"}
1301
1302 %% Journal of the RAS of Canada
1303 MACRO {jrasc} {"J.~R.~Astron. Soc. Canada"}
1304
1305 %% Memoirs of the RAS
1306 MACRO {memras} {"Mem.~RAS"}
1307
1308 %% Memoire della Societa Astronomica Italiana
1309 MACRO {memsai} {"Mem. Soc. Astron. Italiana"}
1310
1311 %% Monthly Notes of the Astronomical Society of Southern Africa
1312 MACRO {mnassa} {"MNASSA"}
1313
1314 %% Monthly Notices of the Royal Astronomical Society
1315 MACRO {mnras} {"MNRAS"}
1316
1317 %% New Astronomy
1318 MACRO {na} {"New~Astron."}
1319
1320 %% New Astronomy Review
1321 MACRO {nar} {"New~Astron.~Rev."}
1322
1323 %% Nature
1324 MACRO {nat} {"Nature"}
1325
1326 %% Nuclear Physics A
1327 MACRO {nphysa} {"Nuclear Phys.~A"}
1328
1329 %% Physical Review A: General Physics
1330 MACRO {pra} {"Phys. Rev.~A"}
1331
1332 %% Physical Review B: Solid State
1333 MACRO {prb} {"Phys. Rev.~B"}
1334
1335 %% Physical Review C
1336 MACRO {prc} {"Phys. Rev.~C"}
1337
1338 %% Physical Review D
1339 MACRO {prd} {"Phys. Rev.~D"}
1340
1341 %% Physical Review E
1342 MACRO {pre} {"Phys. Rev.~E"}
1343
1344 %% Physical Review Letters
1345 MACRO {prl} {"Phys. Rev.~Lett."}
1346
1347 %% Publications of the Astronomical Society of Australia
1348 MACRO {pasa} {"PASA"}
1349
1350 %% Publications of the Astronomical Society of the Pacific
1351 MACRO {pasp} {"PASP"}
1352
1353 %% Publications of the Astronomical Society of Japan
1354 MACRO {pasj} {"PASJ"}
1355
1356 %% Physics Reports
1357 MACRO {physrep} {"Phys.~Rep."}
1358
1359 %% Physica Scripta
1360 MACRO {physscr} {"Phys.~Scr."}
1361
1362 %% Planetary Space Science
1363 MACRO {planss} {"Planet. Space~Sci."}
1364
1365 %% Proceedings of the Society of Photo-Optical Instrumentation Engineers
1366 MACRO {procspie} {"Proc.~SPIE"}
1367
1368 %% Revista Mexicana de Astronomia y Astrofisica
1369 MACRO {rmxaa} {"Rev. Mex. Astron. Astrofis."}
1370
1371 %% Quarterly Journal of the RAS
1372 MACRO {qjras} {"QJRAS"}
1373
1374 %% Science
1375 MACRO {sci} {"Science"}
1376
1377 %% Sky and Telescope
1378 MACRO {skytel} {"Sky \& Telesc."}
1379
1380 %% Solar Physics
1381 MACRO {solphys} {"Sol.~Phys."}
1382
1383 %% Soviet Astronomy (aka Astronomy Reports)
1384 MACRO {sovast} {"Soviet~Ast."}
1385
1386 %% Space Science Reviews
1387 MACRO {ssr} {"Space Sci. Rev."}
1388
1389 %% Zeitschrift fuer Astrophysik
1390 MACRO {zap} {"Z.~Astrophys."}
1391
1392 %% Astronomical Society of the Pacific Conference Series
1393 MACRO {aspconf} {"ASP Conf. Ser."}
1394
1395 %% Astronomische Nachrichten
1396 MACRO {astnach} {"Astron. Nachr."}
1397
1398 %% Astronomy & Computing
1399 MACRO {astcomp} {"Astron. Comput."}
1400
1401 READ
1402
1403 FUNCTION {sortify}
1404 { purify$
1405 "l" change.case$
1406 }
1407
1408 INTEGERS { len }
1409
1410 FUNCTION {chop.word}
1411 { 's :=
1412 'len :=
1413 s #1 len substring$ =
1414 { s len #1 + global.max$ substring$ }
1415 's
1416 if$
1417 }
1418
1419 % There are three apalike cases: one person (Jones),
1420 % two (Jones and de~Bruijn), and more (Jones et~al.).
1421 % This function is much like format.crossref.editors.
1422 %
1423 % The goal here is to be compatible with the MN style prescription that:
1424 % If there are several references with the same first author,
1425 % arrange in the following order:
1426 % firstly single-author papers (by date);
1427 % then two-author papers (alphabetically by co-author, then by date);
1428 % then multi-author papers (by date).
1429 % We deem 'Jones and others' to be a multi-author paper, in this sense,
1430 % so that it sorts, by date, with the three-or-more author papers.
1431 % An alternative is to deem 'Jones and others' to sort just after the single-author papers
1432 % (this case isn't really covered by the above rules, but this position looks sensible);
1433 % we can get that by putting extra spaces before the 'et~al.', as noted below.
1434 % Note: we can't put arbitrary characters here, to force the order,
1435 % because the result of this function appears as the citation label in the typeset result.
1436 FUNCTION {format.lab.names}
1437 { 's :=
1438 s #1 "{vv~}{ll}" format.name$
1439 s num.names$ duplicate$
1440 #2 >
1441 { pop$ " et~al." * }
1442 { #2 <
1443 'skip$
1444 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
1445 { " et~al." * } % <-----+-- alternate sortings
1446 %{ " et~al." * } % <--+
1447 { " \& " * s #2 "{vv~}{ll}" format.name$ * }
1448 if$
1449 }
1450 if$
1451 }
1452 if$
1453 }
1454
1455 % Format names in full
1456 %
1457 FUNCTION {format.lab.names.full}
1458 { 's :=
1459 s #1 "{vv~}{ll}" format.name$
1460 s num.names$ duplicate$
1461 #2 <
1462 'skip$
1463 { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
1464 'skip$
1465 { " \& " * s #2 "{vv~}{ll}" format.name$ * }
1466 if$
1467 }
1468 if$
1469 }
1470
1471 FUNCTION {author.key.label}
1472 { author empty$
1473 { key empty$
1474 { cite$ #1 #3 substring$ }
1475 'key % apalike uses the whole key
1476 if$
1477 }
1478 { author format.lab.names }
1479 if$
1480 }
1481
1482
1483 FUNCTION {author.editor.key.label}
1484 { author empty$
1485 { editor empty$
1486 { key empty$
1487 { cite$ #1 #3 substring$ }
1488 'key % apalike uses the whole key
1489 if$
1490 }
1491 { editor format.lab.names }
1492 if$
1493 }
1494 { author format.lab.names }
1495 if$
1496 }
1497
1498 FUNCTION {author.editor.key.label.full}
1499 { author empty$
1500 { editor empty$
1501 { key empty$
1502 { cite$ #1 #3 substring$ }
1503 'key
1504 if$
1505 }
1506 { editor format.names.label }
1507 if$
1508 }
1509 { author format.names.label }
1510 if$
1511 }
1512
1513 FUNCTION {editor.key.label}
1514 { editor empty$
1515 { key empty$
1516 { cite$ #1 #3 substring$ }
1517 'key % apalike uses the whole key, no organization
1518 if$
1519 }
1520 { editor format.lab.names }
1521 if$
1522 }
1523
1524 % Calculate the 'label' for the entry, which is used for sorting.
1525 % Note that this does not include the a/b/c... for disambiguating
1526 % years (that's added later, in forward.pass).
1527 FUNCTION {calc.label}
1528 { % Define t: this is the 'full' set of names
1529 type$ "book" =
1530 type$ "inbook" =
1531 or
1532 'author.editor.key.label.full
1533 { type$ "proceedings" =
1534 { editor format.names.label }
1535 { author format.names.label }
1536 if$
1537 }
1538 if$
1539 't :=
1540 % Define s: this is the 'shortened' set of names, with 'et al.',
1541 % which are to appear in citations
1542 type$ "book" =
1543 type$ "inbook" =
1544 or
1545 'author.editor.key.label
1546 { type$ "proceedings" =
1547 'editor.key.label % apalike ignores organization
1548 'author.key.label % for labeling and sorting
1549 if$
1550 }
1551 if$
1552 's :=
1553 % the '\protect... is for apalike
1554 "\protect\citeauthoryear{" t * "}{" *
1555 threeauthorvar
1556 numnames #3 =
1557 and
1558 { "\protect\mniiiauthor{" cite$ * "}{" *
1559 t * "}{" * s * "}" * }
1560 { s }
1561 if$
1562 *
1563 "}{" *
1564 year field.or.null purify$ #-1 #4 substring$ % use all four digits
1565 *
1566 % the matching closing "}" comes in at the reverse.pass
1567 'label :=
1568 }
1569
1570 FUNCTION {sort.format.names}
1571 { 's :=
1572 #1 'nameptr :=
1573 ""
1574 s num.names$ 'numnames :=
1575 numnames 'namesleft :=
1576 { namesleft #0 > }
1577 { nameptr #1 >
1578 { " " * }
1579 'skip$
1580 if$ % apalike uses initials
1581 s nameptr "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" format.name$ 't := % <= here
1582 "Mc" t #2 text.prefix$ =
1583 { "mac" t #3 t text.length$ substring$ * 't := }
1584 'skip$
1585 if$
1586 nameptr numnames = t "others" = and
1587 { " et~al." * }
1588 { t sortify * }
1589 if$
1590 nameptr #1 + 'nameptr :=
1591 namesleft #1 - 'namesleft :=
1592 }
1593 while$
1594 }
1595
1596 FUNCTION {sort.format.title}
1597 { 't :=
1598 "A " #2
1599 "An " #3
1600 "The " #4 t chop.word
1601 chop.word
1602 chop.word
1603 sortify
1604 #1 global.max$ substring$
1605 }
1606
1607 FUNCTION {author.sort}
1608 { author empty$
1609 { key empty$
1610 { "to sort, need author or key in " cite$ * warning$
1611 ""
1612 }
1613 { key sortify }
1614 if$
1615 }
1616 { author sort.format.names }
1617 if$
1618 }
1619
1620 FUNCTION {author.editor.sort}
1621 { author empty$
1622 { editor empty$
1623 { key empty$
1624 { "to sort, need author, editor, or key in " cite$ * warning$
1625 ""
1626 }
1627 { key sortify }
1628 if$
1629 }
1630 { editor sort.format.names }
1631 if$
1632 }
1633 { author sort.format.names }
1634 if$
1635 }
1636
1637 FUNCTION {editor.sort}
1638 { editor empty$
1639 { key empty$
1640 { "to sort, need editor or key in " cite$ * warning$
1641 ""
1642 }
1643 { key sortify }
1644 if$
1645 }
1646 { editor sort.format.names }
1647 if$
1648 }
1649
1650 % Format numbers (eg volume, number, pages) into a fixed-width string,
1651 % for sorting.
1652 FUNCTION {number.for.presort}
1653 { field.or.null
1654 duplicate$ text.length$ 'len :=
1655 ""
1656 { #5 len > }
1657 { "0" *
1658 len #1 + 'len := }
1659 while$
1660 swap$ *
1661 }
1662
1663 % apalike uses two sorting passes; the first one sets the
1664 % labels so that the `a's, `b's, etc. can be computed;
1665 % the second pass puts the references in "correct" order.
1666 % The presort function is for the first pass. It computes
1667 % presort.key, sort.label, and sort.key$
1668 FUNCTION {presort}
1669 { calc.label
1670 type$ "book" =
1671 type$ "inbook" =
1672 or
1673 'author.editor.key.label
1674 { type$ "proceedings" =
1675 'editor.key.label % apalike ignores organization
1676 'author.key.label % for labeling and sorting
1677 if$
1678 }
1679 if$
1680 purify$ % remove {braces} round names, to avoid confusing sorting
1681 " "
1682 *
1683 year number.for.presort *
1684 #1 entry.max$ substring$
1685 'presort.key :=
1686 presort.key
1687 " "
1688 *
1689 % Style apalike prefers 'title field.or.null sort.format.title *' here.
1690 % We don't, because we will predominantly be sorting articles in
1691 % this style, and we don't include their titles in the final bibliography.
1692 volume number.for.presort *
1693 number number.for.presort *
1694 pages empty$
1695 { "0" }
1696 { pages first.page.number }
1697 if$
1698 number.for.presort *
1699 #1 entry.max$ substring$
1700 'sort.key$ :=
1701 sort.key$ 'sort.label :=
1702 }
1703
1704 EXECUTE {initialise.mn2e}
1705
1706 ITERATE {presort}
1707
1708 SORT % by label, sort.label, title---for final label calculation
1709
1710 % Manage the construction of the 'extra' labels for references. These
1711 % are the a/b/c/... year suffixes which distinguish different
1712 % publications by the same author.
1713 %
1714 % These apalike labels are only for the text; the 'label' does not
1715 % appear in the bibiliography, so that the 'longest.label' variable is
1716 % unnecessary in this style.
1717 STRINGS { last.key next.extra }
1718
1719 INTEGERS { last.extra.num }
1720
1721 FUNCTION {initialize.extra.label.stuff}
1722 { #0 int.to.chr$ 'last.key :=
1723 "" 'next.extra :=
1724 #0 'last.extra.num :=
1725 }
1726
1727 % By the time that this function is iterated over, the entries have
1728 % had presort.key assigned, and have been presorted. However these labels
1729 % do not (by design) respect the presence of multiple entries in the
1730 % same year, so that there are duplicates. Detect successive
1731 % duplicates, and add an extra a/b/c... suffix.
1732 %
1733 % At the end of this forward.pass, each entry with a duplicate presort.key
1734 % will have an extra.label, starting with 'b' for the first duplicate,
1735 % 'c' for the second, and so on. That is, only the first
1736 % soon-to-be-discovered-to-be-duplicate label will not have an
1737 % extra.label.
1738 FUNCTION {forward.pass}
1739 { last.key presort.key =
1740 { last.extra.num #1 + 'last.extra.num :=
1741 last.extra.num int.to.chr$ 'extra.label :=
1742 }
1743 { % first time we've seen this key
1744 "a" chr.to.int$ 'last.extra.num :=
1745 "" 'extra.label :=
1746 presort.key 'last.key :=
1747 }
1748 if$
1749 }
1750
1751 % Work back through the labels. If, on this pass we discover that the
1752 % next entry in the sequence (which is the last entry processed in
1753 % this reverse pass) had an extra.label of 'b', then this tells us
1754 % that _this_ entry should have an extra.label of 'a', which we were
1755 % unable to detect in the forward.pass above.
1756 %
1757 % We also close the brace pair {...} opened in calc.label
1758 FUNCTION {reverse.pass}
1759 { next.extra "b" =
1760 { "a" 'extra.label := }
1761 'skip$
1762 if$
1763 label extra.label * "}" * 'label :=
1764 extra.label 'next.extra :=
1765 }
1766
1767 EXECUTE {initialize.extra.label.stuff}
1768
1769 ITERATE {forward.pass}
1770
1771 REVERSE {reverse.pass}
1772
1773 % Now that the label is right we sort for real. We sort on sort.label
1774 % then year then title. Since sort.label starts with presort.key,
1775 % this sorting is compatible with the letter suffixes added to years.
1776 %
1777 % This is for the second sorting pass.
1778 FUNCTION {bib.sort.order}
1779 { sort.label
1780 " "
1781 *
1782 year field.or.null sortify
1783 *
1784 " "
1785 *
1786 title field.or.null
1787 sort.format.title
1788 *
1789 #1 entry.max$ substring$
1790 'sort.key$ :=
1791 }
1792
1793 ITERATE {bib.sort.order}
1794
1795 SORT % by sort.label, year, title---giving final bibliography order
1796
1797 FUNCTION {begin.bib}
1798 {
1799 preamble$ empty$ % no \etalchar in apalike
1800 'skip$
1801 { preamble$ write$ newline$ }
1802 if$
1803 "\begin{thebibliography}{}" write$ newline$ % no labels in apalike
1804 "\makeatletter" write$ newline$
1805 % The following is the contents of mnras-insert.sty, minus comments and whitespace.
1806 % DO NOT EDIT THIS TEXT,
1807 % but instead make mnras-insert.txt, and paste the results in here.
1808 "\relax" write$ newline$
1809 "\def\mn@urlcharsother{\let\do\@makeother \do\$\do\&\do\#\do\^\do\_\do\%\do\~}" write$ newline$
1810 "\def\mn@doi{\begingroup\mn@urlcharsother \@ifnextchar [ {\mn@doi@} {\mn@doi@[]}}" write$ newline$
1811 "\def\mn@doi@[#1]#2{\def\@tempa{#1}\ifx\@tempa\@empty \href {http://dx.doi.org/#2} {doi:#2}\else \href {http://dx.doi.org/#2} {#1}\fi \endgroup}" write$ newline$
1812 "\def\mn@eprint#1#2{\mn@eprint@#1:#2::\@nil}" write$ newline$
1813 "\def\mn@eprint@arXiv#1{\href {http://arxiv.org/abs/#1} {{\tt arXiv:#1}}}" write$ newline$
1814 "\def\mn@eprint@dblp#1{\href {http://dblp.uni-trier.de/rec/bibtex/#1.xml} {dblp:#1}}" write$ newline$
1815 "\def\mn@eprint@#1:#2:#3:#4\@nil{\def\@tempa {#1}\def\@tempb {#2}\def\@tempc {#3}\ifx \@tempc \@empty \let \@tempc \@tempb \let \@tempb \@tempa \fi \ifx \@tempb \@empty \def\@tempb {arXiv}\fi \@ifundefined {mn@eprint@\@tempb}{\@tempb:\@tempc}{\expandafter \expandafter \csname mn@eprint@\@tempb\endcsname \expandafter{\@tempc}}}" write$ newline$
1816 }
1817
1818 EXECUTE {begin.bib}
1819
1820 EXECUTE {init.state.consts}
1821
1822 ITERATE {call.type$}
1823
1824 FUNCTION {end.bib}
1825 { newline$
1826 "\makeatother" write$ newline$
1827 "\end{thebibliography}" write$ newline$
1828 }
1829
1830 EXECUTE {end.bib}