1

In a series of posts (see [1], [2], and [3]) I asked how one can create one's own bibliography style.

Now, I would like to understand how I can abbreviate the journal names cleverly. I'm using a reference management software, i.e., Bibdesk, which saves the complete name of the journal, e.g. Physical Review A. But, one should use most of the time the abbreviated form of the journal names. In this case: Phys. Rev. A.

Question is: how can I integrate this in my own bibliography style (which I learned in the previous posts how to make it)?

Astrolabe
  • 265
  • 2
    This is usually implemented with a journal.abbrev function which is basically one big set of nested if$ statements. See e.g. the ACM-Reference-Format.bst for an example. – Alan Munn Jun 22 '20 at 22:35
  • Sorry, I didn't get how I can integrate this into my own bib style. – Astrolabe Jun 24 '20 at 13:14
  • Related/Duplicate? https://tex.stackexchange.com/questions/111724/is-there-a-transparent-way-to-automatically-abbreviate-journal-names – Steven B. Segletes Jun 24 '20 at 16:07
  • 1
    @StevenB.Segletes Not a duplicate: that shows how to allow abbreviations in the .bib file to expand to fuller (possibly abbreviated) names. This question asks how to abbreviate long names themselves. – Alan Munn Jun 24 '20 at 16:25
  • @AlanMunn That doesn't seem clear to me from the question. So, you are saying that the desire is to be presented with a full journal name and have the software generate the abbreviation? – Steven B. Segletes Jun 24 '20 at 16:28
  • @StevenB.Segletes that seems to be what the question says. – Alan Munn Jun 24 '20 at 16:31
  • @AlanMunn You're right! – Astrolabe Jun 25 '20 at 18:06

1 Answers1

1

The basic technique for implementing journal abbreviations is a function containing a big list of nested if$ statements with each if$ corresponding to a pair of full journal names and their corresponding abbreviation. Here's an example of a function that abbreviates two journal names. Notice that for each long journal name there may be multiple versions based on what the input field may be in your .bib file. For example, \& and and are both possible in the first journal name, and IPA, {IPA}, and International Phonetic Association are possible for the second journal name.

This function must appear before any function that calls it, so it must precede both the article function and the format.article.crossref function.

FUNCTION { journal.abbrev } {
      journal   "Natural Language and Linguistic Theory" = { "NLLT" } 
       { journal "Natural Language \& Linguistic Theory" = { "NLLT" }
          { journal "Journal of the International Phonetic Association" = { "Jour. IPA" }
            { journal "Journal of the {IPA}" = { "Jour. IPA" }
               { journal "Journal of the IPA" = { "Jour. IPA" }
                  { journal }  if$ } if$ } if$ } if$} if$}

Now we use this function to pass to the article function for the journal title formatting (the following adapted from the alpha.bst which is your base) instead of just passing journal.

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { journal.abbrev 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
}

Since this style oddly also allows crossref links to articles you also need to change that function:

FUNCTION {format.article.crossref}
{ key empty$
    { journal empty$
        { "need key or journal for " cite$ * " to crossref " * crossref *
          warning$
          ""
        }
        { "In {\em " journal.abbrev * "\/}" * }
      if$
    }
    { "In " key * }
  if$
  " \cite{" * crossref * "}" *
}

To remove the , that appears after the journal title requires some extra work.

First we need to add an extra flag for the state of being after a journal title, we first add this to the list of integer variables:

INTEGERS { output.state before.all mid.sentence after.sentence after.block after.journal }

then assign it a value:

FUNCTION {init.state.consts}
{ #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
  #4 'after.journal :=
}

Now we modify the output.nonnull function to check for after.journal:

FUNCTION {output.nonnull}
{ 's :=
output.state after.journal =
 {" " * write$ }
 {
  output.state mid.sentence =
    { ", " * write$ }
    { output.state after.block =
        { add.period$ write$
          newline$
          "\newblock " write$
        }
        { output.state before.all =
            'write$
            { add.period$ " " * write$ }
          if$
        }
      if$
      mid.sentence 'output.state :=
    }
  if$
}
if$
  s
}

Finally we change the article function to set the state to after.journal.

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { after.journal 'output.state :=
      journal.abbrev 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
}

Sample document (the modified .bst file I've named alpha-abbrv.bst).

\documentclass{article}
\begin{filecontents}{\jobname.bib}

@article{Boeckx2001scope, Author = {Boeckx, Cedric}, Journal = {Natural Language and Linguistic Theory}, Number = {3}, Pages = {503--548}, Title = {Scope reconstruction and {A}-movement}, Volume = {19}, Year = {2001}}

@article{MayrDavies2011, Author = {Mayr, Robert and Davies, Hannah}, Journal = {Journal of the International Phonetic Association}, Number = {1}, Pages = {1--25}, Title = {A cross-dialectal acoustic study of the monophthongs and diphthongs of {Welsh}}, Volume = {41}, Year = {2011}}

@article{AounChoueiri2000, Author = {Joseph Aoun and Lisa Choueiri}, Journal = {Natural Language & Linguistic Theory}, Pages = {1--39}, Title = {Epithets}, Volume = {18}, Year = {2000}} \end{filecontents} \bibliographystyle{alpha-abbrv} \begin{document} \cite{MayrDavies2011,AounChoueiri2000,Boeckx2001scope} \bibliography{\jobname} \end{document}

enter image description here

Alan Munn
  • 218,180
  • Great answer! How can I get rid of the comma after the abbreviation? – Astrolabe Jun 25 '20 at 18:11
  • I ask this because the abbreviations I used end up with a dot. This is sufficient. The comma is then not needed. – Astrolabe Jun 25 '20 at 18:21
  • @Astrolabe I've updated the answer. – Alan Munn Jun 25 '20 at 19:15
  • Oh, there is a problem. Because, I tried to replace the dot after the author names by colon in the first link I added in the post. Now, the colon is gone. I played around with that, but I was unsuccessful. – Astrolabe Jun 25 '20 at 20:20
  • @Astrolabe Well that's not surprising since that answer also added an extra flag. So you just need to make sure the two flags have different values: instead of #4 'after.journal := (which is assigned to your 'after.colon variable in your first answer) use #5 'after.journal := instead inside the init.states.consts Remember also that your list of INTEGERS must also include the after.colon variable. I was modifying the alpha.bst, not following all the individual modifications you made in each question. – Alan Munn Jun 25 '20 at 20:31
  • I exactly did so, but it didn't work. I think the problem is in FUNCTION {output.nonnull}, because in link below I changed it accordingly: https://tex.stackexchange.com/questions/550269/customizing-bibliography-style-alpha-while-using-bibtex – Astrolabe Jun 25 '20 at 20:35
  • I need to make FUNCTION {output.nonnull} consistent for two changes at the same time. I'm trying to do so ... – Astrolabe Jun 25 '20 at 20:38
  • @Astrolabe Well it's just a nested if$ statement, so just make sure the nesting is correct. – Alan Munn Jun 25 '20 at 21:29
  • Could you please give an example? I don't get it. – Astrolabe Jun 25 '20 at 21:45
  • @Astrolabe The syntax is A B = { true part} {false part} if$. And inside each false part are the other conditionals, so two would be A B = {true} {C D = {true} {false} if$ } if$, etc. – Alan Munn Jun 25 '20 at 21:53