# A HelloWord Bib stile file .bst

A HelloWord Bib stile file .bst is described

## Authors

• 1 publication
• ### A new approach to content-based file type detection

File type identification and file type clustering may be difficult tasks...
02/17/2010 ∙ by M. C. Amirani, et al. ∙ 0

• ### A File System For Write-Once Media

A file system standard for use with write-once media such as digital com...
03/31/2020 ∙ by Simson L. Garfinkel, et al. ∙ 0

• ### The polymake XML file format

We describe an XML file format for storing data from computations in alg...
05/17/2016 ∙ by Ewgenij Gawrilow, et al. ∙ 0

• ### File System Design Approaches

03/21/2014 ∙ by Brijender Kahanwal, et al. ∙ 0

• ### Specifying a Realistic File System

We present the most interesting elements of the correctness specificatio...
11/13/2015 ∙ by Sidney Amani, et al. ∙ 0

• ### File System - A Component of Operating System

The file system provides the mechanism for online storage and access to ...
12/06/2013 ∙ by Brijender Kahanwal, et al. ∙ 0

• ### Axodraw Version 2

We present version two of the Latex graphical style file Axodraw. It has...
05/27/2016 ∙ by John C. Collins, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Short motivation

I was preparing an article to a mathematical journal. It uses BibTeX, but there were no the necessary file of bibliographical styles on its internet cite. Precisely, there were some, but all of them generated not the same style of references as in the articles of recent issues of the journal. I have not understood, how the authors of these articles prepared there files, but I had not imagined nothing better than to begin to change one of the bibliography styles, which I have downloaded from the cite of the journal.

I was doing my changes without any additional literature, just with the help of my intuition, through trials and errors. After the end of the work, which, frankly said, was not done properly, I tried to understand, how can I prepare my own bibliography style: how complicated it is (I was sure that it should not be very complicated), where can I read about it etc.

I have found the program makebst (but not used it). I have read that it asks a “long list of questions” and then produces the bst-file (file with the style of bibliography). I have not even downloaded and tried to use this program “makebst” because of I had understood already that a bibliography style (.bst -file) is a small program to produce the bibliography. It seamed to me very strange to have a program (makebst), which asks some questions and produces another program.

I have found [1] and [2]. I have found enough information in these books (precisely in the first one, which is bigger and contains more explanations), but I have spent a mountain of time to prepare my bibliography style, because these books are written as “reference book” with minimum of examples and without detailed explanation “what to start with”.

The sing, which seamed a very strange for me in the book of Oren Patashnik is his suggestion that the best for the create a new style is to start with an existing style that is close to yours, and then modify it. Clearly, if somebody works in the editorial staff of a huge journal, does not know how to create a bibliographical style but, in the same time, needs to create it,… hm… then indeed the best way is to modify (or, better, not to modify) some of the existing styles. But if a person studies to create styles, then (I think) the best way is to start with a small “Hello-Word” style and then to improve it.

Thus I want to write about the preparation a new bibliography style in the manner of writing an introduction to a new language of programming. I want to start with a short “HelloWord” style and then explain how one can improve it to something, which “can be used in the practical life”. I am not a professional in latex-style creating, but this short book is just my own experience of the preparation of a BibTeXstyle-file.

## 2 The simplest examples

### 2.1 The use of bibliography citing without BibTeX

Look at the file test.tex as at Figure 1. After the execution (2 times111I will explain in Section 3, why do we have to execute this program 2 times, but not 1.) of latex.exe test it will be generated the file test.dvi as at Figure 2.

The convenience here is that we can add or rearrange the bibliographical items, and in this case the commands \cite{Ulam-1964} and \cite{Poincare} will generate the correct numbers in brackets. For example, if we will add the first bibliographical reference, i.e. will transform the bibliography as at Figure 3, then the same command \cite{Ulam-1964} will generate “[3]” (see Figure 4).

### 2.2 The use of BibTeX

One of the most simple motivations to use the BibTeX is to standardize the presentation of the bibliographical items in the bibliography. For example, it should be clear that articles [1] and [3] at Figure 4 are described in different styles. For instance, in [1] the second name comes before the first one, but in [3] is conversely. The name of the journal is written by italic in [3], but in [1] is not. The same thing is about the letters “pp.” before the pages of article, bold style of the number of the volume, manner to write the year.

