[Tex/LaTex] Adding impact factor information into apalike.bst

apa-stylebibtex

I am trying to add impact factor information into the apalike.bst. So far, I changed the apalike.bst as follows

Firstly, I added impact_factor into the ENTRY section and created a new function

FUNCTION {format.impactFactor}
{ 
impact_factor empty$
    { "" }
    {"( Impact Factor:" impact_factor ")"}
  if$
}

This function is then called from the article function

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  author format.key output              
  output.year.check                 
  new.block
  format.title "title" output.check
  new.block
  crossref missing$
    { journal emphasize "journal" output.check
      format.vol.num.pages output
    }
    { format.article.crossref output.nonnull
      format.pages output
    }
  if$
  format.impactFactor output              % <---- the new filed
  new.block  
  note output
  fin.entry  
}

I get the following error message when trying to compile it using bibtex and a valid bib file

This is BibTeX, Version 0.99d (MiKTeX 2.9 64-bit)
The top-level auxiliary file: apubs.aux
The style file: apalike_custom.bst
Database file #1: JanS.bib
ptr=2, stack=
( Impact Factor:
45(1):205--212
---the literal stack isn't empty for entry ferkl2010ceiling
while executing---line 1104 of file apalike_custom.bst
(There was 1 error message)

Best Answer

You want the function to output one string, so you have to concatenate them:

FUNCTION {format.impactFactor}
{ 
impact_factor empty$
    { "" }
    {"( Impact Factor:" impact_factor * ")" *}
  if$
}