1

I'm working out how to edit a .bst-file to customise a bibliography. I have made a number of changes, but I am struggling to work out how to add "Vol." to the reference before my volume. As you can see, I have edited the standard plainnat.bst below to as 'no.' before number and 'p.' before page, but this was just through trial and error and a good guess based on what was showing.

 FUNCTION {format.vol.num.pages}
{ volume field.or.null
  number empty$
     'skip$
    { "\penalty0 \ no. " number * "," * *
       volume empty$
        { "there's a number but no volume in " cite$ * warning$ }
        'skip$
      if$
    }
   if$
   pages empty$
    'skip$
    { duplicate$ empty$
        { pop$ format.pages }
       { "\penalty0 \ p. " * pages n.dashify * }
     if$
    }
  if$
}

Please can someone advice on what changes to make to add "vol." before my volume number.

4
  • 1
    Maybe not applicable, but I find it a lot easier to customize biblatex macros than BibTeX styles. So you could consider switching to biblatex if possible. – Paapaa Jul 24 '16 at 18:51
  • Thank you for the suggestion. For next time, I may consider learning that. However I am 48hrs off of my deadline and this is the last problem with my plainnat file, so I am going to just get this done this way! – Matthew Rickard Jul 24 '16 at 18:53
  • I can't test it and am not so firm in .bst language, but does "Vol.~" volume field.or.null * or "Vol.~" * volume field.or.null help? – moewe Jul 24 '16 at 19:00
  • Thanks moewe, that worked for me. If you make that an answer I will mark it as having worked for me. – Matthew Rickard Jul 24 '16 at 19:26
2

The naive method

"Vol.~" volume field.or.null *

seems to work. This does no checking as to whether the volume field is empty or not.

If you want checking, try

volume empty$
  { "" }
  { "Vol.~" volume field.or.null * }
if$
2
  • It works, although I am now finding the problem of one reference having no value in Vol, but as this is online only I will switch the reference type to a URL – Matthew Rickard Jul 25 '16 at 19:34
  • @MatthewRickard Mhh, yes I couldn't get a check for the empty field to work that quickly, but check the update it should work now. Normally it is very safe to assume that an @article does have a volume field. If your @article doesn't have a volume chances are very high it isn't actually an @article. – moewe Jul 26 '16 at 7:56
0

I do not currently have a computer with LaTeX available, but as you are in a hurry, I'll give it a shot, hoping I remember the fairly arcane .bst-syntax well enough. I think this should do the trick for you:

FUNCTION {format.vol.num.pages}
{ volume field.or.null
  volume empty$
    'skip$
    { "Vol. " *  }
  if$number empty$
     'skip$
    { "\penalty0 \ no. " number * "," * *
       volume empty$
        { "there's a number but no volume in " cite$ * warning$ }
        'skip$
      if$
    }
   if$
pages empty$
 'skip$
 { duplicate$ empty$
     { pop$ format.pages }
    { "\penalty0 \ p. " * pages n.dashify * }
      if$
    }
  if$
}

Let me know how far you get with this. I can check back here on my phone or tablet, and I should be back at my computer in a few hours.

2
  • I am afraid this hasn't worked. Now I get the errors when compiling the bibtex: ---the literal stack isn't empty for entry Vidal-Madjar:2003aa while executing---line 1438 of file plainnat.bst '105' is a function literal, not a string or missing field, for entry 1538-4357-604-1-L69 while executing---line 1438 of file plainnat.bst skip$' is a function literal, not a string, for entry 1538-4357-604-1-L69 while executing---line 1438 of file plainnat.bst – Matthew Rickard Jul 24 '16 at 19:23
  • User Moewe gave a suggestion that worked, but gave it as a comment so I can't mark it as an answer that worked for me. – Matthew Rickard Jul 24 '16 at 19:24

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.