0

I am using natbib and unsrtnat.bst. I want to change FUNCTION {format.chapter.pages} and FUNCTION {format.in.ed.booktitle} in order to get something like this:

page 12-34, chapter 5 in Very nice book

Any suggestions?

2
  • This is quite an odd format. I suppose it can be done, but then what is to happen to the editors (if any)? Is it "pp. 12-34, ch. 5 in Ditor, E: Very nice book" or "pp. 12-34, ch. 5 in Very nice book ed. by E. Ditor"? If you use this for @incolletions only it will be inconsistent with @articles, as these will still have "J. Art. 5(6): 12-34". – moewe Sep 28 '13 at 8:06
  • @moewe It will be the second variant: "pp. 12-34, ch. 5 in Very nice book ed. by E. Ditor" and it will be only for @incollection. I am not concerned @articles, in will stay as it is now. – alchemist_ bg Sep 28 '13 at 8:48
2

This can actually be done with natbib and bibtex, though quite some attention has to be paid to getting the capitalisation right.

You will have to modify unstrnat.bst, so find it, copy it to a location LaTeX can find it and rename it to, say, myunsrtnat.bst.

Open myunsrtnat.bst.

Find FUNCTION {format.chapter.pages} and replace it with

FUNCTION {format.chapter.pages}
{ chapter empty$
    'format.pages.incoll
    { type empty$
        { "Chapter" }%<--- that is changed
        { type "l" change.case$ }
      if$
      chapter tie.or.space.connect
      pages empty$
        'skip$
        { ", " * format.pages.incoll * }%<--- changed call to format.pages.incoll
      if$
    }
  if$
}

Then add the following to the file

FUNCTION {format.pages.incoll}
{ pages empty$
    { "" }
    { pages multi.page.check
        { chapter empty$
            { "Page" }
            { "page" }
          if$
          pages n.dashify tie.or.space.connect }
        { chapter empty$
            { "Pages" }
            { "pages" }
          if$
          pages tie.or.space.connect }
      if$
    }
  if$
}

Find FUNCTION {format.in.ed.booktitle} and replace it with

FUNCTION {format.in.ed.booktitle}
{ booktitle empty$
    { "" }
    { pages empty$ %<----------- this conditional is new
        { chapter empty$
            { "In " }
            { "in " }
          if$ }
        { "in " }
      if$%<--------------------- here it stops
      editor empty$
        { booktitle emphasize * }%<--- no "in" anymore
        { format.editors * ", " * booktitle emphasize * }%<--- no "in" anymore
      if$
    }
  if$
}

Find FUNCTION {inbook} it contains the following lines

format.bvolume output
format.chapter.pages "chapter and pages" output.check
new.block

change them to

format.chapter.pages "chapter and pages" output.check
format.bvolume output
new.block

Finally, the same for FUNCTION {incollection}; you will find

  format.in.ed.booktitle "booktitle" output.check
  format.bvolume output
  format.number.series output
  format.chapter.pages output
  new.sentence

replace that with

  format.chapter.pages output
  format.in.ed.booktitle "booktitle" output.check
  format.bvolume output
  format.number.series output
  new.sentence

In your document, use \bibliographystyle{myunsrtnat} instead of \bibliographystyle{unsrtnat}.

The MWE

\documentclass{article}
\usepackage{natbib}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{testbook,
  author        = {Walter Ordsmith},
  title         = {The Work},
  subtitle      = {Subtitle},
  year          = {1983},
  publisher     = {P. Ublisher \& Co.},
  address       = {Townsville},
}
@article{testart1,
  author  = {Steven C. Ientist},
  title   = {Thrilling, Intelligent and True Limes of Erudition},
  journal = {Journal of Articles},
  volume  = {20},
  number  = {3},
  year    = {1935},
  pages   = {1--46},
}
@incollection{ordChap1,
  author     = {Walter Ordsmith},
  title      = {A Chapter},
  booktitle  = {The Second Work},
  publisher  = {Academic Press},
  year       = {1977},
  pages      = {12--34},
  chapter    = {2},
}
@incollection{ordChap2,
  author     = {Walter Ordsmith},
  title      = {A Chapter},
  booktitle  = {The Second Work},
  publisher  = {Academic Press},
  year       = {1977},
  pages      = {12--34},
}
@incollection{ordChap3,
  author     = {Walter Ordsmith},
  title      = {A Chapter},
  booktitle  = {The Second Work},
  publisher  = {Academic Press},
  year       = {1977},
}
\end{filecontents*}

\begin{document}
\nocite{*}
\bibliographystyle{myunsrtnat}
\bibliography{\jobname}
\end{document}

gives

enter image description here

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.