5

I need to create this bibliography style with Bibulous. enter image description here

With the following code I get really close:

TEMPLATES:
book =  [<au>.] [\textit{"<title>"}.] [<address> <year>.]
electronic = [<au>.] [\textit{<institution>.}] [<date>.] ["<title>".] 
[<url>.] 
[<dateofchange>]. [<urldate>.]            
oral = [<author>.] [<interviewer>,] [<date>,] [<address>.]
inbook = [<author>.] ["<articletitle>".] [In: <title>,] hg. v. 
[<publisher>.] [<address>] [<place>.] [<pages>.]
article = [<author>.] ["<title>".] [\textit{<journal>,] [<year>,] 
[<number>,}] [<pages>.]

The optional brackets are intentional because often one argument is missing in the .bib file.

Now I need to sort them alphabetically (as described here:Can bibulous sort references alphabetically? Ask) (first the surename and then the forename, both fully written out) but without the numbers on the left side. It should look like example#9 here. Somehow I'm unable to put the codes together so they work properly.

\documentclass[11pt, a4papter] {scrartcl}
\begin{document}
Lorem ipsum dolor sit amet, \cite{gehalt} consetetur sadipscing elitr, 
\cite{Lenz1}. Lorem ipsum dolor sit amet. \cite{ackeret}
\end{document}

With .bib file

