Debian Codegraph @

texmf-dist/bibtex/bst/quantumarticle/quantum.bst

raw
1 % This is the BibTeX style file for the Quantum journal.
2 % It is based on hyperabbrv.bst, and the extensions by Aram Harrow
3 % (see https://github.com/harrow/arxiv-bibstyle) and Andrew Comech
4 % (see https://www.math.tamu.edu/~comech/tools/bibtex-doi-eprint/).
5 %
6 % In addition to added arxiv and DOI hyperlinks, the file style incorporates design
7 % choices made for Quantum journal, in particular in the light of online availability.
8 % Furthermore, this file style introduces some custom reference classes as well as
9 % custom entry fields.
10
11 ENTRY
12 { address
13 archivePrefix
14 author
15 booktitle
16 chapter
17 code
18 commit
19 date
20 doi
21 edition
22 editor
23 eprint
24 howpublished
25 institution
26 journal
27 journaltitle
28 key
29 month
30 note
31 nolink
32 number
33 organization
34 pages
35 primaryClass
36 publisher
37 school
38 series
39 shortjournal
40 shorturl
41 title
42 type
43 url
44 urldate
45 version
46 volume
47 year
48 }
49 {}
50 {}
51
52 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
53 % Variables and state descriptors
54 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
55
56 INTEGERS
57 {
58 % These are state describing integers to control
59 % punctuation, capitalization, and line breaks
60 output.state
61 before.all
62 mid.sentence
63 after.sentence
64 after.block
65
66 multiresult
67 doi.linked
68
69 % Counters
70 length
71 namesleft
72 numnames
73 found.slashes
74 number.label
75 longest.label.width
76
77 % Config integers
78 % - whether to print out DOI links explicitly or add the link to parts of the
79 % citation itself.
80 explicit.doi.links
81 % - whether to raise compilation errors from (many) BibTeX warnings
82 warnings.are.errors
83 % - whether to append the word "Appearances" to entries, for hyperref's
84 % pagebackref option
85 pagebackref
86
87 % pointers
88 nameptr
89 ptr
90 }
91
92 STRINGS { s t m longest.label label }
93
94 FUNCTION {init.state.consts}
95 { % Initialize the global state describing integeres for punctuation
96 % Args:
97 % Returns:
98 #0 'before.all :=
99 #1 'mid.sentence :=
100 #2 'after.sentence :=
101 #3 'after.block :=
102 }
103
104 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
105 % Custom warning
106 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
107
108 FUNCTION {my.warning}
109 { % Print cited element in bibliography with error message in red.
110 % If warnings.are.errors (default:True), raise a \PackageError
111 % Args: str - Warning message
112 % Returns:
113 'm :=
114 "{\color{red}{ This bibitem caused a BibTeX warning: " m * " entry.}}" *
115 warnings.are.errors
116 { "\PackageError{quantum.bst}{The bibitem " *
117 cite$ *
118 " caused a BibTeX warning}" *
119 "{By default, quantum.bst handles BibTeX warnings like compilation " *
120 "errors. Please refer to the bibliography style demo for details and options.}" *
121 }
122 'skip$
123 if$
124 write$
125 m cite$ * warning$
126 }
127
128 FUNCTION {my.warning.newline}
129 { % Print cited element in bibliography with error message in red.
130 % If warnings.are.errors (default:True), raise a \PackageError
131 % This function includes a newline in the bibliography to ensure
132 % that the error message for missing links is formatted correctly.
133 % Args: str - Second line of warning message
134 % str - First line of warning message
135 % Returns:
136 's :=
137 'm :=
138 "{\color{red}{ This bibitem caused a BibTeX warning: " m * "}}" *
139 write$
140 newline$
141 "{\color{red}{" s * " entry.}}" *
142 warnings.are.errors
143 { "\PackageError{quantum.bst}{The bibitem " *
144 cite$ *
145 " caused a BibTeX warning}" *
146 "{By default, quantum.bst handles BibTeX warnings like compilation " *
147 "errors. Please refer to the bibliography style demo for details.}" *
148 }
149 'skip$
150 if$
151 write$
152 m cite$ * warning$
153 }
154
155 FUNCTION {my.crossref.warning}
156 { % Print cited crossref element in bibliography with error message in red.
157 % If warnings.are.errors (default:True), raise a \PackageError
158 % Args: str - Warning message
159 % Returns:
160 'm :=
161 warnings.are.errors
162 { "{\color{red} This bibitem caused a crossref-BibTeX warning: need "
163 m * " to crossref.}\PackageError{quantum.bst}{The crossref bibitem " *
164 cite$ *
165 " caused a BibTeX warning}" *
166 "{By default, quantum.bst handles BibTeX warnings like compilation " *
167 "errors. Please refer to the bibliography style demo for details.}" *
168 write$
169 }
170 'skip$
171 if$
172 "need " m * " for " * cite$ * " to crossref " * crossref * warning$
173 }
174
175 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
176 % Boolean functions
177 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
178
179 FUNCTION {not}
180 { % Logical NOT of a "Boolean"
181 % Args: int - Boolean to negate
182 % Returns: int - negated Boolean
183 { #0 }
184 { #1 }
185 if$
186 }
187
188 FUNCTION {and}
189 { % Logical AND between two "Booleans"
190 % Args: int - First Boolean to combine
191 % int - Second Boolean to combine
192 % Returns: int - logical AND of input Booleans
193 'skip$
194 { pop$ #0 }
195 if$
196 }
197
198 FUNCTION {or}
199 { % Logical OR between two "Booleans"
200 % Args: int - First Boolean to combine
201 % int - Second Boolean to combine
202 % Returns: int - logical OR of input Booleans
203 { pop$ #1 }
204 'skip$
205 if$
206 }
207
208 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
209 % String manipulation
210 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
211
212 FUNCTION {string.length}
213 { % Count the length of a string
214 % Args: str - String to count
215 % Returns: int - Length of input string
216 #1 'length :=
217 % Increase the length by 1 until the substring of the current length is the full string
218 {duplicate$ duplicate$ #1 length substring$ = not}
219 {length #1 + 'length :=}
220 while$
221 % Pop the string and return the length
222 pop$ length
223 }
224
225 FUNCTION {contains.substring}
226 { % Check whether a substring is contained in a string
227 % Args: str - Substring to find in larger string
228 % str - String to find the substring in
229 % Returns: int("Boolean") - whether the substring is contained in the string
230 's :=
231 't :=
232 % Count the length of the substring
233 s string.length 'length :=
234 % cut away starting characters of the string until it is empty or the substring is found
235 { t empty$ not }
236 % Check whether the current string starts with the substring
237 { t #1 length substring$ s =
238 { % If yes, empty the string and return #1
239 "" 't :=
240 #1
241 }
242 { % If not, delete the first character of the string
243 t #2 global.max$ substring$ 't :=
244 % If the string is empty, return #0
245 t empty$
246 { #0 }
247 'skip$
248 if$
249 }
250 if$
251 }
252 while$
253 }
254
255 FUNCTION {chop.word}
256 { % Chop the beginning of a string if it matches a given second string
257 % Args: str - String to chop
258 % int - Length of substring to match
259 % str - Substring to match
260 % Returns: str - (Potentially) chopped string
261 's :=
262 'length :=
263 s #1 length substring$ =
264 { s length #1 + global.max$ substring$ }
265 's
266 if$
267 }
268
269 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
270 % Elementary output functions
271 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
272
273 FUNCTION {output.nonnull}
274 { % Output a string that is guaranteed not to be empty
275 % Args: str - String to process
276 % Returns:
277 % The written output via write$ depends on the position in a sentence or block,
278 % as stored in outpute.state, which is updated accordingly.
279 's :=
280 output.state mid.sentence =
281 'write$
282 { output.state after.block =
283 { add.period$ write$
284 newline$
285 "\newblock " write$
286 }
287 { output.state before.all =
288 'write$
289 { add.period$ " " * write$ }
290 if$
291 }
292 if$
293 mid.sentence 'output.state :=
294 }
295 if$
296 s
297 }
298
299 FUNCTION {output}
300 { % Output a string if it is not empty
301 % Args: str - String to check and output
302 % Returns:
303 duplicate$ empty$
304 'pop$
305 'output.nonnull
306 if$
307 }
308
309 FUNCTION {output.check}
310 { % Check whether a string is empty, output it if it is not, and raise a my.warning if it is.
311 % Args: str - Describing string of argument that is checked to provide a useful error message
312 % str - String to check and output if it is not empty
313 % Returns:
314 't :=
315 duplicate$ empty$
316 { pop$ "empty " t * " in " * my.warning }
317 'output.nonnull
318 if$
319 }
320
321 FUNCTION {no.output.check}
322 { % Check whether a string is empty and raise a my.warning if it is.
323 % Args: str - Describing string of argument that is checked to provide a useful error message
324 % str - String to check
325 % Returns:
326 't :=
327 duplicate$ empty$
328 { pop$ "empty " t * " in " * my.warning }
329 'skip$
330 if$
331 }
332
333 FUNCTION {no.output.check.links}
334 { % Check whether a string is empty and raise a my.warning.newline if it is.
335 % Args: str - Describing string of argument that is checked to provide a useful error message
336 % str - String to check
337 % Returns:
338 % The separate handling from no.output.check is the special warning message that contains
339 % special characters, requiring us to use my.warning.newline. In addition, if the field
340 % `nolink` is not missing (it may be empty though), the warning is not raised.
341 't :=
342 duplicate$ empty$ nolink missing$ and
343 { pop$ "empty " t * ". " *
344 "If none of these fields is applicable for the cited work you can include the field " *
345 "\verb|`nolink = {}`| in its bib"
346 my.warning.newline
347 }
348 'skip$
349 if$
350 }
351
352 FUNCTION {output.bibitem}
353 { % Write the current buffer and the header for a new bibitem to the bbl file and
354 % updates the output.state
355 % Args: str - Current buffer is written to the bbl file
356 % Returns: str - An empty string
357 newline$
358 % Write the header for a new bibitem
359 "\bibitem{" write$
360 cite$ write$
361 "}" write$
362 newline$
363 ""
364 before.all 'output.state :=
365 }
366
367 FUNCTION {fin.entry}
368 { % Finalize an entry by appending a period if appropriate and writing to the bbl file
369 % Args: str - Current string to write to the bbl file
370 % Returns:
371 add.period$
372 pagebackref
373 { " Appearances:~" * }
374 'skip$
375 if$
376 write$
377 newline$
378 }
379
380 FUNCTION {new.block}
381 { % Start a new block in an entry, setting the output.state accordingly
382 % Args:
383 % Returns:
384 output.state before.all =
385 'skip$
386 { after.block 'output.state := }
387 if$
388 }
389
390 FUNCTION {new.sentence}
391 { % Start a new sentence in an entry, setting the output.state accordingly
392 % Args:
393 % Returns:
394 output.state after.block =
395 output.state before.all =
396 or
397 'skip$
398 { after.sentence 'output.state := }
399 if$
400 }
401
402 FUNCTION {new.block.checka}
403 { % Start a new block in an entry if the input string is not empty
404 % Args: str - String to decide whether a new block is started
405 % Returns:
406 empty$
407 'skip$
408 'new.block
409 if$
410 }
411
412 FUNCTION {new.block.checkb}
413 { % Start a new block in an entry if any of two input strings are not empty
414 % Args: str - Second string to decide whether a new block is started
415 % str - First string to decide whether a new block is started
416 % Returns:
417 empty$
418 swap$ empty$
419 and
420 'skip$
421 'new.block
422 if$
423 }
424
425 FUNCTION {new.sentence.checka}
426 { % Start a new sentence in an entry if the input string is not empty
427 % Args: str - String to decide whether a new sentence is started
428 % Returns:
429 empty$
430 'skip$
431 'new.sentence
432 if$
433 }
434
435 FUNCTION {new.sentence.checkb}
436 { % Start a new sentence in an entry if any of two input strings are not empty
437 % Args: str - Second string to decide whether a new sentence is started
438 % str - First string to decide whether a new sentence is started
439 % Returns:
440 empty$
441 swap$ empty$
442 and
443 'skip$
444 'new.sentence
445 if$
446 }
447
448 FUNCTION {field.or.null}
449 { % Replace an empty field or string by the empty string ""
450 % Args: str - Field or string to check and replace
451 % Returns: str - The input string if it was not empty, else ""
452 % This function does nothing on strings, it just replaces empty (but defined)
453 % fields by the empty string in order to allow for string comparisons and other operations
454 % that are not defined on empty (non-string) fields.
455 duplicate$ empty$
456 { pop$ "" }
457 'skip$
458 if$
459 }
460
461 FUNCTION {tie.or.space.connect}
462 { % Connect two strings with a space or a non-breaking ~
463 % Args: str - Second string to connect. If it is shorter than 3 characters, a ~ is used
464 % str - First string to connect.
465 % Returns: str - The connected strings.
466 duplicate$ text.length$ #3 <
467 { % Use a ~ if the second string is shorter than 3 characters
468 "~"
469 }
470 { % Use a space else
471 " "
472 }
473 if$
474 % Bring the strings in the order (first string, connector, second string) and merge them
475 swap$ * *
476 }
477
478 FUNCTION {init.longest.label}
479 { % Initializes globally used variables to determine the longest label in the bibliography
480 % Args:
481 % Returns:
482 "" 'longest.label :=
483 #1 'number.label :=
484 #0 'longest.label.width :=
485 }
486
487 FUNCTION {longest.label.pass}
488 { % Update the longest.label.width and the longest.label, as measured by width$
489 % Args:
490 % Returns:
491 % Note that this function does not require any input from the bilbiography items,
492 % but only depends on the number of items.
493 number.label int.to.str$ 'label :=
494 number.label #1 + 'number.label :=
495 label width$ longest.label.width >
496 { label 'longest.label :=
497 label width$ 'longest.label.width :=
498 }
499 'skip$
500 if$
501 }
502
503
504 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
505 % Entry formatting
506 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
507
508 FUNCTION {boldfont}
509 { % Add a bold font formatting string to a string (if it is not empty)
510 % Args: str - The string to format in bold font
511 % Returns: str - The input string wrapped in a formatting string for bold font
512 % Only add the formatting string to a non-empty string
513 duplicate$ empty$
514 { pop$ "" }
515 { "{\bf " swap$ * "}" * }
516 if$
517 }
518
519 FUNCTION {format.names}
520 { % Format a given string with names
521 % Args: str - The string with names
522 % Returns: str - The formatted names
523 's :=
524 % initialize pointer, counter for names and counter for names to handle left
525 #1 'nameptr :=
526 s num.names$ 'numnames :=
527 numnames 'namesleft :=
528 % Iterate over names
529 { namesleft #0 > }
530 { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
531 nameptr #1 >
532 { % After the first name, include connecting characters
533 namesleft #1 >
534 { % If there is more than the current name left, use a comma
535 ", " * t *
536 }
537 { % If there is only the current name left, use "and" or "et al."
538 numnames #2 >
539 { % Add a comma before "and" if there were more than two names
540 "," *
541 }
542 'skip$
543 if$
544 t "others" =
545 { % Replace "and others" by "et~al."
546 " et~al." *
547 }
548 { " and " * t * }
549 if$
550 }
551 if$
552 }
553 { % Simply write the first name to buffer
554 t
555 }
556 if$
557 nameptr #1 + 'nameptr :=
558 namesleft #1 - 'namesleft :=
559 }
560 while$
561 }
562
563 FUNCTION {format.authors}
564 { % Apply format.names to the author field and return it
565 % Args:
566 % Returns: str - author field formatted via format.names
567 % If the author field is empty, the empty string is returned instead.
568 author empty$
569 { "" }
570 { author format.names }
571 if$
572 }
573
574 FUNCTION {format.editors}
575 { % Apply format.names to the editor field, add a remark "editor(s)" to it, and return it
576 % Args:
577 % Returns: str - editor field formatted via format.names, with ", editor(s)" appended.
578 % If the editor field is empty, the empty string is returned instead.
579 editor empty$
580 { "" }
581 {
582 editor format.names
583 ", editor" *
584 % Add plural "s" if multiple editors are given
585 editor num.names$ #1 >
586 { "s" * }
587 'skip$
588 if$
589 }
590 if$
591 }
592
593 FUNCTION {format.title}
594 { % Wrap the title in quotation marks and change its capitalization.
595 % Args:
596 % Returns: str - title field wrapped in quotation marks with new capitalization
597 % Note that change.case$ together with the option "t" removes all capitalization
598 % of text that is not in curly braces, except for the very first character.
599 title empty$
600 { "" }
601 { "``" title "t" change.case$ * "''" * }
602 if$
603 }
604
605 FUNCTION { format.arxiv.hyperlink }
606 { % Extract the arXiv handle from a string, removing a leading "arXiv"
607 % Args: str - The string to extract the handle from
608 % Returns: str - The extracted arXiv handle
609 % If the string starts with "arxiv:" or "arxiv" (or any capitalized version of these),
610 % the length-10 handle is extracted, otherwise the original string is returned.
611 duplicate$ #1 #6 substring$ "l" change.case$ "arxiv:" =
612 { #7 #10 substring$ }
613 { duplicate$ #1 #5 substring$ "l" change.case$ "arxiv" =
614 { #6 #10 substring$ }
615 'skip$
616 if$
617 }
618 if$
619 }
620
621 FUNCTION {format.eprint}
622 { % Format the eprint link, including the hyperlink and the link text.
623 % Args:
624 % Returns: str - Hyperlink to extracted arxiv reference
625 eprint empty$
626 { "" }
627 { archivePrefix empty$
628 { primaryClass empty$
629 { "arXiv" }
630 { primaryClass }
631 if$
632 }
633 { archivePrefix }
634 if$
635 " \href{http://arxiv.org/abs/"
636 eprint format.arxiv.hyperlink *
637 "}{" *
638 swap$ *
639 ":" *
640 eprint #1 #5 substring$ "arXiv" =
641 { eprint #7 #15 substring$ * }
642 { eprint * }
643 if$
644 "}" *
645 }
646 if$
647 }
648
649 FUNCTION {add.doi.link}
650 { % Add a hyperlink referring to a DOI reference to a string, using the doi field.
651 % Args: str - String to add the hyperlink to
652 % Returns: str - Input string with hyperlink added
653 "\href{https://dx.doi.org/" doi * "}{" * swap$ * "}" *
654 }
655
656 FUNCTION {n.dashify}
657 { % Replace single dashes by double dashes
658 % Args: str - Input string to be modified
659 % Returns: str - Input string with single dashes replaced by double dashes
660 't :=
661 ""
662 % Iterate over the characters in the string
663 { t empty$ not }
664 { t #1 #1 substring$ "-" =
665 {
666 t #1 #2 substring$ "--" = not
667 { % If the current `t` starts with a "-" but not with "--", replace
668 % the single dash with "--" and cut the leading dash from `t`
669 "--" *
670 t #2 global.max$ substring$ 't :=
671 }
672 { % If the current `t` starts with a "--", add all dashes in the
673 % current `t` to the output string without any replacement
674 { t #1 #1 substring$ "-" = }
675 { "-" *
676 t #2 global.max$ substring$ 't :=
677 }
678 while$
679 }
680 if$
681 }
682 { % If the current `t` does not start with a dash, simply move the first
683 % character to the output string.
684 t #1 #1 substring$ *
685 t #2 global.max$ substring$ 't :=
686 }
687 if$
688 }
689 while$
690 }
691
692 FUNCTION {format.year}
693 { % Format the year of an entry
694 % Args:
695 % Returns: str - Formatted year in brackets
696 % If the year field is empty, the year is extracted from the date field, assuming
697 % that it starts with the year.
698 year empty$
699 { date empty$
700 { "" }
701 { "~(" date #1 #4 substring$ * ")" * }
702 if$
703 }
704 { "~(" year * ")" * }
705 if$
706 }
707
708 FUNCTION {format.urldate}
709 { % Format the date on which a URL was accessed
710 % Args:
711 % Returns: str - The formatted date in brackets with a remark "accessed:"
712 % The urldate field preceeds the date field.
713 urldate empty$
714 { date empty$
715 { "" }
716 { "(accessed:~" date * ")" * }
717 if$
718 }
719 { "(accessed:~" urldate * ")" * }
720 if$
721 }
722
723 FUNCTION {format.chapter}
724 { % Format the chapter field for an entry
725 % Args: int - "Boolean" indicating whether the "Chapter" should be turned to lower case
726 % Returns: str - The formatted chapter with leading "Chapter" string.
727 % If the field `type` is not empty, it is used instead of the generic "Chapter".
728 type empty$
729 { "Chapter" }
730 { type }
731 if$
732 swap$
733 { "l" change.case$ }
734 'skip$
735 if$
736 chapter tie.or.space.connect
737 }
738
739 FUNCTION {multi.page.check}
740 { % Check whether a string indicates multiple pages
741 % Args: str - The string describing a page or multiple pages
742 % Returns: int - "Boolean" indicating whether the string describes multiple pages
743 't :=
744 #0 'multiresult :=
745 { multiresult not
746 t empty$ not
747 and
748 }
749 { % Check whether the first character in the current `t` is one of "-", "," or "+"
750 t #1 #1 substring$
751 duplicate$ "-" =
752 swap$ duplicate$ "," =
753 swap$ "+" =
754 or or
755 { #1 'multiresult := }
756 { % Remove the first character from the current `t`
757 t #2 global.max$ substring$ 't :=
758 }
759 if$
760 }
761 while$
762 multiresult
763 }
764
765 FUNCTION {format.pages}
766 { % Format the pages field of an entry
767 % Args: int - "Boolean" indicating whether to capitalize the word "page(s)"
768 % Returns: str - The formatted pages field, including the word "page(s)"
769 { "p" }
770 { "P" }
771 if$
772 pages multi.page.check
773 { "ages" * pages n.dashify tie.or.space.connect }
774 { "age" * pages tie.or.space.connect }
775 if$
776 }
777
778 FUNCTION {format.bvol.series}
779 { % Format the book volume and the series of an entry
780 % Args:
781 % Returns: str - The volume and series field formatted into one string.
782 % Raises a warning if the field `number` is present in addition to `volume`.
783 volume empty$
784 { "" }
785 { mid.sentence output.state =
786 { "v" }
787 { "V" }
788 if$
789 "olume" * volume tie.or.space.connect
790 series empty$
791 'skip$
792 { " of " * series * }
793 if$
794 number empty$
795 'skip$
796 { "can't use both volume and number fields in " * my.warning }
797 if$
798 }
799 if$
800 }
801
802 FUNCTION {format.bvol.chap.pages}
803 { % Format the book volume, series and the chapter and pages of an entry
804 % Args:
805 % Returns: str - The volume and series field formatted into one string.
806 % This function wraps the previously defined functions format.bvol.series,
807 % format.chapter, and format.pages into one.
808 format.bvol.series
809 chapter empty$
810 'skip$
811 { duplicate$ empty$
812 { #0 }
813 { ", " *
814 #1
815 }
816 if$
817 format.chapter *
818 }
819 if$
820 pages empty$
821 'skip$
822 { duplicate$ empty$
823 { #0 }
824 { ", " *
825 #1
826 }
827 if$
828 format.pages *
829 }
830 if$
831 }
832
833 FUNCTION {format.number.series}
834 { % Format the number and the series of an entry
835 % Args:
836 % Returns: str - The number and series field formatted into one string.
837 % The returned string is empty if the `volume` field is not empty.
838 % Raises a warning if the field `series` is empty.
839 volume empty$
840 { number empty$
841 { series field.or.null }
842 { output.state mid.sentence =
843 { "number" }
844 { "Number" }
845 if$
846 number tie.or.space.connect
847 series empty$
848 { "there's a number but no series in " my.warning }
849 { " in " * series * }
850 if$
851 }
852 if$
853 }
854 { "" }
855 if$
856 }
857
858 FUNCTION {format.edition}
859 { % Format the edition field of an entry
860 % Args:
861 % Returns: str - The edition of the entry with "edition" comment, if it
862 % is not contained in the field itself already.
863 edition empty$
864 { "" }
865 { output.state mid.sentence =
866 { edition "l" change.case$ }
867 { edition "t" change.case$ }
868 if$
869 edition "edition" contains.substring
870 'skip$
871 { " edition" * }
872 if$
873 }
874 if$
875 }
876
877 FUNCTION {format.vol.pages}
878 { % Format the volume and pages for an article entry
879 % Args:
880 % Returns: The volume and page numbers as a single string
881 volume field.or.null boldfont
882 pages empty$
883 'skip$
884 { duplicate$ empty$
885 { pop$ mid.sentence output.state = format.pages }
886 { " " swap$ * ", " * pages n.dashify * }
887 if$
888 }
889 if$
890 }
891
892 FUNCTION {format.chapter.pages}
893 { % Format the chapter and pages for an entry
894 % Args:
895 % Returns: str - chapter and pages description in one string
896 chapter empty$
897 { #0 format.pages }
898 {
899 mid.sentence output.state =
900 format.chapter
901 pages empty$
902 'skip$
903 { ", " * #1 format.pages * }
904 if$
905 }
906 if$
907 }
908
909 FUNCTION {format.in.ed.booktitle}
910 { % Format the booktitle together with editors of an entry
911 % Args:
912 % Returns: The booktitle for an entry contained in the book.
913 booktitle empty$
914 { "" }
915 { editor empty$
916 { "In " booktitle * }
917 { "In " format.editors * ", " * booktitle * }
918 if$
919 }
920 if$
921 }
922
923 FUNCTION {empty.misc.check}
924 { % Checks whether all relevant fields for a misc entry are empty
925 % Args:
926 % Returns:
927 % Raises a warning if all fields are empty
928 author empty$ title empty$ howpublished empty$
929 month empty$ year empty$ note empty$
930 and and and and and
931 % Only warn for entries that actually have a key
932 key empty$ not and
933 { "all relevant fields are empty in " my.warning }
934 'skip$
935 if$
936 }
937
938 FUNCTION {format.thesis.type}
939 { % Replace a string with the type field if given, and add a DOI link
940 % Args: str - String to add the DOI link to, or to replace by the `type` field.
941 % Returns: str - Input string or `type` string if present, with DOI link.
942 type empty$
943 'skip$
944 { pop$
945 type "t" change.case$
946 }
947 if$
948 doi missing$
949 explicit.doi.links
950 or
951 'skip$
952 { add.doi.link }
953 if$
954 }
955
956 FUNCTION {format.tr.number}
957 { % Format the number of a technical report and add the remark "Technical Report"
958 % or the `type` field if present.
959 % Args:
960 % Returns: str - `type` field or "Technical Report" together with the `number` field
961 type empty$
962 { "Technical Report" }
963 'type
964 if$
965 number empty$
966 { "t" change.case$ }
967 { number tie.or.space.connect }
968 if$
969 }
970
971 FUNCTION {get.journal}
972 { % Obtain the journal from either journal, journaltitle or shortjournal,
973 % in that order of priority
974 % Args:
975 % Returns: str - The name of the journal.
976 journal missing$
977 {
978 journaltitle missing$
979 {
980 shortjournal missing$
981 { "" }
982 { shortjournal }
983 if$
984 }
985 { journaltitle }
986 if$
987 }
988 { journal }
989 if$
990 }
991
992 FUNCTION {format.article.crossref}
993 { % Fomat a cross-reference of an article
994 % Args:
995 % Returns: str - Crossref entry for an article incl. citation
996 key empty$
997 { get.journal empty$
998 { "key or journal" my.crossref.warning
999 ""
1000 }
1001 { "In {\em " get.journal * "\/}" * }
1002 if$
1003 }
1004 { "In " key * }
1005 if$
1006 " \cite{" * crossref * "}" *
1007 }
1008
1009 FUNCTION {format.crossref.editor}
1010 { % Fomat the editors for a cross-reference to a book, collection or proceedings
1011 % Args:
1012 % Returns: str - Editors names formatted for a cross-reference.
1013 editor #1 "{vv~}{ll}" format.name$
1014 editor num.names$ duplicate$
1015 #2 >
1016 { pop$ " et~al." * }
1017 { #2 <
1018 'skip$
1019 { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
1020 { " et~al." * }
1021 { " and " * editor #2 "{vv~}{ll}" format.name$ * }
1022 if$
1023 }
1024 if$
1025 }
1026 if$
1027 }
1028
1029 FUNCTION {format.book.crossref}
1030 { % Fomat a cross-reference to a book
1031 % Args:
1032 % Returns: str - Crossref entry to a book incl. citation
1033 volume empty$
1034 { "volume" my.crossref.warning
1035 "In "
1036 }
1037 { "Volume" volume tie.or.space.connect
1038 " of " *
1039 }
1040 if$
1041 editor empty$
1042 editor field.or.null author field.or.null =
1043 or
1044 { key empty$
1045 { series empty$
1046 { "editor, key, or series" my.crossref.warning
1047 "" *
1048 }
1049 { "{\em " * series * "\/}" * }
1050 if$
1051 }
1052 { key * }
1053 if$
1054 }
1055 { format.crossref.editor * }
1056 if$
1057 " \cite{" * crossref * "}" *
1058 }
1059
1060 FUNCTION {format.incoll.inproc.crossref}
1061 { % Fomat a cross-reference for an entry from a collection or proceedings
1062 % Args:
1063 % Returns: str - Crossref entry to the collection/proceedings incl. citation.
1064 editor empty$
1065 editor field.or.null author field.or.null =
1066 or
1067 { key empty$
1068 { booktitle empty$
1069 { "editor, key, or booktitle" my.crossref.warning
1070 ""
1071 }
1072 { "In {\em " booktitle * "\/}" * }
1073 if$
1074 }
1075 { "In " key * }
1076 if$
1077 }
1078 { "In " format.crossref.editor * }
1079 if$
1080 " \cite{" * crossref * "}" *
1081 }
1082
1083 FUNCTION {extract.repo}
1084 { % Obtain the repository name from the `code` field
1085 % Args:
1086 % Returns: str - The repository name to print
1087 % Look for registered formatting of github repos and remove them
1088 "github.com/" #11
1089 "www.github.com/" #15
1090 "https://github.com/" #19
1091 code
1092 chop.word
1093 chop.word
1094 chop.word
1095 % Extract the part of the repository name until the second slash
1096 't :=
1097 #0 'found.slashes :=
1098 #1 'ptr :=
1099 { ptr t text.length$ < #2 found.slashes > and}
1100 {t ptr #1 substring$ "/" =
1101 { found.slashes #1 + 'found.slashes := }
1102 'skip$
1103 if$
1104 ptr #1 + 'ptr := }
1105 while$
1106 % Return only the part up to the second slash from above
1107 #2 found.slashes =
1108 { t #1 ptr #2 - substring$ }
1109 { t #1 ptr substring$ }
1110 if$
1111 }
1112
1113 FUNCTION {format.version}
1114 { % Format the `version` field of an entry with `code` field
1115 % Args:
1116 % Returns: str - The version with a "v" abbreviation
1117 version empty$
1118 { "" }
1119 {
1120 "v" version #1 #1 substring$ =
1121 { " " version * }
1122 { " v" version * }
1123 if$
1124 }
1125 if$
1126 }
1127
1128 FUNCTION {format.commit}
1129 { % Format the `commit` field of an entry with `code` field
1130 % Args:
1131 % Returns: str - The commit field with the remark "commit"
1132 commit empty$
1133 { "" }
1134 { " commit:" commit #1 #7 substring$ * }
1135 if$
1136 }
1137
1138 FUNCTION {format.code}
1139 { % Format the `code` field
1140 % Args:
1141 % Returns: str - The `code` field with version and commit,
1142 % including a link to the repository
1143 code empty$
1144 { "" }
1145 { code "l" change.case$ "github" contains.substring
1146 { " code:~\href{" code * "}{" * extract.repo * format.version * format.commit * "}" * }
1147 { " code:~\href{" code * "}{" * code * "}" * }
1148 if$
1149 }
1150 if$
1151 }
1152
1153 FUNCTION {format.url}
1154 { % Format a url
1155 % Args:
1156 % Returns: str - The `shorturl` (preferred) or `url` field including a link
1157 % The "https" part is removed from the printed string of the hyperlink
1158 shorturl empty$
1159 { url empty$
1160 { "" }
1161 { " url:~\url{" url * "}" * }
1162 if$
1163 }
1164 { " url:~\href{" url * "}{" * "https://" #8 shorturl chop.word * "}" * }
1165 if$
1166 }
1167
1168 FUNCTION {check.links}
1169 { % Check that one of the fields providing a hyperlink is present and raise a warning if not
1170 % Args:
1171 % Returns:
1172 % The fields of which one should be present are `doi`, `eprint` and
1173 % `url`. Setting the (empty) field `nolink={}` suppresses this warning.
1174 doi missing$ eprint missing$ and
1175 { format.url "doi, eprint and url" no.output.check.links pop$ }
1176 'skip$
1177 if$
1178 }
1179
1180 FUNCTION {output.links}
1181 { % Output the links of an entry
1182 % Args:
1183 % Returns:
1184 new.block
1185 explicit.doi.links
1186 { % If explicit DOI links are set via the config, output it
1187 % explicitly (if it's not missing)
1188 doi missing$
1189 'skip$
1190 { " doi:~" doi add.doi.link * output
1191 new.block
1192 }
1193 if$
1194 }
1195 'skip$ % Without explicit DOI links, it has already been added to another string.
1196 if$
1197 % Add eprint link
1198 format.eprint output
1199 doi missing$ eprint missing$ and
1200 { % If the DOI and the eprint link are missing, add the `url` field hyperlink
1201 new.block
1202 format.url output
1203 }
1204 'skip$
1205 if$
1206 new.block
1207 % Add the code hyperlink
1208 format.code output
1209 }
1210
1211 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1212 % Interpretation of bib entries
1213 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1214
1215 FUNCTION {is.arxiv.article}
1216 { % Determine whether an article class is an arxiv article only.
1217 % Args:
1218 % Returns: int - "Boolean" indicating whether the entry is an arxiv article only
1219 % The article is considered an arxiv article only if
1220 % - get.journal delivers an empty string and the `archivePrefix` field matches "arxiv"
1221 % (up to capitalization)
1222 % - "arxiv" (or a capitalized version of it) is present in the output of get.journal
1223 % If the output of get.journal is empty and the `archivePrefix` field is present but not
1224 % known, a warning is raised.
1225 get.journal empty$
1226 { archivePrefix missing$
1227 { #0 }
1228 { archivePrefix "l" change.case$ "arxiv" =
1229 { #1 }
1230 { "The `archivePrefix' " archivePrefix * " is not supported for entry" * my.warning
1231 #0
1232 }
1233 if$
1234 }
1235 if$
1236 }
1237 { get.journal "l" change.case$ "arxiv" contains.substring
1238 { #1 }
1239 { #0 }
1240 if$
1241 }
1242 if$
1243 }
1244
1245 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1246 % Raw citation classes that are aliased in the public citation classes
1247 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1248
1249 FUNCTION {arxiv.article}
1250 { % Format an arxiv-only article
1251 output.bibitem
1252 format.authors "author" output.check
1253 new.block
1254 format.title "title" output.check
1255 crossref missing$
1256 {
1257 format.year "year" output.check
1258 new.block
1259 check.links
1260 output.links
1261 }
1262 { format.article.crossref output.nonnull
1263 #1 format.pages output
1264 }
1265 if$
1266 fin.entry
1267 }
1268
1269 FUNCTION {std.article}
1270 { % Format a standard published article
1271 output.bibitem
1272 format.authors "author" output.check
1273 new.block
1274 format.title "title" output.check
1275 crossref missing$
1276 { new.block
1277 get.journal "journal, shortjournal and journaltitle" no.output.check
1278 format.vol.pages *
1279 doi missing$
1280 explicit.doi.links
1281 or
1282 'skip$
1283 { add.doi.link }
1284 if$
1285 output
1286 format.year "year" output.check
1287 new.block
1288 check.links
1289 output.links
1290 }
1291 { format.article.crossref output.nonnull
1292 #1 format.pages output
1293 }
1294 if$
1295 fin.entry
1296 }
1297
1298 FUNCTION {std.misc}
1299 { % Format a standard misc entry
1300 output.bibitem
1301 format.authors output
1302 title howpublished new.block.checkb
1303 format.title output
1304 howpublished new.block.checka
1305 howpublished output
1306 format.year output
1307 format.eprint output
1308 new.block
1309 note output
1310 fin.entry
1311 empty.misc.check
1312 }
1313
1314 FUNCTION {thesis.start}
1315 { % Format the first part of a thesis entry
1316 output.bibitem
1317 format.authors "author" output.check
1318 new.block
1319 format.title "title" output.check
1320 new.block
1321 }
1322
1323 FUNCTION {thesis.end}
1324 { % Format the second (and last) part of a thesis entry
1325 new.block
1326 school "school" output.check
1327 new.block
1328 address output
1329 format.year "year" output.check
1330 new.block
1331 output.links
1332 fin.entry
1333 }
1334
1335 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1336 % Recognized citation classes
1337 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1338
1339 FUNCTION {article}
1340 { is.arxiv.article
1341 'arxiv.article
1342 'std.article
1343 if$
1344 }
1345
1346 FUNCTION {conditional.doi.link}
1347 { duplicate$ empty$
1348 doi missing$
1349 explicit.doi.links
1350 doi.linked
1351 or or or
1352 'skip$
1353 { add.doi.link
1354 #1 'doi.linked :=
1355 }
1356 if$
1357 }
1358
1359 FUNCTION {book}
1360 { output.bibitem
1361 author empty$
1362 { format.editors "author and editor" output.check }
1363 { format.authors output.nonnull }
1364 if$
1365 new.block
1366 format.title "title" output.check
1367 new.block
1368 #0 'doi.linked :=
1369 crossref missing$
1370 { format.bvol.chap.pages
1371 conditional.doi.link output
1372 new.block
1373 format.number.series
1374 conditional.doi.link output
1375 new.sentence
1376 publisher "publisher" no.output.check
1377 conditional.doi.link output
1378 new.sentence
1379 address output
1380 }
1381 { format.chapter.pages output
1382 new.block
1383 format.book.crossref output.nonnull
1384 }
1385 if$
1386 format.year "year" output.check
1387 new.block
1388 format.edition output
1389 check.links
1390 output.links
1391 fin.entry
1392 }
1393
1394 FUNCTION {repository}
1395 { output.bibitem
1396 format.authors output
1397 format.year output
1398 new.block
1399 code empty$
1400 { format.url "url" output.check }
1401 { format.code output }
1402 if$
1403 fin.entry
1404 }
1405
1406 FUNCTION {website}
1407 { output.bibitem
1408 author empty$
1409 'skip$
1410 { format.authors output.nonnull }
1411 if$
1412 new.block
1413 format.title "title" output.check
1414 new.block
1415 format.url "url" output.check
1416 new.block
1417 code empty$
1418 'skip$
1419 { format.code output
1420 new.block
1421 }
1422 if$
1423 format.urldate output
1424 note output
1425 fin.entry
1426 }
1427
1428 FUNCTION {misc}
1429 { is.arxiv.article
1430 'arxiv.article
1431 'std.misc
1432 if$
1433 }
1434
1435 FUNCTION {inbook}
1436 {
1437 format.chapter.pages empty$
1438 { "`inbook' requires chapter or pages, otherwise use `book'" my.warning }
1439 'skip$
1440 if$
1441 book
1442 }
1443
1444 FUNCTION {proceedings}
1445 { output.bibitem
1446 editor empty$
1447 { organization output }
1448 { format.editors output.nonnull }
1449 if$
1450 new.block
1451 format.title "title" no.output.check
1452 doi missing$
1453 explicit.doi.links
1454 or
1455 'skip$
1456 { add.doi.link }
1457 if$
1458 output
1459 new.block
1460 format.bvol.series output
1461 format.number.series output
1462 new.block
1463 address empty$
1464 { editor empty$
1465 { publisher new.sentence.checka }
1466 { organization publisher new.sentence.checkb
1467 organization output
1468 }
1469 if$
1470 new.block
1471 publisher output
1472 format.year "year" output.check
1473 }
1474 { address output.nonnull
1475 format.year "year" output.check
1476 new.sentence
1477 editor empty$
1478 'skip$
1479 { organization output }
1480 if$
1481 new.block
1482 publisher output
1483 }
1484 if$
1485 new.block
1486 check.links
1487 output.links
1488 fin.entry
1489 }
1490
1491 FUNCTION {booklet}
1492 { output.bibitem
1493 format.authors output
1494 new.block
1495 format.title "title" output.check
1496 howpublished new.block.checka
1497 howpublished output
1498 address new.block.checka
1499 address output
1500 format.year output
1501 output.links
1502 new.block
1503 note output
1504 fin.entry
1505 }
1506
1507 FUNCTION {unpublished}
1508 { output.bibitem
1509 format.authors "author" output.check
1510 new.block
1511 format.title "title" output.check
1512 new.block
1513 note "note" output.check
1514 format.year output
1515 format.eprint output
1516 fin.entry
1517 }
1518
1519 FUNCTION {incollection}
1520 { output.bibitem
1521 format.authors "author" output.check
1522 new.block
1523 format.title "title" output.check
1524 new.block
1525 #0 'doi.linked :=
1526 crossref missing$
1527 { format.in.ed.booktitle "booktitle" output.check
1528 new.block
1529 format.bvol.chap.pages
1530 conditional.doi.link output
1531 new.block
1532 format.number.series
1533 conditional.doi.link output
1534 new.sentence
1535 publisher "publisher" no.output.check
1536 conditional.doi.link
1537 address missing$
1538 'skip$
1539 { ", " * address * }
1540 if$
1541 output
1542 format.year "year" output.check
1543 new.block
1544 format.edition output
1545 }
1546 { format.incoll.inproc.crossref output.nonnull
1547 format.chapter.pages output
1548 }
1549 if$
1550 new.block
1551 output.links
1552 fin.entry
1553 }
1554
1555 FUNCTION {inproceedings}
1556 { output.bibitem
1557 format.authors "author" output.check
1558 new.block
1559 format.title "title" output.check
1560 new.block
1561 #0 'doi.linked :=
1562 crossref missing$
1563 { format.in.ed.booktitle "booktitle" output.check
1564 new.block
1565 format.bvol.chap.pages
1566 conditional.doi.link output
1567 new.block
1568 format.number.series
1569 conditional.doi.link output
1570 address empty$
1571 { organization publisher new.sentence.checkb
1572 organization output
1573 publisher output
1574 format.year "year" output.check
1575 }
1576 { address output.nonnull
1577 format.year "year" output.check
1578 new.sentence
1579 organization output
1580 new.sentence
1581 publisher output
1582 }
1583 if$
1584 }
1585 { format.incoll.inproc.crossref output.nonnull
1586 format.pages output
1587 }
1588 if$
1589 new.block
1590 check.links
1591 output.links
1592 fin.entry
1593 }
1594
1595 FUNCTION {conference} { inproceedings }
1596
1597 FUNCTION {techreport}
1598 { output.bibitem
1599 format.authors "author" output.check
1600 new.block
1601 format.title "title" output.check
1602 new.block
1603 format.tr.number
1604 doi missing$
1605 explicit.doi.links
1606 or
1607 'skip$
1608 { add.doi.link }
1609 if$
1610 output.nonnull
1611 new.block
1612 institution "institution" output.check
1613 address output
1614 format.year "year" output.check
1615 output.links
1616 fin.entry
1617 }
1618
1619 FUNCTION {manual}
1620 { output.bibitem
1621 author empty$
1622 { organization empty$
1623 'skip$
1624 { organization output.nonnull
1625 new.block
1626 address output
1627 }
1628 if$
1629 }
1630 { format.authors output.nonnull }
1631 if$
1632 new.block
1633 format.title "title" output.check
1634 author empty$
1635 { organization empty$
1636 { address new.block.checka
1637 address output
1638 }
1639 'skip$
1640 if$
1641 }
1642 { organization address new.block.checkb
1643 organization output
1644 new.block
1645 address output
1646 }
1647 if$
1648 new.block
1649 format.edition output
1650 format.year output
1651 output.links
1652 fin.entry
1653 }
1654
1655 FUNCTION {mastersthesis}
1656 { thesis.start
1657 "Master's thesis" format.thesis.type output.nonnull
1658 thesis.end
1659 }
1660
1661 FUNCTION {phdthesis}
1662 { thesis.start
1663 "PhD thesis" format.thesis.type output.nonnull
1664 thesis.end
1665 }
1666
1667
1668 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1669 % Default citation type
1670 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1671
1672 FUNCTION {default.type} { article }
1673
1674 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1675 % Macros/aliases
1676 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1677
1678 MACRO {jan} {"Jan."}
1679
1680 MACRO {feb} {"Feb."}
1681
1682 MACRO {mar} {"Mar."}
1683
1684 MACRO {apr} {"Apr."}
1685
1686 MACRO {may} {"May"}
1687
1688 MACRO {jun} {"June"}
1689
1690 MACRO {jul} {"July"}
1691
1692 MACRO {aug} {"Aug."}
1693
1694 MACRO {sep} {"Sept."}
1695
1696 MACRO {oct} {"Oct."}
1697
1698 MACRO {nov} {"Nov."}
1699
1700 MACRO {dec} {"Dec."}
1701
1702 MACRO {acmcs} {"ACM Comput. Surv."}
1703
1704 MACRO {acta} {"Acta Inf."}
1705
1706 MACRO {cacm} {"Commun. ACM"}
1707
1708 MACRO {ibmjrd} {"IBM J. Res. Dev."}
1709
1710 MACRO {ibmsj} {"IBM Syst.~J."}
1711
1712 MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
1713
1714 MACRO {ieeetc} {"IEEE Trans. Comput."}
1715
1716 MACRO {ieeetcad}
1717 {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
1718
1719 MACRO {ipl} {"Inf. Process. Lett."}
1720
1721 MACRO {jacm} {"J.~ACM"}
1722
1723 MACRO {jcss} {"J.~Comput. Syst. Sci."}
1724
1725 MACRO {scp} {"Sci. Comput. Programming"}
1726
1727 MACRO {sicomp} {"SIAM J. Comput."}
1728
1729 MACRO {tocs} {"ACM Trans. Comput. Syst."}
1730
1731 MACRO {tods} {"ACM Trans. Database Syst."}
1732
1733 MACRO {tog} {"ACM Trans. Gr."}
1734
1735 MACRO {toms} {"ACM Trans. Math. Softw."}
1736
1737 MACRO {toois} {"ACM Trans. Office Inf. Syst."}
1738
1739 MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
1740
1741 MACRO {tcs} {"Theoretical Comput. Sci."}
1742
1743 READ
1744
1745 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1746 % BIBLIOGRAPHY HEADER AND FOOTER
1747 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1748
1749 FUNCTION {begin.bib}
1750 { % Print the beginning of the bibliography to the .bbl file. Also set the
1751 % "Booleans" for the global config of DOI link printing and handling of warnings.
1752 #0 'explicit.doi.links :=
1753 #1 'warnings.are.errors :=
1754 #0 'pagebackref :=
1755 preamble$ empty$
1756 'skip$
1757 { preamble$ "MakeDoiLinksExplicit" contains.substring
1758 { #1 'explicit.doi.links :=
1759 "\newcommand{\MakeDoiLinksExplicit}{}" write$ newline$
1760 }
1761 { #0 'explicit.doi.links := }
1762 if$
1763 preamble$ "DoNotMakeWarningsErrors" contains.substring
1764 { #0 'warnings.are.errors :=
1765 "\newcommand{\DoNotMakeWarningsErrors}{}" write$ newline$
1766 }
1767 { #1 'warnings.are.errors := }
1768 if$
1769 preamble$ "PageBackRef" contains.substring
1770 { #1 'pagebackref :=
1771 "\newcommand{\PageBackRef}{}" write$ newline$
1772 }
1773 { #0 'pagebackref := }
1774 if$
1775 preamble$ write$ newline$
1776 }
1777 if$
1778 "\begin{thebibliography}{" longest.label * "}" * write$ newline$
1779 }
1780
1781 FUNCTION {end.bib}
1782 { % Print the ending of the bibliography to the .bbl file.
1783 newline$
1784 "\end{thebibliography}" write$ newline$
1785 }
1786
1787 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1788 % EXECUTION
1789 % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
1790
1791 % Initialize global constants indicating the positions in an entry
1792 EXECUTE {init.state.consts}
1793
1794 % Initialize global variables for the longest label
1795 EXECUTE {init.longest.label}
1796
1797 % Determine the longest label that will be needed
1798 ITERATE {longest.label.pass}
1799
1800 % Begin the library and handle the preamble
1801 EXECUTE {begin.bib}
1802
1803 % Create all bibliography entries
1804 ITERATE {call.type$}
1805
1806 % Finalize the library
1807 EXECUTE {end.bib}