[Tex/LaTex] BibTeX style which shows annotation fields and employs numeric-style citation call-outs

bibliographiesbibtex

I am relatively new to LaTeX, i have used it for a couple of documents here and there but I am now using it for a formal school report which needs an annotated bibliography.

My current problem is that if I want to have my annotation displayed, the citations keys are now no longers numerical. If I changed my style, my keys are numerical but my annotations are not displayed.

Here is my bibfile.bib:

@MISC{tJung11,
    author = {Jungblut, Thomas},
    title = {Ant Colony Optimization for TSP Problems},
    month = Aug,
    year = {2011},
    howpublished = {url: http://codingwiththomas.blogspot.co.uk/2011/08/ant-colony-optimization-for-tsp.html},
    note = {Accessed: 26-01-2015},
    annotate = {This Blog posted by Thomas Jungblut covers mutliple topics which are of high interest to the projects research.
            The information contained in the blog covers items like capitalising on multi-threading opportunities and how to efficiently do so.
            The underling calculations and evaluation procedures for each agent are also discussed. This is useful for modeling and 
            designing the algorithm itself.}
}

and here is the styling i've tried:

\nocite{*}
\bibliographystyle{annotate}
\bibliography{bibfile}

which produces:

enter image description here

and just a simple plain style:

   \nocite{*}
    \bibliographystyle{annotate}
    \bibliography{bibfile}

which produces this:

enter image description here

i want a combination of the two so the annotation shows and the key is [1] not [Jun11]

I have tried looking on websites such as: http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html but I can't seem to locate a solution.

Does anybody have any suggestions?

Best Answer

If it's the plain bibliography style you wish to modify to enable it to print the contents of the annotate field, you could proceed as follows:

  • Find the file plain.bst in your TeX distribution. Make a copy of this file, calling the copy (say) plainannotate.bst. (Don't edit a file from the TeX distribution directly.)

  • Open the file plainannotate.bst in a text editor. The editor you use to edit your tex files will do fine.

  • First, you have to inform plainannotate that it's supposed to recognize fields named annotate. Near the very top of the file, find the structure named ENTRY. Insert a blank line between "address" and "author", and insert the word "annotate" in the new line.

  • Second, you have to inform the bibliography style (and BibTeX) what to do when it's told to process the contents of the annotate field. Find the definition of the function format.authors (ca. line 215 in my copy of the file). After this function (and before the function format.editors), insert the following lines of code:

    FUNCTION {format.annotate}
    { annotate empty$
        { "" }
        { " \begin{quotation}\noindent "
          annotate
          * " \end{quotation} " *
        }
          if$
    }
    

    In case you're curious what this code does: It first checks if the annotate field is empty. If so, it prints nothing (""). If it's non-empty, a quotation environment is initiated, the contents of the annotate field are written out, and the quotation environment is closed.

  • Third, we have to modify the functions article, book, etc, which process the entries of type @article, @book, etc., and tell them that they're supposed to invoke the newly-created function format.annotate at the end of each entry.

    • Find the function article. (It should start on line 550 or so if you've been following the instructions so far.) After the line that says fin.entry, insert two new lines:

        format.annotate write$
        newline$
      
    • Next, find the function book. (It should be the function that immediately follows article.) Guess what: After its final line, which is again fin.entry, insert two more new lines, with the same contents as for the function article:

        format.annotate write$
        newline$
      
    • Ditto for the function booklet.

    • For most of the remaining entry-formatting functions, viz., inbook, incollection, inproceedings, manual, mastersthesis, phdthesis, proceedings, techreport, and unpublished, just add one extra line after fin.entry, viz.,

        format.annotate write$
      
    • The only entry type that's a bit special is the type @misc, since it's BibTeX's "catch-all" entry type. (Entry types that are not recognized, say because they've been mis-spelled by accident, are automatically treated as being of type @misc.) Find the function misc; it should be between the functions mastersthesis and phdthesis. Note that this function's final two lines are

        fin.entry
        empty.misc.check
      

      (Because @misc is the catch-all entry type, care must be taken if its contents are entirely empty.) In this case, insert the instruction format.annotate write$ on a new blank line between these two lines, like so:

        fin.entry
        format.annotate write$
        empty.misc.check
      
  • Save the file plainannotate.bst, either in the directory where your main tex file is located, or in a directory that's searched by BibTeX. If you choose the latter option, be sure to update the filename database of your TeX distribution.

  • Start using the "new" bibliography style by providing the instruction \bibliographystyle{plainannotate}. Be sure to run LaTeX, BibTeX, and LaTeX twice more to propagate all changes.

Here's an MWE that puts it all together:

enter image description here

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{abcdef.bib}
@MISC{tJung11,
    author = {Jungblut, Thomas},
    title = {Ant Colony Optimization for {TSP} Problems},
    month = Aug,
    year = {2011},
    howpublished = {\url{http://codingwiththomas.blogspot.co.uk/2011/08/ant-colony-optimization-for-tsp.html}},
    note = {Accessed: 26-01-2015},
    annotate = {This Blog posted by Thomas Jungblut covers mutliple topics which are of high interest to the projects research. The information contained in the blog covers items like capitalising on multi-threading opportunities and how to efficiently do so. The underling calculations and evaluation procedures for each agent are also discussed. This is useful for modeling and designing the algorithm itself.}
}
\end{filecontents}
\usepackage[numbers]{natbib}
\bibliographystyle{plainannotate}
\usepackage[hyphens]{url}
\begin{document}
\cite{tJung11}
\bibliography{abcdef}
\end{document}
Related Question