1

I'm editing the bibliography style "unsortnat" to satisfy a conference requirements.

The ask me to put at the end of the citation the volume and pages, after the year like :

S. Adhikari, M. I. Friswell, D. J. Inman. Piezoelectric energy harvesting from broadband random vibrations. Volume 18, pp. 115005.

Editing the bst file in the function

FUNCTION {format.vol.num.pages}
    { volume field.or.null
  number empty$
    'skip$
    { "{\ 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 }
    { ",~pp.~" * pages n.dashify * }
      if$
    }
  if$
}

I get this:

S. Adhikari, M. I. Friswell, D. J. Inman. Piezoelectric energy harvesting from broadband random vibrations. 18, pp. 115005.

the desired output but without the word "volume" which I don't know how to add it in the bst modification.

Any help will be appreciated it.

1 Answer 1

2

I presume you mean you are modifying unsrtnat.bst. In any case you need to rewrite the function a little to add this string because the first line

 volume field.or.null

immediately puts the volume number on to the stack when it is non null. Here is one suggestion of how to rewrite:

FUNCTION {format.vol.num.pages}
{ volume empty$
  { number empty$
      { "" }
      { "\penalty0 (" number * ")" * *
        "there's a number but no volume in " cite$ * warning$
      }
    if$
  }
  { "Volume " volume *
    number empty$
      'skip$
      { "\penalty0 (" number * ")" * * }
    if$
  }
  if$
  pages empty$
    'skip$
    { duplicate$ empty$
        { pop$ format.pages }
        { ":\penalty0 " * pages n.dashify * }
      if$
    }
  if$
}

The logic is that we

  • test whether volume is empty
    • if so test whether number is empty
      • if it is add a null string to the stack
      • otherwise provide the number information in brackets and warn that there is no volume number
    • if volume is not empty, print "Volume " and the volume number and then do a similar check on whether the number is non-empty or not, this time no warning is necessary.
    • thereafter proceed as before with the page information.

Calling the resulting file myunsrtnat.bst and using the standard xampl.bst contained in tex distributions, this gives

Sample output

\documentclass{article}

\usepackage{natbib}

\begin{document}

\citet{article-minimal,article-full,whole-collection}

\bibliographystyle{myunsrtnat}
\bibliography{xampl}

\end{document}

The first entry is an article without volume or number information, the second is a full detailed article, the third is another entry of a different type without these fields.

The \pentalys are from a recent version of unsrtnat.bst.

1
  • That worked! Amazing reply. Thanks very much!
    – Ger
    Aug 10, 2016 at 12:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .
https://tex.stackexchange.com/questions/320432/add-word-volume-to-a-custom-bst
tex.stackexchange.com
CC-MAIN-2024-10
139302
application/http; msgtype=response
sha1:27Y3GGMCDDCWDWVEOXEY6SNEWLM4ENSF
<urn:uuid:becad58b-6ee1-4ef5-bd7a-2cb29e4baf85>
2024-02-24T23:49:59Z
172.64.144.30
text/html
sha1:RGARYCMSB7ZPRPGR2M7TLIZZX5Q3D3HP
<urn:uuid:1e8e196c-e190-4903-ad35-3d69f9dc52f9>
https://tex.stackexchange.com/questions/320432/add-word-volume-to-a-custom-bst
response
<urn:uuid:1a95f3a7-87df-460c-90df-2f1910510a91>
isPartOf: CC-MAIN-2024-10
publisher: Common Crawl
description: Wide crawl of the web for February/March 2024
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-78
software: Apache Nutch 1.19 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.5-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/