A HelloWord Bib stile file .bst

09/12/2017 ∙ by Makar Plakhotnyk, et al. ∙ 0

A HelloWord Bib stile file .bst is described

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

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).

\documentclass{article} \begin{document}We cite the article~\cite{Ulam-1964} by S. Ulam and the book~\cite{Poincare} by H. Poincar\’e. Then we cite the article~\cite{Ulam-1964} by S. Ulam again. \begin{thebibliography}{10}

\bibitem{Poincare} H. Poincaré, {\it Les méthods nouvelles de la mécanique céleste}, Paris: Gauthier-Villars, 1892.

\bibitem{Ulam-1964} P. Stein and S. Ulam, ‘‘Non-linear transformation studies on electronic computers’’, {\it Rozprawy Mat.}, Vol. {\bf 39}, pp. 1-66, 1964.


\end{thebibliography} \end{document}

Figure 1: test.tex
We cite the article [2] by S. Ulam and the book [1] by H. Poincaré. Then we cite the article [2] by S. Ulam again.

References

  • [1] H. Poincaré, Les méthods nouvelles de la mécanique céleste, Paris: Gauthier-Villars, 1892.
  • [2] P. Stein and S. Ulam, “Non-linear transformation studies on electronic computers”, Rozprawy Mat., Vol. 39, pp. 1-66, 1964.

Figure 2: test.dvi
\begin{thebibliography}{10}

\bibitem{Simson-2015} Simson D., Tame-wild dichotomy of Birkhoff type problems for nilpotent linear operators, J. Algebra, Vol. 424 (2015) 254--293.

\bibitem{Poincare} H. Poincaré, {\it Les méthods nouvelles de la mécanique céleste}, Paris: Gauthier-Villars, 1892.

\bibitem{Ulam-1964} P. Stein and S. Ulam, ‘‘Non-linear transformation studies on electronic computers’’, {\it Rozprawy Mat.}, Vol. {\bf 39}, pp. 1-66, 1964.

\end{thebibliography}


Figure 3: test-a.tex
We cite the article [3] by S. Ulam and the book [3] by H. Poincaré. Then we cite the article [3] by S. Ulam again.

References

  • [1]
  • [2] Simson D., Tame-wild dichotomy of Birkhoff type problems for nilpotent linear operators, J. Algebra, Vol. 424 (2015) 254–293.
  • [3] H. Poincaré, Les méthods nouvelles de la mécanique céleste, Paris: Gauthier-Villars, 1892.
  • [4] P. Stein and S. Ulam, “Non-linear transformation studies on electronic computers”, Rozprawy Mat., Vol. 39, pp. 1-66, 1964.

Figure 4: test-a.dvi

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.


@article{Ulam-1964,
         author = "Stein P. R. and Ulam S. M.",
         title = "Non-linear transformation studies on electronic computers",
         journal = "Rozprawy Mat.",
         year = "1964",
         volume = "39",
         pages = "1-66"}

@book{Poincare,
         author = "H. Poincaré",
         title = "Les méthods nouvelles de la mécanique céleste",
         year = "1892",
         publisher = "Gauthier-Villars",
         address = "Paris"}

Figure 5: my.bib

\documentclass{article}
\begin{document}
We cite the article \cite{Ulam-1964} and the book \cite{Poincare}.}

\bibliographystyle{plain}
\bibliography{my}
\end{document}

Figure 6: test2.tex

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.

We cite the article [2] by S. Ulam and the book [1] by H. Poincaré. Then we cite the article [2] by S. Ulam again.

References

  • [1] H. Poincaré. Les méthods nouvelles de la mécanique céleste. Gauthier-Villars, Paris, 1892.
  • [2] Stein P. R. and Ulam S. M. Non-linear transformation studies on electronic computers. Rozprawy Mat., 39:1–66, 1964.

Figure 7: test2.dvi

ENTRY
         { author
         }{}{}

FUNCTION {output.bibitem} {
         "\bibitem{" write$
         cite$ write$
         "}" write$ newline$}

FUNCTION {article}{
         output.bibitem
         author write$
         " (article)" write$
         newline$ }

FUNCTION {book}{
         output.bibitem
         author write$
         " (book)" write$
         newline$ }
READ

FUNCTION {begin.bib}{
         "\begin{thebibliography}{10}" write$
         newline$ newline$ }

EXECUTE {begin.bib}
ITERATE {call.type$}
FUNCTION {end.bib}{
         "\end{thebibliography}" write$ }
EXECUTE {end.bib}


Figure 8: helloword.bst

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.


\begin{thebibliography}{10}

