1

I'm using the unsrt.bst bib style and wish to modify it so that in the output it starts with what the type of entry was:

[1] BOOK: A. N. Other etc...

[2] ARTICLE: A. N. Other etc....

But I break the .bst file no matter there I put a "BOOK: " entry. Any ideas? I only use a small subset of the types of citation so could easily just amend the .bst case by case instead of a in a general way. If I knew how.

3

For unsrt.bst the following recipe works.

  1. Locate unsrt.bst on your machine. You can do this by typing kpsewhich unsrt.bst into the command line/terminal. Alternatively, obtain a copy of the file from CTAN http://mirrors.ctan.org/biblio/bibtex/base/unsrt.bst

  2. Copy the file to a location where TeX can find it. The document directory will do fine. See also https://texfaq.org/FAQ-inst-wlcf

  3. Rename the file to unsrt-typed.bst, say (the license of unsrt.bst requires you to change the name if you modify the file)

  4. Find FUNCTION {output.bibitem} (ll. 85-93) and replace the complete function definition with

    FUNCTION {output.bibitem}
    { newline$
      "\bibitem{" write$
      cite$ write$
      "}" write$
      newline$
      type$ "u" change.case$ ":" * write$
      newline$
      ""
      before.all 'output.state :=
    }
    

    That is, add the two lines

      type$ "u" change.case$ ":" * write$
      newline$
    

    Note that the "u" change.case$ gives us the ALL CAPS, if you wanted all-lower case you'd just say

      type$ ":" * write$
    

    If you wanted to apply a LaTeX macro, you'd say

      "\textbf{" type$ * "}:" * write$
    
  5. Add a comment with your name, the current date and a short description of the changes to the top of the file.

  6. Use \bibliographystyle{unsrt-typed} instead of \bibliographystyle{unsrt} in your document.

As alternative for steps 1 to 5 you can obtain the patched version of the file at https://gist.github.com/moewew/e0c609d7162524a9f82d74cff14bdc61

Then

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

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{sigfridsson,
  author  = {Sigfridsson, Emma and Ryde, Ulf},
  title   = {Comparison of methods for deriving atomic charges from the
             electrostatic potential and moments},
  journal = {Journal of Computational Chemistry},
  year    = 1998,
  volume  = 19,
  number  = 4,
  pages   = {377-395},
  doi     = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}
@book{nussbaum,
  author    = {Nussbaum, Martha},
  title     = {Aristotle's \enquote{De Motu Animalium}},
  year      = 1978,
  publisher = {Princeton University Press},
  address   = {Princeton},
}
@phdthesis{geer,
  author  = {de Geer, Ingrid},
  title   = {Earl, Saint, Bishop, Skald~-- and Music:
             The {Orkney Earldom} of the Twelfth Century.
             {A} Musicological Study},
  school  = {Uppsala Universitet},
  year    = 1985,
  address = {Uppsala},
}
\end{filecontents}


\begin{document}
\cite{sigfridsson,nussbaum,geer}
\bibliographystyle{unsrt-typed}
\bibliography{\jobname}
\end{document}

produces

Bibliography with entry type in ALL CAPS: e.g. "ARTICLE: Emma Sigfridsson and Ulf Ryde. Comparison of methods for deriving atomic charges from the electrostatic potential and moments. Journal of Computational Chemistry, 19(4):377–395, 1998."


A more naive approach would be adding

"<TYPE>: " write$

after output.bibitem in each type FUNCTION.

The article function would then read

FUNCTION {article}
{ output.bibitem
  "ARTICLE: " write$
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { journal emphasize "journal" output.check
      format.vol.num.pages output
      format.date "year" output.check
    }
    { format.article.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  note output
  fin.entry
}

But obviously that is more work. See https://gist.github.com/moewew/e7e53020544f16d3db619ca8b33f1896. On the plus side you are more flexible in the output since you don't have to rely on type$, which will only give you the formal BibTeX entry type. (article where one might want to say "Journal article" etc.)


Of course with biblatex those sort of things don't need manipulation of .bst files: How to label bibliography items, books and articles and others?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.