0

Looking for some help in creating a custom bibstyle with natbib.

Just started an MSc and planned to do my writing using TeX, as I did for my UG. The institute I am doing my MSc at, however, uses some custom version of the Harvard System. I have managed to recreate most of what they ask for by modifying a copy of the agsm.bst file.

I am simply struggling with the last part.

This is how it looks right now but to make it match what the institute wants, I need to have dashes where an author has been repeated. (Only the first entry is real, I simply repeat it for example.)

Current Reference List

This is how they present it in the guide but they don't seem to use TeX and suggest writing in Word and using a third party tool for reference management (I am not fond of the idea).

Required Reference List

Edit. MWE. This is the initial call for the package:

\usepackage[authoryear,round,sort]{natbib}
\setcitestyle{round,aysep={},notesep={: }}

This is a example cite and and list build

\citep[35-37]{tedre2015science2}

\bibliographystyle{agsmuhi} \bibliography{sources}

This is how book looks:

FUNCTION {book}
{ output.bibitem
  list.label.output
  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
  author empty$
    { editor "author and editor" item.check }
    { crossref missing$
    { "author and editor" editor either.or.check }
    'skip$
      if$
    }
  if$
  title.field field.used =
    { skip$ }
    { format.btitle "title" output.check }
  if$
  crossref missing$
    { format.bvolume output
      format.number.series output
      format.edition output
      format.publisher.address output
    }
    { format.book.crossref output.nonnull
      format.edition output
    }
  if$
  new.block
  note output
  fin.entry
  write.url
}

And this is the output function:

FUNCTION {init.state.consts}
{ #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
}

STRINGS { s t f }

FUNCTION {output.nonnull} { 's := output.state mid.sentence = { " " * write$ } { output.state after.block = { newline$ "\newblock " write$ } { output.state before.all = 'write$ {"" * write$ } if$ } if$ mid.sentence 'output.state := } if$ s }

There is also this dashify function which I don't know if it has anything to do with it, but the only place I see it called is in the function for formatting page numbers.

FUNCTION {n.dashify}
{ 't :=
  ""
    { t empty$ not }
    { t #1 #1 substring$ "-" =
    { t #1 #2 substring$ "--" = not
        { "--" *
          t #2 global.max$ substring$ 't :=
        }
        {   { t #1 #1 substring$ "-" = }
        { "-" *
          t #2 global.max$ substring$ 't :=
        }
          while$
        }
      if$
    }
    { t #1 #1 substring$ *
      t #2 global.max$ substring$ 't :=
    }
      if$
    }
  while$
}
epR8GaYuh
  • 2,432

0 Answers0