\bibitem{Ulam-1964}
Stein P. R. and Ulam S. M. (article)
\bibitem{Poincare}
H. Poincaré (book)
\end{thebibliography}

Figure 9: test3.bbl
We cite the article [1] by S. Ulam and the book [2] by H. Poincaré. Then we cite the article [1] by S. Ulam again.

References

  • [1] Stein P. R. and Ulam S. M. (article)
  • [2] H. Poincaré (book)

Figure 10: test3.dvi

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.

When the functions article and book are finished, the program comes to the line, which is next after ITERATE {call.type$}. After this we see the description of the function end.bib. And then our program finishes with the execution of end.bib, i.e. with writing the text

\end{thebibliography}

into test3.bbl.

References

  • [1] H. Poincaré, Les méthods nouvelles de la mécanique céleste, Paris: Gauthier-Villars, 1892.
  • [2] P. Stein and S. Ulam, “Non-linear transformation studies on electronic computers”, Rozprawy Mat., Vol. 39, pp. 1-66, 1964.

References

  • [1]
  • [2] Simson D., Tame-wild dichotomy of Birkhoff type problems for nilpotent linear operators, J. Algebra, Vol. 424 (2015) 254–293.
  • [3] H. Poincaré, Les méthods nouvelles de la mécanique céleste, Paris: Gauthier-Villars, 1892.
  • [4] P. Stein and S. Ulam, “Non-linear transformation studies on electronic computers”, Rozprawy Mat., Vol. 39, pp. 1-66, 1964.

References

  • [1] H. Poincaré. Les méthods nouvelles de la mécanique céleste. Gauthier-Villars, Paris, 1892.
  • [2] Stein P. R. and Ulam S. M. Non-linear transformation studies on electronic computers. Rozprawy Mat., 39:1–66, 1964.

References

  • [1] Stein P. R. and Ulam S. M. (article)
  • [2] H. Poincaré (book)

3 The .aux-file, or how does LaTeXcreates the bibliographical citations

3.1 The case, where BibTeXis not used

Lets come back to the file test.tex (see Figure 1) and suppose that there are no any other file in this folder.

During the first run of latex.exe test it creates three files:

1. test.log (the comments during the translation),

2. test.aux (information about the bibliography),

3. test.dvi (the result of the translation).

The test.aux file after the first run of latex.exe test is as at the Figure 11. This file is easy to understand. The first line \relax is not important for us555In fact, this is a command which says to LaTeXto “stop the execution of any function if it is executed”.. When LaTeX meets the citation \ref{…} in the .tex-file, it creates a line \citation{…} in the .aux-file.

\relax
\citation{Ulam-1964}
\citation{Poincare}
\citation{Ulam-1964}
\bibcite{Poincare}{1}
\bibcite{Ulam-1964}{2}

Figure 11: test.aux

When LaTeXmeets the bibliography item in the .tex-file, it creates a line \bibitem{…}, it creates the line \bibcite{…} in the .aux-file.

Nevertheless, the final file tes.dvi does not have references after the first execution of latex.exe test (see Figure 12).

We cite the article [?] by S. Ulam and the book [?] by H. Poincaré. Then we cite the article [?] by S. Ulam again.

References

  • [1] H. Poincaré, Les méthods nouvelles de la mécanique céleste, Paris: Gauthier-Villars, 1892.
  • [2] P. Stein and S. Ulam, “Non-linear transformation studies on electronic computers”, Rozprawy Mat., Vol. 39, pp. 1-66, 1964.

Figure 12: test.dvi

We can found a hint about these [?]s in the file test.log. It contains a line “No file test.aux”, which, clearly, mans that latex.exe test tried to use test.aux, but this file was not created this moment. Remark, that the messages

LaTeX Warning: Citation ‘Ulam-1964’ on page 1 undefined on input line …

LaTeX Warning: Citation ‘Poincare’ on page 1 undefined on input line …

appear after the message about non-existence of test.aux. We can explain it as follows. Before the begin of the translation the file test.tex, the LaTeX opens (tries to open) the test.aux. It is successes with this, it reads all the lines \bibcite{…}, which give the correspondence with bibliographical references (“Ulam-1964” and “Poincare” in our case) and numbers (2 and 1 respectively in our case). If the file test.aux is read (precisely if it exists) then the relations, obtained from it, are used to construct the references “[1]” and “[2]” instead of “[?]”.

In any way, after the second execution of latex.exe test, the message No file 1.aux disappears from test.log and we obtain the final result test.dvi, given at Figure 2.

