4

In https://www.sharelatex.com/learn/Bibliography_management_with_bibtex

There was an example of using Bibilography:

\begin{thebibliography}{9}
\bibitem{latexcompanion} 
Michel Goossens, Frank Mittelbach, and Alexander Samarin. 
\textit{The \LaTeX\ Companion}. 
Addison-Wesley, Reading, Massachusetts, 1993.

\bibitem{einstein} 
Albert Einstein. 
\textit{Zur Elektrodynamik bewegter K{\"o}rper}. (German) 
[\textit{On the electrodynamics of moving bodies}]. 
Annalen der Physik, 322(10):891–921, 1905.

\bibitem{knuthwebsite} 
Knuth: Computers and Typesetting,
\\\texttt{http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html}
\end{thebibliography}

What does {9} do here? As explained in the article: A parameter inside braces, 9 in the example, indicates the number of entries to be added; this parameter can not be greater than 99.

However, in a previous document with over 50 citations/entries. I only needed to do {1} and not {50}. Can someone solve this contradiction to me?

  • 1
    It defines the width reserved for the label. The number itself does not matter, if you put xxx it will reserve the width of xxx. 9 is often used because in most fonts it is one of the widest digits. If you would us 1 this could reserve not enough room if 1 is smaller than 9 in the font you use. – samcarter_is_at_topanswers.xyz Sep 05 '18 at 14:11
  • 1
    So a good rule of thumb: if you have <10 entries use 9, If you have <100 entries use 99 etc. – samcarter_is_at_topanswers.xyz Sep 05 '18 at 14:14
  • @samcarter Hi, sorry I don't quite understand what you meant by "width" reserved for the label. – Shamisen Expert Sep 05 '18 at 14:15
  • 1
    In particular the number there should be the longest label number (really just in terms of width when printed) that you have in your bibliography. Since most digits are about the same width (ignoring the 1) using 9s to pad the number is a common practice. You say 9 if you have at most nine entries, 99 if you have 10 to 99 entries (i.e. double-digits) etc. – moewe Sep 05 '18 at 14:16
  • Carefully compare the output in your example when you change \begin{thebibliography}{9} to \begin{thebibliography}{} and then to \begin{thebibliography}{99999} – moewe Sep 05 '18 at 14:17
  • @moewe Just to clarify, "number of entries" is the same as "number of citations" right? – Shamisen Expert Sep 05 '18 at 14:17
  • 1
    @Hendrix Number of entries = number of different citations (you can cite one thing more than once) – samcarter_is_at_topanswers.xyz Sep 05 '18 at 14:18
  • 1
    Ah yes. I mean the number of references in your bibliography. Technically speaking this is not about the number (as in counting) of items, it is about the label numbers that are shown in front of the entries. Note that "this parameter can not be greater than 99" is wrong. You can easily write 999999999999999. – moewe Sep 05 '18 at 14:18
  • 1
    @Hendrix Totally off-topic: Using the url or hyperref package could make it easier for you to write web addresses. – samcarter_is_at_topanswers.xyz Sep 05 '18 at 14:21

1 Answers1

6

The argument to thebibliography should hold the longest label (in terms of width when typeset) in your bibliography list. LaTeX needs to know the the width of the longest label to be able to indent the list properly so that several lines of the same entry align.

Compare

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{hyperref}

\begin{document}
\begin{thebibliography}{9}
\bibitem{latexcompanion} 
Michel Goossens, Frank Mittelbach, and Alexander Samarin. 
\textit{The \LaTeX\ Companion}. 
Addison-Wesley, Reading, Massachusetts, 1993.

\bibitem{einstein} 
Albert Einstein. 
\textit{Zur Elektrodynamik bewegter K{\"o}rper}. (German) 
[\textit{On the electrodynamics of moving bodies}]. 
Annalen der Physik, 322(10):891–921, 1905.

\bibitem{knuthwebsite} 
Knuth: Computers and Typesetting,
\\\url{http://www-cs-faculty.stanford.edu/\~uno/abcde.html}
\end{thebibliography}
\end{document}

enter image description here

with the same example using an empty argument

\begin{thebibliography}{}

enter image description here

and a ridiculously large

\begin{thebibliography}{999}

enter image description here

You will note that in the second picture subsequent lines start just a tad too far on the left so that they are not aligned with the first line. This is because LaTeX has reserved too little space for the labels, causing the first line to be start further to the right compared to the following lines.

In the third picture the lines are aligned, but the labels are unnecessarily pushed to the right (compare the relative position to the heading "References"). Here LaTeX has reserved too much space.

The argument need not be numeric (and should not be numeric for alphabetic citation styles). In fact it can be anything as long as LaTeX can typeset it.

The common practice of putting 9 or 99 can be explained by the fact that in the default font all digits have the same width, so it does not really matter if you put 8 or 9, only the number of digits matters. So you put 9 if you have no more than 9 entries in your bibliography and you would put 99 if you have 10 or more, but less than 100. Things are more subtle if you use a font with variable-width digit. Compile the examples with \usepackage{ebgaramond} and try different values between 1 and 9.

The rule of thumb won't be sufficient, however, if you use non-numeric citation labels, in that case you really need to identify the longest label manually.

The quoted passage from https://www.sharelatex.com/learn/Bibliography_management_with_bibtex

A parameter inside braces, 9 in the example, indicates the number of entries to be added; this parameter can not be greater than 99.

is incorrect. Neither does the argument indicate the number of entries (or maximum number of entries) nor is it restricted to a maximum value of 99. It is just a coincidence that the label number of the last entry, which is also the total number of entries when numbering starts at 1, is usually a good candidate for the longest label.

Luckily you will not have to worry about these things if you use BibTeX or biblatex. If you use the automatic approaches to build your bibliography they can figure out the longest label for you.

moewe
  • 175,683