@Electronic{gehalt,
  author      = {Rütti, Nicole},
  institution = {NZZ Online},
  date        = {2017-07-27},
  title       = {Sind Frauen wirklich selber schuld am tieferen Gehalt?},
  url         = {https://www.nzz.ch/wirtschaft/frauen-und-lohnverhandlungen-auf-stoeckelschuhen-rueckwaerts-ueber-ein-minenfeld-laufen-ld.1307984},
  urldate     = {2018-10-14},
}


@Electronic{ackeret,
  author      = {Ackeret, Markus},
  institution = {NZZ Online},
  date        = {2017-05-25},
  title       = {Im Übereifer des politischen Gefechts},
  url         = {https://www.nzz.ch/international/debatte-um-die-bundeswehr-im-uebereifer-des-politischen-gefechts-ld.1296154},
  urldate     = {2018-10-14},
}

@Electronic{Lenz1,
  author      = {Lenz, Christoph},
  institution = {Tages-Anzeiger Online.},
  date        = {2017-07-04},
  title       = {Rechenspiele der Armee haben politische Folgen},
  url         = {https://www.tagesanzeiger.ch/schweiz/standard/rechenspiele-der-armee-haben-politische-folgen/story/19945957},
  urldate     = {2018-10-16},
}

EDIT: After the suggestions from moewe I changed the code slightly:

\documentclass[11pt, a4papter] {scrartcl}
 \renewcommand{\@biblabel}[1]{} \renewcommand{\@cite}[2]{{#1\if@tempswa , 
  #2\fi}} \makeatother
    \begin{document}
    Lorem ipsum dolor sit amet, \cite{gehalt} consetetur sadipscing elitr, 
    \cite{Lenz1}. Lorem ipsum dolor sit amet. \cite{ackeret}
    \end{document}

.bst file

TEMPLATES:
book =  [<au>.] [\textit{"<title>"}.] [<address> <year>.]
electronic = [<au>.] [\textit{<institution>.}] [<date>.] ["<title>".] `[<url>.] [<dateofchange>]. [<urldate>.]`            
oral = [<author>.] [<interviewer>,] [<date>,] [<address>.]
inbook = [<author>.] ["<articletitle>".] [In: <title>,] hg. v. 

[<publisher>.] [<address>] [<place>.] [<pages>.]
    article = [<author>.] ["<title>".] [{\textit<journal>,] [<year>,] [<number>,}] [<pages>.]


SPECIAL-TEMPLATES:
au = <authorname.0>; ...; <authorname.9>

This two changes remove the numbers and show the full name of the author. However, the authors aren't sorted alphabetically and I still don't manage that the surename comes first and then the forename.

If anyone could help me I would be very grateful.

  • Welcome to TeX.SX! This is an interesting question, but you could make it easier for people to get started answering your question if you could give them something to test the template: Please consider adding a short example document with a few citations and a bibliography as well as a short .bib file with a few example entries. (What we may call an MWE or MWEB: tex.meta.stackexchange.com/q/228/35864 and tex.meta.stackexchange.com/q/4407/35864). Your question is understandable as it is, but it is easier to answer if you give us something to start from and to test. – moewe Oct 28 '18 at 16:55
  • As it turns out, this question needs an MWE. The question of numbers or no numbers in the bibliography is not decided by Bibulous and its template. Whether or not a number is shown is governed by the definition of thebibliography active in your document (depends on the document class and bibliography-related packages you load - e.g. natbib, cite, ...). Something like \makeatletter \renewcommand{\@biblabel}[1]{} \renewcommand{\@cite}[2]{{#1\if@tempswa , #2\fi}} \makeatother as shown in Example 9 should help, but it depends on your exact setup. – moewe Oct 28 '18 at 17:04
  • In my preamble I don't have a package as natbib or cite. However, this might solve some other problems I'm dealing with. – svenz Oct 28 '18 at 17:21
  • @moewe I'm not sure but I don't think that natbib will work with a authoryear sorting. – svenz Oct 29 '18 at 14:43
  • It does. natbib does not care about sorting and if the bibliography style provides the necessary metadata natbib will even allow you to use author-year citations (that is one of the selling points of natbib over the standard \cite implementation). Since I have only Python 3 on my PC and I am having trouble getting Bibulous to work I could not yet have a closer look at your code, but I will hopefully be able to look into this a little later. – moewe Oct 29 '18 at 14:48
3

Since Bibulous is a drop-in replacement for BibTeX you can combine it with any citation package that you can use for BibTeX. I suggest you load natbib, because natbib has good support for author-year citations. With natbib run in author-year mode there will be no numbering in the bibliography.

Sorting by author and year is achieved with sortkey.

\documentclass[11pt, a4papter] {scrartcl}
\usepackage{natbib}

\usepackage{filecontents}
\begin{filecontents*}{svenz.bst}
TEMPLATES:
book =  [<au>.] [\textit{\enquote{<title>}}.] [<address> <year>.]
electronic = [<au>.] [\textit{<institution>.}] [<date>.] [\enquote{<title>}.] [<url>.] [<dateofchange>.] [<urldate>.]
oral = [<au>.] [<interviewer>,] [<date>,] [<address>.]
inbook = [<au>.] [\enquote{<title>}.] [In: <booktitle>,] hg. v. [<publisher>.] [<address>] [<place>.] [<pages>.]
article = [<au>.] [\enquote{<title>}.] [\textit{<journal>,] [<year>,] [<number>,}] [<pages>.]

SPECIAL-TEMPLATES:
citelabel = <authorlist.0.last>, <year>
sortkey = <authorlist.0.last><year>

OPTIONS:
namelist_format = last_name_first
use_firstname_initials = False
\end{filecontents*}
\begin{filecontents}{\jobname.bib}
@Electronic{gehalt,
  author      = {Rütti, Nicole},
  institution = {NZZ Online},
  year        = {2017},
  date        = {2017-07-27},
  title       = {Sind Frauen wirklich selber schuld am tieferen Gehalt?},
  url         = {https://www.nzz.ch/wirtschaft/frauen-und-lohnverhandlungen-auf-stoeckelschuhen-rueckwaerts-ueber-ein-minenfeld-laufen-ld.1307984},
  urldate     = {2018-10-14},
}


@Electronic{ackeret,
  author      = {Ackeret, Markus},
  institution = {NZZ Online},
  year        = {2017},
  date        = {2017-05-25},
  title       = {Im Übereifer des politischen Gefechts},
  url         = {https://www.nzz.ch/international/debatte-um-die-bundeswehr-im-uebereifer-des-politischen-gefechts-ld.1296154},
  urldate     = {2018-10-14},
}

@Electronic{Lenz1,
  author      = {Lenz, Christoph},
  institution = {Tages-Anzeiger Online},
  year        = {2017},
  date        = {2017-07-04},
  title       = {Rechenspiele der Armee haben politische Folgen},
  url         = {https://www.tagesanzeiger.ch/schweiz/standard/rechenspiele-der-armee-haben-politische-folgen/story/19945957},
  urldate     = {2018-10-16},
}
\end{filecontents}

\begin{document}
Lorem ipsum dolor sit amet, \citet{gehalt} consetetur sadipscing elitr, 
\cite{Lenz1}. Lorem ipsum dolor sit amet. \cite{ackeret}

\bibliographystyle{svenz}
\bibliography{\jobname}
\end{document}

enter image description here

In the above example I had to give both the year and the date because Bibulous does not parse the date field by default. But it should be possible to write a small Python function that does this automatically....

Here is a .bst that I thought would work even with date, but did not because I could not get Bibulous to resolve variables in the special templates section (see https://github.com/nzhagen/bibulous/issues/15).

TEMPLATES:
book =  [<au>.] [\textit{\enquote{<title>}}.] [<address> <year>.]
electronic = [<au>.] [\textit{<institution>.}] [<date>.] [\enquote{<title>}.] [<url>.] [<dateofchange>.] [<urldate>.]
oral = [<au>.] [<interviewer>,] [<date>,] [<address>.]
inbook = [<au>.] [\enquote{<title>}.] [In: <booktitle>,] hg. v. [<publisher>.] [<address>] [<place>.] [<pages>.]
article = [<au>.] [\enquote{<title>}.] [\textit{<journal>,] [<year>,] [<number>,}] [<pages>.]


SPECIAL-TEMPLATES:
citelabel = <authorlist.0.last>, <dateyear>
sortkey = <authorlist.0.last><dateyear>


OPTIONS:
allow_scripts = True
namelist_format = last_name_first
use_firstname_initials = False


VARIABLES:
dateyear = parse_date_or_year(entry, options)

DEFINITIONS:
def parse_date_or_year(entry, options):
    '''
    Parses the ISO 8601 date in the date field or year in year field
    '''

    if ('date' in entry):
        datematch = re.search(r'\A([0-9]{4})(?:-[0-9]{2}){0,2}(?:/([0-9]{4})(?:-[0-9]{2}){0,2})?\Z', entry['date'])
        if datematch.group(2):
            return(datematch.group(1) + "--" + datematch.group(2))
        elif datematch.group(1):
            return(datematch.group(1))
    elif ('year' in entry):
        return(entry['year'])

    return(None)

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.