# Customizing the biblatex style authoryear - Part 2

This is a follow up question to Customizing the biblatex style authoryear.

For my work I need 3 more types of literature altered:

@inbook:

Last Name, First Name (year): Title. In Last BookauthorName, First BookauthorName (Hg): Booktitle, Pages. Location, Publisher.

Here, "In" and "(Hg)" should be hardcoded (it's German). I managed to undo the italic style for the booktitle and the parentheses of the title by:

\DeclareFieldFormat[inbook]{booktitle}{#1}
\DeclareFieldFormat[inbook]{title}{#1}


@article:

Last Name, First Name (year): Title. Journaltitle, Number (Series), Pages.

@online:

Last Name, First Name (year): Title, (besucht am Date). Url.

here, "besucht am" should be hardcoded but is no problem since it's biblatex standard in German.

I can imagine that all of this isn't quite straight forward.. But any help would be greatly appreciated! Thanks a lot!

What I have thus far:

\usepackage[style=authoryear]{biblatex}

\DeclareFieldFormat[book]{title}{#1} %titel non-italic
\DeclareFieldFormat[inbook]{booktitle}{#1} %booktitle non-italic
\DeclareFieldFormat[inbook]{title}{#1} %title without ""
\DeclareFieldFormat[article]{title}{#1} %title without ""
\DeclareFieldFormat[article]{journaltitle}{#1} %journaltitle non-italic
\DeclareFieldFormat[online]{title}{#1} %title non-italic

\renewbibmacro*{publisher+location+date}{%
\printlist{location}%
\printlist{publisher}%
\usebibmacro{date}%
\newunit}

\begin{document}
\parencite{heybook}
\parencite{heyinbook}
\parencite{heyarticle}
\parencite{heyonline}
\end{document}


My sources.bib file with examples looks the following:

@book{heybook,
author    ={Simon Beck},
title     ={Buchtitel},
publisher ={Verlag},
location  ={Ort},
date      ={2011} }

@inbook{heyinbook,
bookauthor={Simonbook Beckbook},
author    ={Simoninbook Beckinbook},
booktitle ={Buchtitel},
title     ={Kapiteltitel},
publisher ={Verlag},
location  ={Ort},
pages     ={123-124},
date      ={2012} }

@article{heyarticle,
author   ={Simonarticle Beckarticle},
title    ={Artikeltitel},
journaltitle={Zeitschrift},
number   ={12},
series    ={Jahrgang},
pages    ={123-124},
date     ={2013} }

@online{heyonline,
author   ={Simononline Beckonline},
title    ={Onlinetitle},
url      ={http://pes.ee.ethz.ch},
urldate  ={2014-04-12},
date     ={2014} }

• We can help you faster, if you provide a compilable MWE including your bib-file. You can use the package filecontents for that: \begin{filecontents}{sources.bib}@book{...}\end{filecontents} – musicman Apr 30 '14 at 9:37
• Thanks for your help! How i do I provide a compilable MWE? I did not alter any other files besides my main .tex file as shown above. Please give me a minute to figure out how to use filecontents properly..;) – Simon Beck Apr 30 '14 at 9:53
• Okey, sadly, I didn't got filecontents to work.. but I included my sources.bib into my post. Hope this is helpful as well. Thanks! – Simon Beck Apr 30 '14 at 10:17
• Yes, I will work on an answer. – musicman Apr 30 '14 at 10:18
• Why exactly do you want to use series with @articles? The series field is intended for things like "new series", "neue Folge" etc.. Normally volume and number are enough. Do you have a real-life example when you might need series? – moewe Apr 30 '14 at 17:05

Okay, look at your updated MWE:

\documentclass[a4 paper,12pt]{article}
\usepackage[style=authoryear,dashed=false]{biblatex}
\usepackage[ngerman]{babel}

\begin{filecontents}{mybib.bib}
@book{heybook,
author    ={Simon Beck},
title     ={Buchtitel},
publisher ={Verlag},
location  ={Ort},
date      ={2011} }

@inbook{heyinbook,
% bookauthor={Simonbook Beckbook},
author    ={Simoninbook Beckinbook},
editor    ={Fritz HerausgeberGuy and Frieda HerausgeberGirl},
booktitle ={Buchtitel},
title     ={Kapiteltitel},
publisher ={Verlag},
location  ={Ort},
pages     ={123-124},
date      ={2012} }

@article{heyarticle,
author   ={Simonarticle Beckarticle},
title    ={Artikeltitel},
journaltitle={Zeitschrift},
number   ={12},
series    ={Jahrgang},
pages    ={123-124},
date     ={2013} }

@online{heyonline,
author   ={Simononline Beckonline},
title    ={Onlinetitle},
url      ={http://pes.ee.ethz.ch},
urldate  ={2014-04-12},
date     ={2014} }
\end{filecontents}

\DeclareFieldFormat[book]{title}{#1} %titel non-italic
\DeclareFieldFormat[inbook]{booktitle}{#1} %booktitle non-italic

%my code:
\DeclareFieldFormat[inbook]{title}{#1} %title without ""
\DeclareFieldFormat[article]{journaltitle}{#1} %non-italic
\DeclareFieldFormat[online]{title}{#1} %non-italic
\DeclareFieldFormat[article]{title}{#1} %titel unquoted

\renewcommand{\intitlepunct}{}%no ":" after "in"

\DefineBibliographyStrings{german}{%redefine strings
editors = {Hgg}
}

\renewbibmacro*{editor+others}{%from biblatex.def, parencites around editor
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\printnames{editor}%
\clearname{editor}}
{}}

\DeclareBibliographyDriver{inbook}{%from standard.bbx; macro "editor..." instead of "byeditor..."
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{in:}%
\usebibmacro{bybookauthor}%
\newunit\newblock
\usebibmacro{maintitle+booktitle}%moved
\usebibmacro{chapter+pages}%moved
% \newunit\newblock
% \usebibmacro{byeditor+others}%
% \newunit\newblock
% \printfield{edition}%maybe add again if needed
\newunit
\iffieldundef{maintitle}
{\printfield{volume}%
\printfield{part}}
{}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{publisher+location+date}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}

\DeclareBibliographyDriver{article}{%from standard.bbx, removed macro "in:"
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
% \usebibmacro{in:}%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}

\newbibmacro*{journal+issuetitle}{%standard.bbx, rearranged, parencites
\usebibmacro{journal}%
\printfield{number}%
%end
\iffieldundef{series}
{}
{%\newunit
\printfield[parens]{series}%
}
\usebibmacro{issue+date}%
\usebibmacro{issue}%
\newunit}

\DeclareBibliographyDriver{online}{%arrange, deleted some macros
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\usebibmacro{url+urldate}%
\newunit\newblock
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}

\renewbibmacro*{url+urldate}{%from biblatex.def, rearranged
\iffieldundef{urlyear}
{}
{\printurldate}
\printfield{url}%moved
}

\renewbibmacro*{publisher+location+date}{%
\printlist{location}%
\printlist{publisher}%
\usebibmacro{date}%
\newunit}

\begin{document}
\nocite{*}
\printbibliography
\end{document}


This is rather much code. There may be better ways to do what you want, but it gives you a start. I've commented the code; in some parts it may not be the best, and you have to modify it to your needs. A few notes:

• You should use editor (Herausgeber) instead of bookauthor.
• Your citation style is inconsistent, but that's not a LaTeX-problem...
• If you want to cite an article out of a book, consider to put both in your bibtex-file and refer it in the article via crossref={key}. So you can seperate things better and don't have to write data again and again. For example booktitle, this will be automaticall inherited if you put in a title-field from a book-entry and use crossref in your article.
• The updated MWE also includes the bibfile as a filecontent.

Output:

• You're officially a genius! Thank you so much! May I ask how you learned all of this? I couldn't find any useful information on this topic on the web? Thanks again. – Simon Beck Apr 30 '14 at 13:01
• Oh I'm not a genius, you don't know the others ;) I've just learned like you: Try, ask and manuals. – musicman Apr 30 '14 at 13:12
• One more thing: If an answer solves your problem and you're okay with it, mark it as your accepted answer. – musicman Apr 30 '14 at 13:22
• Since the OP seems to want to have all titles in non-italic and not quotes, a single \DeclareFieldFormat*{title}{#1} and \DeclareFieldFormat*{booktitle}{#1} will make things a bit shorter. – moewe Apr 30 '14 at 16:59
• If the only purpose of the redefinition of the @article driver is to get rid of the in, you'd better go with Suppress “In:” biblatex. You could also move the editor macros in @inbook entries via xpatch as in Move names of editors followed by (Ed./Eds.) and a comma before title in biblatex, so you can avoid copying the whole driver from standard.bbx. – moewe Apr 30 '14 at 17:03