1 % This template file was written by Phil Holmes to replace the one used for the bibliogrphy
2 % on the LilyPond project. 18 Feb 2011
4 % This section lists the possible fields, although not all are handled by the template
37 { label extra.label sort.label }
39 % s and t came from the original. The other strings are self explanatory
41 STRINGS { ThesisType ReportType }
44 INTEGERS { nameptr namesleft numnames }
46 % This was simply copied and pasted from the original
47 FUNCTION {format.names}
50 s num.names$ 'numnames :=
51 numnames 'namesleft :=
53 % This line was changed: the {ff{ } } entry outputs the first name without allowing bibtex to use
54 % a ~ to replace the spaces where it thinks fit. The downside is that we lose hyphens...
55 { s nameptr "{ff{ } }{vv }{ll}{, jj}" format.name$ 't :=
72 nameptr #1 + 'nameptr :=
73 namesleft #1 - 'namesleft :=
78 FUNCTION {format.authors}
79 % This is a very common construct. It means "if the author is empty, process the lines in the first pair
80 % of braces {}. Otherwise process the lines in the second pair. So if it's empty, an empty string is
84 % If it's not empty, it formats author (and stacks the result) and then checks whether editor is empty
87 % If editor is empty, it appends an empty string (the * is a postfix operator meaning append this
88 % string to the top entry on the stack
90 % Otherwise it appends a period, parenthesis.
97 FUNCTION {format.editor}
100 { editor format.names
101 editor num.names$ #1 >
114 FUNCTION {output.bibitem}
116 "@item " write$ newline$
119 FUNCTION {format.edition}
122 { edition " edition, " * }
126 FUNCTION {format.date}
130 { "there's a month but no year in " cite$ * warning$
137 { month " " * year * }
143 FUNCTION {format.address}
155 FUNCTION {format.publisher}
172 FUNCTION {format.note}
181 FUNCTION {format.title}
184 { "@strong{" title * "}" *
198 FUNCTION {format.number}
200 % ReportType is set by us when we call the correct function for the bibliography type
206 { "Number " number * ". " * }
215 { " " * number * ", " * institution * ", " * }
221 FUNCTION {format.volume}
226 { "volume " volume * }
233 FUNCTION {format.journal}
236 { "@emph{" journal * "}" *
245 { "(" number * ")" * }
262 FUNCTION {format.series}
266 % This is an inbuilt function that adds a period when appropriate.
273 FUNCTION {format.booktitle}
276 { "In @emph{" booktitle * "}, " *
279 { "pages " * pages * ", " * }
285 FUNCTION {format.thesis}
288 { ThesisType school * ", " *}
292 % This is the function that runs the formatting code. It's called when the biblio type is @Book
295 format.authors write$
304 format.publisher write$
305 format.address write$
306 format.edition write$
307 format.booktitle write$
318 % All the following functions are called for the other biblio types. This is @article
321 % And we just call the book function
332 % This sets the string ThesisType to be equal to "PhD Thesis"
333 "PhD thesis, " 'ThesisType :=
335 % And this sets it back to an empty string
339 FUNCTION {TechReport}
341 "Technical Report" 'ReportType :=
346 FUNCTION {InProceedings}
351 FUNCTION {MastersThesis}
353 "Master's thesis, " 'ThesisType :=
363 % Haven't dug too deeply into this, but it seems to set the sort key
366 #1 entry.max$ substring$
370 % The entry point for processing
375 % Work through the entries, calling the presort function
381 % This could go higher with all the other functions, but it _has_ to be above the call
383 { "@c bib -> itexi intro" write$ newline$
384 "@itemize" write$ newline$
387 % Run the begin.bib function
390 % For each bibliogrpahy entry call the relevant function (e.g. book, article, booklet, etc.)
395 "@end itemize" write$ newline$
396 "@c bib -> itexi end" write$ newline$