Managing Bibliography and Citation in LaTeX

Includes PGF, TikZ, PSTricks, and platforms/distributions: Kile, TeXstudio, TeXmaker, TeXnicCenter, MiKTeX, LyX
Post Reply
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#1

Managing bibliography and citation is very important for scientific writing with LaTeX. There are numerous ways we can define bibliography style and bibliography entries to characterize and render references and citations in LaTeX. Here, we briefly provide examples on how to switch between two powerful referencing and citation styles.

Numerical Citation

For this type of citation, cite{} will list numbered references [1], [2], [3] and so on, and each reference is cited within the text in a similar manner, i.e., [1], [2], [3], etc.

This referencing and citation style is achieved by using natbib package (natbib can take a number of options) in the preamble and the \bibliographystyle{plain}, usually placed between the beginning and the end of the document, the minimal working example would look like:

  1. %Preamble
  2. \documentclass[11pt,a4paper]{report}
  3. \usepackage[pdfborder= 0 0 0, citecolor=magenta, urlcolor=blue,
  4. linkcolor=red, colorlinks=true, bookmarksopen=true,pdfstartview=FitV, breaklinks=true]{hyperref}
  5. \usepackage[square, sort & compress, comma, numbers, sectionbib]{natbib}
  6. \usepackage{ocgx}
  7. \usepackage{lipsum}
  8. \usepackage{media9}
  9.  
  10. \begin{document}
  11. \bibliographystyle{plain}
  12. \bibliography{paperX}
  13. \citeindextrue
  14. \newcommand{\inprep}{in preparation}
  15. \newcommand{\submitted}{submitted}
  16. \end{document}


Author-Year citation

To use bibliography system with Author-year citation replace [options]{natbib} and \bibliographystyle{plain}, respectively, with [round]{natbib} and \bibliographystyle{plainnat}. After switching, always delete .aux and .bbl files, and run LaTeX to compile and update the reference database, otherwise you may encounter errors. If using PDFLaTeX, run/compile files in the order pdflatex -> bibtex -> pdflatex -> pdflatex. If using biblatex in this manner,

  1. \usepackage{biblatex}
  2. \addbibresource{bibfilename.bib}% or \bibliography{bibfilename}
  3. %
  4. %
  5. ....
  6. \printbibliography


run files in the order pdflatex -> biber -> pdflatex -> pdflatex.

You can then use \cite, \citep, \citet , \citet* and \citep* to call and cite references from the .bib file. As an example, \citep will produce (Author et al., year) and \cite will produce Author et al. (year), see more usage.

It also happens that some references are very long because they contain so many authors, and you would like to shorten them, in order to do so, for example with \bibliographystyle{plain}:

-First, find the file plain.bst on your system, make a copy of this file and rename the copy, say, plain.bst. Avoid editing a system file directly, because if something goes wrong, you will not have a back up.

-Open the file plain.bst using your favorite text editor, and find the function format.names, and locate the following two lines in this function:

  1.  nameptr #1 >
  2.             { namesleft #1 >


-Assuming that you want to print out only the first four author names whenever the reference entry has more than six authors, replace these two lines with

  1. nameptr #1 >
  2.              {
  3.               nameptr #4
  4.               #1 + =
  5.               numnames #6
  6.               > and
  7.                 { "others" 't :=
  8.                  #1 'namesleft := }
  9.                 'skip$
  10.              if$
  11.              namesleft #1 >


This means the first line remains unchanged, but the second line should be replaced with several new lines of code, in this case 10 lines. This is the beauty of open sources, hack it to suit your needs.

Finally, save the file plain.bst. Depending on your TeX file system and on where you saved the file, you may need to update by rebuilding TeX's filename database so that BibTeX can find the modified file. Start using the new bibliography style by issuing the instruction \bibliographystyle{plain}. This modification has been tested for unsrt85, plain and plainnat bibliography styles. See here for more options.
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
User avatar
Eli
Senior Expert Member
Reactions: 183
Posts: 5334
Joined: 9 years ago
Location: Tanzania
Has thanked: 75 times
Been thanked: 88 times
Contact:

#2

Instead of inserting the bibliography at the end of the whole work, "chapterbib" can be used to mange multiple bibliographies in a document, for example, if one wants to include bibliography at the end of each chapter: https://www.ctan.org/pkg/chapterbib
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
Post Reply

Return to “LaTeX and MathJax”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests