Outils pour utilisateurs

Outils du site


issue198:latex

Ceci est une ancienne révision du document !


This time we are going to expand the “back matter”of the book even more. I started working with the sample cookbook in Full Circle Magazine #194, and continued in #195 and #197. (Sorry about missing #196, there were other important things I had to deal with.) If you have been following along, you should now have a small book with a number of recipes, a very short glossary, and an index. There are section dividers and a table of contents. This time, I am going to add sources to the recipes and build a bibliography.

A bibliography is a necessary part of any academic paper, whether it is published in a peer-reviewed journal or an assignment submitted to a teacher. The basic rule for references is simple. If the words or ideas included in your paper were written by someone else you have to use a reference, you have to give credit where credit is due. Not to do so means you claim their words are your words. You are lying, misrepresenting the truth. Portions of your paper, article, book, have been copied from someone else. Officially this is called plagiarism, also known as cheating.

The recipes I included in the sample cookbook I collected from email and various web sites. Most of them I have had for more than ten years. However, they are not my work. I do not know the sources for any of them. I do not claim they are my work. In this issue, I will provide the recipes with fictional sources of various kinds.

If you have had to write something that included at least one other person’s words, you should know there are different ways to indicate the source of other persons’ words. The oldest way was to use numbered footnotes at the bottom of the page where the quoted material appeared, and then a complete listing of all sources in a bibliography (list of references) at the end. More recently, endnotes have become acceptable in many publications. They are similar to footnotes in that they are numbered in the text but the list of notes appears either at the end of the chapter (less common), or at the end of the book. Sometimes, the numbering was sequential from beginning to end. Usually in a book, the numbering restarted at 1 at the beginning of each chapter and the list of endnotes was divided by chapter. For many years, the standard in scientific papers has been inline references (or citations) plus a bibliography at the end of the book.

There are “style sheets” for various types of citations and reference lists: APA, Chicago, MLA, etc. Every publication and every publisher will have a style for references. The style chosen might be their own custom style. More likely, they will use one of the well-known standards either as is or with a few modifications that make it more suitable for its intended audience.

There are more than 1.5 pages of references in the index to The Latex Companion dealing with bibliography. There are another two pages for references for “cite” and “citations”, and half a page of references for database management for bibliographies. Volume 2, chapter 15, deals with bibliographies, and chapter 16 deals with citations, over two hundred pages of text. You should conclude from all these numbers that this is a very valuable and complex feature in Latex.

There are two major programs used by Latex to build bibliographies: Bibtex and biber. I am going to use the tools and commands used in Bibtex. I would prefer to use biber, because it supports Unicode. However, that would mean rebuilding my bibliographic database.

The first step in building a bibliography is to have sources to include in it. One way is available in TexStudio but not in Gummi (the two Latex GUIs I have on my system): a Bibliography menu. When selected, it shows a long list of different types of sources. Pick the one that is most relevant to your source, and fill in the blanks. What you are building is a one-table, multiple-field database. Before you select the Bibliography menu, you must open a new file in TexStudio (or open an existing bibliography database file). The file must be saved using “bib” as the file type. For ease of use, name it the same as the principle file and save it to the same directory as the principle file. (The name and location can be different than suggested, but you should have a good reason to do so.)

Once the file has been opened (and possibly saved), select the type of reference from the Bibliography menu in TexStudio and then fill in the information. Optional information is indicated with OPT at the beginning of the field name, required information is not. If you do not complete the required information, you will get a compilation error. Optional fields that do not have user information can be left as-is or deleted.

Each record in the bib file will start with an ampersand @, followed by the name of the type of source, then a curly brace. Immediately after the curly brace you should supply a unique value (name) for the source. You can name a source anything you wish. I suggest you use something you will remember since it is this identifier that is used in the cite instruction in the body of your article or book or whatever. I normally use the author’s last name, unless I have two or more sources from the same author, and then I might include a year or part of the title of the source. (A little more about this when we get to the cite instruction.)

Another way to add records to the bib file is to copy them from an online source. Many books and journal articles have included bibliographic information in various formats on websites. Google Scholar is one place to find such information. Even if you own the source, sometimes it is easier to copy and paste the required information from a website to your bib file than to type it all yourself. Often the bibliographic information online is more complete than what you might type. I looked up a book I own on books.google.ca, and found bibliographic information in three formats: BibTex, EndNote, RefMan.

Once you have at least one source recorded in a bib file, you need two more steps to make the bibliography appear in the PDF of your document, well three steps if you count compilation, which is always the last step before the PDF appears. These two steps can be completed in any order.

Step 1: Cite the item in the appropriate place in your document. Step 2: Add instructions to the document so the bibliography appears where you want it.

At the end of the master document of the cookbook, I inserted the two necessary instructions to get the bibliography to appear after the glossary and before the index.

\bibliographystyle{alpha}

\bibliography{fcm198index}

These two instructions are both required. However, the options inside the curly braces will change. Remember I said the bib file is best named the same as the main document file. See the {fcm198index} instruction. That points to the fcm198index.bib file saved in the same directory as the main document. If you decide to save it with a different name, myrefs.bib for example, that name would appear as \bibliography{myrefs}. If you also saved it in a different directory, the path to that directory must be included inside the curly braces.

The bibliographystyle{alpha} is also required. It tells Latex how to set up the citations in the body of the document and how to set up the bibliography. {alpha} is the default style, which I do not like very much. I am used to using either APA or MLA, or some form of scientific-style citation. There are several built-in bibliography styles, and many other packages can be obtained from ctan.org. I did not want to load this issue with a lot of screenshots. If you are interested, I suggest you take a look at any of the following styles: plain, acm, apalike, ieeetr. To find out what bibliography styles are installed on your computer, do a search for files of type bst. My standard Latex installation has at least two hundred *.bst files.

In order to have a bibliography, the document (in our case at least one of the documents) must contain a citation, a place in the text which refers to the source. The instruction for a citation is \cite. If you use TexStudio and have compiled the PDF when you type the instruction \cite, TexStudio will show you a list of entries from the bib file so you can pick one instead of trying to remember which identifier is appropriate at this point in your document.

As an example, the Chinese Sesame Buns recipe has a reference to Fuchsia Dunlop’s book. In the tex file, the reference is \cite{Dun19}. This citation points to item Dun19 in the bibliography. (This recipe has nothing to do with Fuchsia Dunlop, I use it only as an example.) See image previous page, bottom right.

The last step in generating a PDF file from the Latex code is to compile the document. As with the index, a document with a bibliography has to be compiled at least three times. The first time and the third time are standard, the second time compiles the information for the citations and the bibliography. Again, TexStudio is very helpful with a Bibliography (F8) item in the Tools menu. Since compiling a standard document takes very little time, doing this three-step process does not slow down document production very much. If you have made changes to citations or sources, you must do the three-step recompile to update the final PDF. (Of course, if you have changed the indexing items as well, you must also recompile for the index, making this a four-step process in TexStudio.)

Next time, I will show how to make the chapter titles clickable “live links”. Readers will not need to scroll through pages or use PDF Find in order to navigate through your thesis or cookbook or whatever.

issue198/latex.1698501636.txt.gz · Dernière modification : 2023/10/28 16:00 de auntiee