[Tex/LaTex] Babelbib: combine bababbrv-lf and babunsrt-lf

bibliographiesbibtexsorting

I am using babelbib in order to generate my bibliography. However, it won't satisfy all my needs. I just want the entrys to be formatted like

[1] Knuth, D. and Torvalds, L.: We didn't write anything together etc.

[2] Abraham, A. and Barbara, B.: Our entry is not at the first place

So it has to fulfill:

  • Order items as they appear within the text (and use numbers)
  • Abbreviate names
  • Names must all be in the order of "lastname, firstname"

I was using either

\bibliographystyle{bababbrv-lf}

\bibliographystyle{babunsrt-lf}

Each one only achieves 2 of the 3 points above. How can I get the whole thing to work? Below, you see a minimal working example, compiled with

pdflatex mwe.tex
bibtex mwe
pdflatex mwe.tex
pdflatex mwe.tex
pdflatex mwe.tex

mwe.tex


\documentclass[a4paper]{scrbook}

\usepackage[ngerman]{babel}
\usepackage{babelbib}

\begin{document}
    \chapter{One}
    Once, Lastname1 Firstname1 wrote a story~\cite{randomGuyStory}. And so did Derpina Derp~\cite{randomDerpinaStory}.
    \backmatter
    \bibliographystyle{babunsrt-lf}
%    \bibliographystyle{bababbrv-lf}
    \bibliography{mwebib}
\end{document}

mwebib.bib


@article{randomDerpinaStory,
  title={The Story of tl;dr},
  author={Derp, Derpina and Herp, Herpington},
  journal={Journal of Sunday-workers},
  volume={284},
  number={46},
  pages={31548--31554},
}
@MASTERSTHESIS{randomGuyStory,
    author = {Lastname1, Firstname1 and Lastname2, Firstname2 and Lastname3, Firstname3},
    title = {Cool Story Bro},
    school = {Random University},
    year = {2012}
}

Best Answer

Copy the file babunsrt-lf.bst to your working directory and rename this file e.g. mybabunsrt-lf

After this change the function format.names to the following definition:

FUNCTION {format.names}
{ 's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { nameptr #1 >
      {
        s nameptr "{ll}" format.name$ lastnamefont
        s nameptr "{,~jj}{,~f{.\btxfnamespaceshort }.}{~vv}" format.name$ *
        't :=
          namesleft #1 >
            { ", " * t namefont * }
            { numnames #2 >
                { "\btxandcomma {}" * }
                'skip$
              if$
              s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ "others" =
                { " " "\btxetalshort {.}" etalfont * * }
                { " \btxandshort {.}\ " * t namefont * }
              if$
            }
          if$
        }
        {
          s nameptr "{ll}" format.name$ lastnamefont
          s nameptr "{,~jj}{,~f{.\btxfnamespaceshort }.}{~vv}"
          format.name$ * namefont
        }
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

After this modification I got the following result:

enter image description here

Related Question