2

I have to use a journal template with a .bst file to format my references, but my .bib file contains entries that are not recognized since I usually use biblatex, so I have no background using natbib. However, going through the .bst file I found some functions that seem to define some type of reference, for like a @www:

FUNCTION {www}
{ output.bibitem
  format.authors "author" output.checkwoa
  new.block
  format.title "title" output.check
  new.block
  format.website "url" output.check
  format.eprint output
  new.block
  note output
  formatfull.doi output
  fin.entry
} 

Therefore, my question is how can I identify all the @ types defined in the .bst?

The only information I found was in this related question, and I already skim through the Tame the BeaST book.

JackOA
  • 31
  • 3
    Hopefully it comes with documentation that lists the types, otherwise I think there must be a FUNCTION as you show for each type, but some FUNCTIONS are internal helpers. By convention the functions for document types have output.bibitem but that is just by convention not a reserved function name – David Carlisle Oct 18 '22 at 18:56
  • "Going through the bst file" -- which bst file? What's its name? Please be explicit. – Mico Oct 18 '22 at 21:06
  • If a given entry type isn't defined in the bst file, BibTeX will use @misc as the fallback entry type. – Mico Oct 18 '22 at 21:07
  • @Mico usually but only if the bst has FUNCTION { default.type } { misc } – David Carlisle Oct 18 '22 at 21:59
  • @DavidCarlisle - Happily, all bst files I've come across so far possess just such a function. :-) – Mico Oct 18 '22 at 22:02
  • 1
    @Mico yes but I interpreted the question as "in general, how do you determine the types a style accepts" I think the general answer is "read the source and figure it out" ... – David Carlisle Oct 18 '22 at 22:05
  • @Mico I have updated the question to a link to where the template, containing the mdpi.bst file, can be downloaded. I did not think the rest of the file will be relevant. – JackOA Oct 19 '22 at 12:02
  • @DavidCarlisle - Exactly, the problem is in identifying the FUNCTIONS which are not just internal helpers, since unfortunately it did not come with documentation for the types. Your point about the functions containing the output.bibitem could be a valid solution, for a lack of a better one not relying on conventions. @Mico answer also rely on conventions, but there are more helper functions after the FUNCTION {article} so IMHO is not as reliable. – JackOA Oct 19 '22 at 12:11
  • @JackOA - Sorry to have to break the bad news to you, but your expectations as to what kind of documentation or information may be retrievable from bst files seem to be quite unrealistic. For better or worse (likely: worse), BibTeX (the programming language) imposes very few structural contstraints on how bst files have to be organized. I thoroughly sympathize with your desire for "reliability"; sadly, your quest may be doomed from the outset. – Mico Oct 19 '22 at 14:00

2 Answers2

4

Unless you're working with a bst file for which some helpful documentation exists that lists all available entry types, you'll have to look at the bst file and, specifically, check which FUNCTIONs define entry-type variables. E.g., if you're on a Unix or MacOS system, you could open a command window, switch to the directory that contains your bst file -- let's call it aaa.bst -- and type the following command at the command prompt:

cat aaa.bst | grep "FUNCTION {"

All lines of code that contain the string FUNCTION { will be listed.

For the file plainnat.bst, a total of roughly 90 lines will be output. The relevant results will start with the line FUNCTION {article}:

FUNCTION {article}
FUNCTION {book}
FUNCTION {booklet}
FUNCTION {inbook}
FUNCTION {incollection}
FUNCTION {inproceedings}
FUNCTION {conference} { inproceedings }
FUNCTION {manual}
FUNCTION {mastersthesis}
FUNCTION {misc}
FUNCTION {phdthesis}
FUNCTION {proceedings}
FUNCTION {techreport}
FUNCTION {unpublished}
FUNCTION {default.type} { misc }

On the other hand, the file apacite6.bst yields about 220 [!] grep search results, and the relevant ones for our purpose again start with the line FUNCTION {article}:

FUNCTION {periodical}
FUNCTION {article}
FUNCTION {magazine}
FUNCTION {newspaper}
FUNCTION {book}
FUNCTION {incollection}
FUNCTION {techreport}
FUNCTION {intechreport}
FUNCTION {lecture}
FUNCTION {thesis}
FUNCTION {phdthesis}
FUNCTION {mastersthesis}
FUNCTION {unpublished}
FUNCTION {misc}
FUNCTION {literal}
FUNCTION {manual}
FUNCTION {booklet}
FUNCTION {inbook}
FUNCTION {inproceedings}
FUNCTION {conference}
FUNCTION {proceedings}
FUNCTION {default.type} { misc }

Incidentally, all bst files I've ever encountered contain the function default.type as well as something that makes default.type a conduit to the @misc entry type.

Mico
  • 506,678
  • 1
    Cat abuse! :-) grep "FUNCTION" aaa.bst – egreg Oct 19 '22 at 07:25
  • @egreg - Yeah, I'll admit that my Unix shell command skills have atrophied over the years. In (admittedly lame) defense, my use case (to extract the FUNCTION instances) involved two steps -- first, kpsewhich plainnat.bst (to make sure I was going after the intended file), and second cat \!!` | grep "FUNCTION"` (to extract the sought-after lines). I guess I should have simplified this to avoid the impression of commiting cat abuse... – Mico Oct 19 '22 at 10:55
  • 2
    Let's save more kittens: grep "FUNCTION" $(kpsewhich plainnat.bst) – egreg Oct 19 '22 at 11:48
1

As @Mico points out, there are no explicit constraints or structures in a .bst (BibTeX Style Document) that can be used to automatically identify the document types @ defined.

So if you are like me and have no helpful documentation, all you can do is look at the .bst file internals and hope they have followed one of this two conventions:

  • From @DavidCarlisle comment, you can find all the FUNCTIONs that contain a output.bibitem and assume those FUNCTION names can be used with a leading @ to define document types. This worked wonders in my case.
  • From @Mico answer, you can find the FUNCTION {article} and assume the next FUNCTIONS are used to define document types. This didn't fully work, since after some number of FUNCTIONs they were back to being regular helper functions. Then I had to guess, based on the FUNCTION name, or test them manually to check if they could be used to define document types.
JackOA
  • 31