# Custom citations and bibliography with natbib

This is a very specific problem. I am a member of a project-group of 6 people (5 other than me). I am the only one who is LaTeX "Certified" (or "master" like my group calls me) in my group, so when it comes to LaTeX formatting, I'm on my own.

We are writing a project, in which we want a very specific way of citing and a very specific look in the printed bibliography.

I have scoured the vastness of tex.stackexchange and various package documentations, without luck, and I'm not wise enough to filter the partial solutions for exactly what I need to solve my problem.

I have tried all combinations (most) of the bibliography styles linked to Natbib, without prevail.

This is our documentclass:

\documentclass[a4paper,11pt,fleqn,twoside,openright]{memoir}


This is the packages I've included, which I think are relevant to the question:

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[danish]{babel}


This is our bib file.:

@article{source1,
author = {1Firstname 1Middlename 1Lastname and 2Firstname 2Middlename 2Lastname},
title = {{Hvordan bager man en kage}},
year = {2018},
month = {02},
day = {12},
note = {Læst d. 11-02-2019},
}

@book{source2,
title = {{Hvordan bager man en kage}},
author = {3Firstname 3Middlename 3Lastname and 4Firstname 4Middlename 4Lastname},
year = {2019},
month = {02},
day = {12},
publisher = {Gyldendal},
ISBN = {123-456-789},
note = {Læst d. 11-02-2019}
}


It's this short at the time of writing, because I'm still working on making it look like we want to.

Since we're writing in danish, we want the name separator in the printed bibliography to be "og" instead of "and".

So with all that out of the way, this is the way we wish for the whole thing to look:

In code:

This is some text, which need a citation. \cite{source1}
This is some text, which need a citation. \cite{source2}
This is some text, which need a citation. \cite{source1,source2}


Inline:

This is some text, which need a citation. [1Lastname og 2Lastname, (2018)]

This is some text, which need a citation. [3Lastname og 4Lastname, (2019)]

This is some text, which need a citation. [1Lastname og 2Lastname, (2018), 3Lastname og 4Lastname, (2019)]

In the "Litteratur" (danish for "sources" or "bibliography"):

Litteratur

1Lastname, 1Firstname 1Middlename og 2Lastname, 2Firstname 2Middlename; 2018; Full title; Full date; journal; note

3Lastname, 3Firstname 3Middlename og 4Lastname, 4Firstname 4Middlename; 2019; Full title; Full date; publisher; isbn; note

So my question is, is there someone out there, who is willing to put in some time, to help me solve my problem?

I'm no master at this, so any help is very much appreciated.

• Biblatex seems to be the most natural thing to use here. – Johannes_B Feb 12 at 12:03
• @Johannes_B Care to explain how to implement it? I've tried numerous times, switching between natbib and biblatex – L. Nielsen Feb 12 at 12:41

To give you a starting point please have a look on the following code using biblatex.

\begin{filecontents*}{testbib.bib}
@article{source1,
author = {1Firstname 1Middlename 1Lastname and 2Firstname 2Middlename 2Lastname},
title = {{Hvordan bager man en kage}},
year = {2018},
month = {02},
day = {12},
note = {Læst d. 11-02-2019},
}
@book{source2,
title = {{Hvordan bager man en kage}},
author = {3Firstname 3Middlename 3Lastname and 4Firstname 4Middlename 4Lastname},
year = {2019},
month = {02},
day = {12},
publisher = {Gyldendal},
ISBN = {123-456-789},
note = {Læst d. 11-02-2019}
}
\end{filecontents*}

\documentclass[a4paper,11pt,fleqn,twoside,openright,article]{memoir}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[danish]{babel}

\usepackage{csquotes}
\usepackage[%
backend=biber,
style=authoryear, % <=================================================
]{biblatex}

\DeclareCiteCommand{\cite}[\mkbibbrackets] % <==========================
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\begin{document}
This is some text, which need a citation. \cite{source1}

This is some text, which need a citation. \textcite{source2}

This is some text, which need a citation. \autocite{source1,source2}

\printbibliography[title=Litteratur] % <================================
\end{document}


I used class option article to get text and bibliography on the same page, I used filecontent to have the file testbib.bib and the tex code together in one compiling MWE (you do not need to use filecontents for your work, it is only for the MWE!).

I used the style=authoryear and [title=Litteratur] to get your wanted layout.

If you realy want to enclose your citings in the text with brackets you need the code

\DeclareCiteCommand{\cite}[\mkbibbrackets] % <==========================
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}


The option [\mkbibbrackets] adds the brackets. If you want that too for command \textcite you have to redefine it similar to \cite.

This is the resulting pdf of the given MWE:

Please see that you need biber instead bibtex to compile my code, because option backend=biber is used.

If you want to use natbib with your code, add option natbib=true, to biblatex.