Let us imagine, that we are a editorial staff of a scientific journal. Clearly, we have some concrete rules for the manner of presentation of an item of the bibliography of an article (i.e. which should be bold, which should be italic, where should be parenthesis, where slashes etc.). One way to achieve this is all the articles of our journal is to give to all the authors an “example” (for instance, Figure 2) and to ask “to prepare the bibliography according to example”. Another way is to ask them to prepare the data about their bibliographical items separately and then we will use some program to prepare the bibliography in the manner we need.

The bibliography from Figure 1 (the lines between \begin{thebibliography}{10} and \end{thebibliography}) should be redone as at Figure 5 and saved in the separate file with extension .bib (call it my.bib). Also redo the .tex-file as at Figure 6 and name it test2.tex.

The line \bibliography{my} in test2.tex means that the bibliography is saved in the same directory as the current file (test2.tex) and this bibliography is named my.bib.

The line \bibliographystyle{plain} means that “plain” is the name of the style of bibliography, which we will use (this is one of standard bibliography styles ant it is generally distributed with BibTeX). The bibliography stile plain is distributed together with the BibTeX. There is a file

\bibtex\bst\base\plain.bst

(in the folder, where TeX is installed), and this file provides the style “plain”222also there are “another styles” in the mentioned folder. The extensions of all of them are .bst and it is an extension of a file of BibTeX-style..

To create the file test2.dvi we need to:

1. execute latex.exe test2 (one time),

2. execute bibtex.exe test2 (one time),

3. execute latex.exe test2 (two times).

After these procedures our final test looks as at Figure 7. Remark, that this is not exactly the same, as we had at Figure 2. In fact, the file test2.bbl was created by the program bibtex.exe and it contains the bibliography, which is very similar to one from Figure 1.

### 2.3 The Hello-Word BibTeX-file

The style, which we will consider the simplest (hello-word) style is given at Figure 8. To use this file we save our test2.tex as test3.tex and just change the parameter plain of the command \bibliographystyle into helloword. Save the “script” from Figure 8 in the same folder, where test3.tex is, and let’s name this style-file helloword.bst.

After the execution of latex.exe test3 and then bibtex.exe test3 the file test3.bbl (see Figure 9) is generated. The final file test3.dvi is given at Figure 10.

Clearly, the obtained file test3.dvi corresponds the bibliography-file test3.bbl. This test3.bbl was created “by the algorithm”, which is there in helloword.bst.

I shall not give the detailed explanations about “how helloword.bst works”, but we will just briefly look through helloword.bst and compare it with test3.bbl.