We can present here one more experiment, which will clarify our understanding of the creation of the bibliography by LaTeX. Let us delete the file test.aux and execute latex.exe test. Then enter the test.aux and change the last two lines to
\bibcite{Poincare}{10}
\bibcite{Ulam-1964}{25}

We cite the article [25] by S. Ulam and the book [10] by H. Poincaré. Then we cite the article [25] by S. Ulam again.

References

  • [1] H. Poincaré, Les méthods nouvelles de la mécanique céleste, Paris: Gauthier-Villars, 1892.
  • [2] P. Stein and S. Ulam, “Non-linear transformation studies on electronic computers”, Rozprawy Mat., Vol. 39, pp. 1-66, 1964.

Figure 13: test.dvi

After the second execution of latex.exe test we will obtain the file test.dvi as at Figure 13. The message

Warning: Label(s) may have changed. Rerun to get cross-references right.

will appear in test.log. The file test.aux will return to its “previous” condition, i.e. as at Figure 11.

After one more execution of latex.exe test, the test.dvi also will come back to the form, which is presented at Figure 2.

3.2 The use of BibTeX

When we execute latex.exe test2 for the file test2.tex (see Figure 6), then (in the assumption, that there is no test2.bbl in the folder) the file test2.aux as at Figure 14 is generated.

\relax
\citation{Ulam-1964}
\citation{Poincare}
\citation{Ulam-1964}
\bibstyle{plain}
\bibdata{my}

Figure 14: test2.aux

Now, when we will execute bibtex.exe test2, this test2.aux will be analyzed at the very beginning (not test2.tex). Clearly, the style plain will be used after (because exactly this style is mentioned in the file) the bibliography will be taken from my.bib. After all of this the file test2.bbl will be generated.

When we already have test2.bbl, we may execute latex.exe test2 and it will add to test2.aux two lines:
\bibcite{Poincare}{1}
\bibcite{Ulam-1964}{2}
Nevertheless, the bibliographical links will not be generated in test2.dvi (after the first execution of latex.exe test). The explanation of this is the same why they were not generated after the first execution of latex.exe test in previous subsection.

References

  • [1] H. Poincaré, Les méthods nouvelles de la mécanique céleste, Paris: Gauthier-Villars, 1892.
  • [2] P. Stein and S. Ulam, “Non-linear transformation studies on electronic computers”, Rozprawy Mat., Vol. 39, pp. 1-66, 1964.

References

  • [1] H. Poincaré, Les méthods nouvelles de la mécanique céleste, Paris: Gauthier-Villars, 1892.
  • [2] P. Stein and S. Ulam, “Non-linear transformation studies on electronic computers”, Rozprawy Mat., Vol. 39, pp. 1-66, 1964.

4 Polish notation and some explanations about the style of programming in .bst-file

The polish notation is the tradition to write formulas (functions with arguments) such that first we write arguments and then the name of the function. For example, to write

instead of

Moreover, every function (including the algebraic operations), which has input arguments and which has output, works with a stack “first in – last out”.

For example, when style the file test.bst (from Figure 8) was executed:

1. the line "\bibitem{" write$ meant to write “\bibitem{” to the stack; then execute the function write$, which reads one parameter from the stack and writes it to the file test.bbl (indeed, not exactly to file, but to the “buffer” of test.bbl) After all the writing to the buffer of test.bbl we need to use the function newline$, which writes everything from the buffer to the file and then writes a symbols of the end of a line into the file.

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.


FUNCTION {bib.sort.order}{
         author ’sort.key$ := }
ITERATE {bib.sort.order}
{SORT}

Figure 15:

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.


@article{YangYu,          author = "Yang Tse-Chung and Yu Chia-Fu",          title = "Monomial, Gorenstein and Bass orders",          journal = "J. Pure Appl. Algebra",
         year = "2015",
         volume = "219",
         pages = "767-778",
         number = "4"}


Figure 16:

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


ENTRY
         { author
         { number
         { volume
         }{}{}
FUNCTION {article}{
         output.bibitem
         author write$

         ", No. " write$ number write$
         ", Vol. " write$ volume write$
         newline$ }

Figure 17:

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

Figure 18:

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.


FUNCTION {article}{
         output.bibitem
         author write$
         number empty$
         {skip$}
         {", No. " write$ number write$}
         if$
         ", Vol. " write$ volume write$
         newline$ }

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”.


FUNCTION {bib.sort.order}{
         author #1 "{ll}" format.name$
         author num.names$ #1 =
         {skip$}
                 { author #2 "{ll}" format.name$ *
                 author num.names$ #2 =
                 {skip$}
                 {author #3 "{ll}" format.name$ *}
                 if$}
         ’sort.key$ := }

Figure 20:

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.