The second line { author } in helloword means that the field “author” will be accessible to our program (thus, another fields from my.bib, i.e. “title”, “journal”, “year”, “volume”, “publisher” and “address” will not. In other words, our style-file (our “algorithm”) will not be able to use these fields. To make one (or more than one) of these parameters accessible we had to write for example:

ENTRY
{ author
title
journal
}{}{}

After the block called ENTRY, we see functions output.bibitem, article and book. The functions will be executed (if will be) a bit later by the correspond commands (and we will see these commands).

The word “READ” is the command, which tells BibTeX“to read our file test3.tex333indeed this command says to read the file test3.aux, which we will discuss a bit later, but for the first time we can imagine that the file test3.tex is read.

After the command READ we have the function begin.bib, which will be executed later, in the same manner as another functions.

The next command EXECUTE { begin.bib } executes the function begin.bib, which should be described later, because BibTeX-file reads the .bst

-file “line by line” and whence “does not know”, what is there later; thus, in the moment of the command to execute the function

begin.bib, this function should be already described.

Since the we have already seen the function begin.bib early in our file, let us come there and understand, what it does. It does nothing more that to write the line “\begin{thebibliography}{10}” onto the file test3.bbl, then write two times the symbols or the begin of the next line (which is clear from the file test3.bbl, which, in fact, appears).

After the function begin.bib finished its execution, we come back to the line, where it was called and look at the next line.

The next command ITERATE {call.type$} does the following: 1. looks through our file test3.tex444indeed, through test3.aux, but we will talk about this later.. 2. takes every command \ref{…} (in the order or the appearance in the file); precisely, in our file it is \cite{Ulam-1964}, then \cite{Poincare} and then \cite{Ulam-1964} ones more. 3. Find the description of the reference \cite{Ulam-1964} in the file my.bib. This description starts with “@article{Ulam-1964,”. Thus, the function article will be executed. 4. The same thing will happen with \cite{Poincare}. First the line “@book{Poincare,” will be found in my.bib, and the the function called book will be executed. 5. Since the third citation \cite{Ulam-1964} corresponds to the reference, which was prepared for the test3.bbl already, then happens nothing. This idea (with different functions “article” and “book”) is realized to make possible to prepare the bibliographical description of “articles” and “books” in different manner. For example, every article has journal (where it was published), i.e. during the creation of the description of the article the field “journal” should be used. Nevertheless, a book does not have such parameter as journal. In any way, now we will look inside the function article (since it was executed first) and then inside the function book. At the very beginning the function article calls one more function: output.bibitem. This is written just by the first line of article. The function output.bibitem works in the same way, as we have already seen in begin.bib. First write into the file test3.bbl the sequence of symbols “\bibitem{”. The command “cite$” takes the name of the reference (in or case it is “Ulam-1964”) and writes in to test3.bbl. Then close the bracket “}” in the test3.bbl and writes the symbol of the new line. Thus, in our case the line

\bibitem{Ulam-1964}

appears. After this output.bibitem is over and program goes back to article. The command author write$writes into test3.bbl the text from the field “author” of the reference “Ulam-1964”. The next command " (article)" write$ writes “ (article)”. We do it to distinguish the function article and the function book in the final file test3.bbl.

The function book works absolutely analogically to article.

2. the line author write$worked similarly. First write to the stack the field “author” and then write one string from the stack to the buffer of test.bbl. There are some natural rules of using this stack. For example: 1. Assume that at the moment of the start of the execution of the .bst-file the stack is empty. This means that if we use a function, which reads something from the stack, then we should be sure that this “something” is there in written to the stack earlier. 2. Variables has types. The types are only integer and string. If some function has integer argument, then correspond its argument in the stack should be integer, but not string. 3. At the end of the execution of the .bst-file the stack should be empty. We will not give now the list of all the function (this list with the descriptions is there, for example, in the book by Nicolas Markey), but we will give some remarks just to understand, what the functions from that list “can do”: 1. There is an operator “:=”, which puts the value from the stack to the variable and should be used as ’var := (i.e. with apostrophe) to assign the value from the stack to the variable var; 2. Arithmetical operations are functions; 3. there is possibility to use cycles (function while) and to verify conditions (function if); There are some other functions, but all of them are not important for us just now. ## 5 Ordering of references with the use of BibTeX-style As far as we has understood from the study of the our hello-word style, that the simplest way to order the bibliography is by the appearance in the .tex-file, or precisely (which, in fact, is the same) in the .aux-file. The need to order the bibliography in any other way (for example, by author’s names) is frequent and natural. It can be easily realized. Let us take our style test.bst (from Figure 8) and add there the fragment, which is there at Figure 15. Put this fragment after the command read and before the function begin.bib. Each bibliographical item has the string variable, called sort.key. The command SORT sorts the bibliographical items according to this variable. The command  ITERATE {bib.sort.order} executes our function bib.sort.order, which sets the value of the field “author” to the variable sort.key. Thus, after such modification of the .bst-file we will have our bibliography, ordered by author. From another hand, attentive reader must notice, that “life is a bit more complicated”, because in our example we had authors “H. Poincaré” and “P. Stein and S. Ulam”. If they will be sorted as we have done, then (also in the case o huge list of bibliography) the first item will appear between items, starting with letter “H” (H. Poincaré), and the same thing about “P. Stein and S. Ulam”. Nevertheless, it is natural to want to sort bibliography by second names, but not complete names. We will discuss this problem a bit later in the section 7. ## 6 Function if$

Clearly, the bifurcations (like “if”) and cycles (like “while”) is the basis of any language of programming. From another hand, the .bst-file is not a pure program, but a list of commands, how to create a .bib-file.

Let us see an example, where bifurcation is necessary.

Wether the article has number?

Some journals identify the article by: volume (one year is one volume), number (starts from one each year), pages. Some another journal’s issues has no number (but has only volume).

Suppose that we have one more reference (see Figure 16) and have citing “\cite{YangYu}” somewhere in the .tex-file.

Let us add fields “number” and “volume” to our style and lets modify the function article as at Figure 17.

The references of our file will look as at Figure 18. Clearly, it is bad, because the word “No. ” should not appear in the second reference. Moreover, the bibtex.exe generates, during the generation a .bib-file its own file with comments test3.blg and the comment

‘number’ is a missing field, not a string, for entry Ulam-1964

appeared there. The significance of this comment is clear. Modify our function book ones more as at the Figure 19.

Explain a bit the obtained function. The function if$has three arguments (which are taken from the stack). The first one is an integer (which is considered as true if it is strictly positive and false otherwise). The second argument should be command (of name of another function, or sequence of commands). We have written in brackets the first argument of if$:

{skip$} and the second its argument ", Vol. " write$ volume write$. The command {skip$} means “do nothing” and one of the reason of its existence is, possibly, the way to use the function if$, as we have to. The third parameter of if$ should be clear, since it already appeared in the previous version of our function book.

The function {empty$} checks, wether its argument (taken from the stack as an argument of any function) is an empty string. If it is, the result (which is put to the stack) 1 is returned and 0 otherwise. Thus, the line number empty$

means that we first put “number” into the stack (if a reference do not have some [declared] field, this field is considered to be an empty string); then empty$puts a string from the stack and checks, wether it is empty. ## References • [1] H. Poincaré (book) • [2] Stein P. R. and Ulam S. M., No. , Vol. 39 • [3] Yang Tse-Chung and Yu Chia-Fu, No. 4, Vol. 219 ## 7 Function format.name$

There are some situations, which we need to obtain the second named from the list of named of the authors (for example, for order bibliography by author’s names).

Traditionally all the information about author’s names BibTeXtakes from the field “author”, whence it will be considered strange, if our style will have fields like

“first.authors.first.name”, “first.authors.second.name”, “second.authors.first.name”,

“second.authors.second.name”, “third.authors.first.name”, “third.authors.second.name” etc.

This “traditionally” it quiet important, because the idea of BibTeX is to create the style, which manipulates with the bibliographical data-base and thus, our own style should not need to ask the author of the .bib-file to redo it in some way to satisfy the needs of especially our style .bst.

Thus, there are some rules to prepare the names of authors in the field author:

1. Different authors should be separated by the word “and” onr from another

2. Author’s name has four parts: First name; Last name; part “von”, and “suffix”.

2. There are three forms to write each of the author:

2a. First von Last;

2b von Last, First;

2c. von Last, Suffix, First.

There are two functions to work with names: num.names$and format.name$.

The first of them (num.names$) is easy: it takes (clearly from the stack) a string and computes the number of words “and” in it. This is assumed to calculate the number of authors in the list of author’s names. The function format.name$ has three arguments: String (the field “author”), integer (the number of the author in the list of authors), and String (the output format of the name, which we want).

The use of the function format.name$is clearly explained in the book by N. Markey. The example of the “output format of the name” is “{ff}{vv}{ll}{jj}”, which means here to obtain the (complete) first name (i.e. everything, which is the first name), then the complete von-part, then the complete last name and then the complete suffix. We could write “{ff}{l.}{jj}” to take only the first latter (s) of the last name (to write only one “l” instead of “ll” and to put dot after the last name part. We could not ask about some parts about the name, for example (like we have ignored the “von”-part in the last example. Clearly, the existence of all of these rules means that the author of the .bib-file has to prepare the list of names “correctly”, i.e. in such a way that functions num.names$ and format.name\$ could obtain the list of named of authors and the part of each author correctly. Otherwise, the incorrect .bib-file should be considered as a mistake of its author, but not of author or a style. For example, if there is a rule to write the name as

First von Last,

then the author name should be written as

F. Riss

not “Riss F.”. Nevertheless, the same name can be written as

Riss, F.

(with comma) according to the rule

von Last, First.

In this case, can not be written “F., Riss”.

For example, the simplest function bib.sort.order is given at Figure 20. It sorts the list of references by author’s second (last) names, but not by the strings “author”.

## 8 Conclusion

A good bibliographical style has to be written only by a person, who has a lot of experience. This experience is not an experience of programming, but the experience of checking the correctness of the bibliographical references. The language of .bst-file is simple enough, but this language is nothing more than a tool to prepare the bibliography, but the logics of the preparation depends of the mind of the programmer, but not on the language. For example, we have noticed that an article may have a number of a journal, may not have. An article may a very long list of authors (up to 30 in some articles on physics). If somebody does not know this, then only experience may help. And what obvious (for an experienced person) and important we have not noticed?

If a person prepares his(her) own book with 20-30 bibliographical references, then to prepare an own .bst-file may be an interesting exercise. But if somebody works in the additional staff of a journal, which prepares 100 articles a month with 20-30 references each, then usage (and improve) of an own .bst-file, starting with hello-word can lead to a huge disadvantages of one of the issues of this journal. From another hand, any programmer, who studies a new language, do not do study during the participation in a huge project and do not prepare a huge project during one night.

## References

• [1] Nicolas Markey. Tame the beast the b to x of bibtex. 2003.
• [2] Oren Patashnik. Designing bibtex styles. 1988.