2

I am trying to achieve the following bibliography style for websites (@misc):

Editor (Hrsg.) (2015): Title, Location. Verfügbar unter: http://some.kind.of.url (letzter Zugriff: 05.09.2015).

And I would like to add a field "downloaded" to the bibliography to get bibliography entries for publicly available PDF files:

Editor (Hrsg.) (2015): Title, Location. Verfügbar unter: http://some.kind.of.url/file.pdf (Download am: 05.09.2015).

This is my example what I did so far:

\documentclass[12pt, oneside]{Thesis}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[backend=biber,%
            citestyle=authoryear-icomp,%
            bibstyle=authoryear,%
            dashed=false,%
            sorting=nyvt,%
            autocite=footnote,%
            autopunct=true,%
            backrefstyle=three+,%
            isbn=false,%
            doi=false,%
            pagetracker=true,%
            useprefix=true,%
            uniquename=init,%                       
            firstinits=true,%
            maxcitenames=2,%
            ]{biblatex} 
\addbibresource{Bibliography.bib}                       
\setlength{\bibitemsep}{1em}
\setlength{\bibhang}{2em}
\setlength{\footnotesep}{0.6\baselineskip}
\renewcommand{\mkcitation}[1]{\space#1}
\renewcommand{\mkblockquote}[4]{\singlespace\emph{#1}#2#4#3}
\urlstyle{same}
\renewcommand*{\nameyeardelim}{\addcomma\space}
\renewcommand*{\labelnamepunct}{\addcolon\space}
\renewcommand{\multinamedelim}{\addsemicolon\space}
\renewcommand{\finalnamedelim}{\addsemicolon\space}
\DeclareNameAlias{author}{last-first}
\DeclareNameAlias{labelname}{last-first}
\DeclareFieldFormat{title}{#1}
\DeclareFieldFormat{url}{verf{\"u}gbar unter\addcolon\space\url{#1}}
\DefineBibliographyStrings{ngerman}{urlseen = letzter Zugriff\addcolon}
\DeclareFieldFormat[article]{title}{#1}
\DeclareFieldFormat{journaltitle}{#1}
\renewcommand{\bibfootnotewrapper}[1]{\bibsentence#1\addspace}
\DefineBibliographyStrings{ngerman}{
    editor = {(Hrsg\adddot)},
    editors={(Hrsg\adddot)}
}
\renewbibmacro*{editor+others}{
    \ifboolexpr{
        test \ifuseeditor
        and
        not test {\ifnameundef{editor}}
    }
    {
        \printnames{editor}%
        \setunit{\space}%
        \usebibmacro{editor+othersstrg}%
        \clearname{editor}
        \usebibmacro{date+extrayear}
    }
    {

    }
}

\begin{document}
Some Text\blockquote[{\autocite[][]{WwwSource.2015}}]{with citation}{}.
\end{document}

This is my .bib entry for the first:

@misc{WwwSource.2015,
 editor = {{Editor}},
 year = {{2015}},
 title = {Title},
 url = {http://some.kind.of.url},
 keywords = {Quelle},
 address = {Location},
 urldate = {2015-09-05},
}

This is my .bib entry for the second:

@misc{WwwSource.2015,
 editor = {{Editor}},
 year = {{2015}},
 title = {Title},
 url = {http://some.kind.of.url/file.pdf},
 keywords = {Quelle},
 address = {Location},
 urldate = {2015-09-05},
 downloaded = {2015-09-05}
}

The problem I am currently encountering is that with the redefinition of the macro editor+others in my bibliography the entries containing an editor are indented: enter image description here

For the second part with the download date I don't have an idea how to do that.

Any help appreciated.

Thanks a lot in advance.

  • BTW: I don't think it is good style to add the parentheses manually to \DefineBibliographyStrings{ngerman}, you can achieve the same output by \DeclareFieldFormat{editortype}{\mkbibparens{#1}}. – moewe Sep 5 '15 at 13:17
  • Your \renewbibmacro*{editor+others} has the potential to cause lots of unwanted space. Read What is the use of percent signs (%) at the end of lines? – moewe Sep 5 '15 at 13:18
  • You should also not change the labelname format if you don't know exactly what you are doing, it can destroy a lot - why did you change the format? – moewe Sep 5 '15 at 13:22
  • Changed to \DeclareFieldFormat{editortype}{\mkbibparens{#1}} - thanks for that. – Grodon Sep 5 '15 at 13:26
  • If I get you right, I should either add % at the end of every line in my \renewbibmacro*{editor+others} or put everything in one line, correct? – Grodon Sep 5 '15 at 13:28
2

Since we decided to use a keyword to decide whether to display "letzter Zugriff" or "Download am" the entire thing is not too complicated. We will also get to know a way to do this with the options field, instead of the old keywords.

Firstly, we need to define a new bibliography string

\NewBibliographyString{downloadon}

Then, we define the strings so they say the right things

\DefineBibliographyStrings{german}{%
  urlfrom    = {verfügbar unter},
  urlseen    = {letzter Zugriff},
  downloadon = {Download am},
}

Then we change the formats of the url and urldate fields to use the new strings, with keywords we need

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{%
  \mkbibparens{%
    \ifkeyword{pdf}
      {\bibstring{downloadon}}
      {\bibstring{urlseen}}%
    \addcolon\space#1}}

The urldate shows a different bibstring depending on whether the keyword pdf is present or not.

Alternatively, we can use options supplied to the entries. We then need

\newtoggle{blx:pdf}
\DeclareEntryOption{pdf}[true]{%
  \settoggle{blx:pdf}{#1}}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{%
  \mkbibparens{%
    \iftoggle{blx:pdf}
      {\bibstring{downloadon}}
      {\bibstring{urlseen}}%
    \addcolon\space#1}}

And you need to add options = {pdf}, to the bib entry instead of adding the keyword pdf.

We can even automate this process a bit such that all URLs that end in .pdf automatically trigger the pdf=true option via

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \step[fieldsource=url, match=\regexp{\.pdf\Z}, final]
      \step[fieldset=options, append, fieldvalue={,pdf=true}]
    }
  }
}

MWE

\documentclass[ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=authoryear-icomp,%
            dashed=false,%
            sorting=nyvt,%
            autocite=footnote,%
            autopunct=true,%
            backrefstyle=three+,%
            isbn=false,%
            doi=false,%
            pagetracker=true,%
            useprefix=true,%
            uniquename=init,%                       
            firstinits=true,%
            maxcitenames=2,%
            ]{biblatex} 
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@misc{WwwSource.2015,
 editor    = {Ellen Ditor},
 year      = {2015},
 title     = {A Real PDF},
 url       = {http://example.edu/file.pdf},
 keywords  = {Quelle},
 options   = {pdf},
 address   = {Location},
 urldate   = {2015-09-05},
}
@misc{WwwSource.2016,
 editor   = {Ellen Ditor},
 year     = {2016},
 title    = {Just Any Old Website},
 url      = {http://example.com},
 keywords = {Quelle},
 address  = {Location},
 urldate  = {2015-09-05},
}
\end{filecontents*}
\addbibresource{\jobname.bib}   

\renewcommand{\mkcitation}[1]{\space#1}
\renewcommand{\mkblockquote}[4]{\singlespace\emph{#1}#2#4#3}
\urlstyle{same}

\renewcommand*{\bibfootnotewrapper}[1]{\bibsentence#1\addspace}

\renewcommand*{\nameyeardelim}{\addcomma\space}
\renewcommand*{\labelnamepunct}{\addcolon\space}
\renewcommand*{\multinamedelim}{\addsemicolon\space}
\renewcommand*{\finalnamedelim}{\multinamedelim}

\DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{labelname}{last-first}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareFieldFormat{title}{#1}
\DeclareFieldFormat[article]{title}{#1}
\DeclareFieldFormat{journaltitle}{#1}


\NewBibliographyString{downloadon}
\DefineBibliographyStrings{german}{%
  urlfrom    = {verfügbar unter},
  urlseen    = {letzter Zugriff},
  downloadon = {Download am},
}

\newtoggle{blx:pdf}
\DeclareEntryOption{pdf}[true]{%
  \settoggle{blx:pdf}{#1}}

\DeclareFieldFormat{url}{\bibstring{urlfrom}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{%
  \mkbibparens{%
    \iftoggle{blx:pdf}
      {\bibstring{downloadon}}
      {\bibstring{urlseen}}%
    \addcolon\space#1}}



\makeatletter
\renewbibmacro*{bbx:editor}[1]{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\printnames{editor}%
        \setunit{\addspace}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{#1}%
     \clearname{editor}%
     \setunit{\addspace}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \usebibmacro{date+extrayear}}
\makeatother

\begin{document}
Some Text \autocite{WwwSource.2015,WwwSource.2016}

\printbibliography
\end{document}

enter image description here

  • If you want to format all titles plain, then \DeclareFieldFormat*{title}{#1} should do it without having to issue a \DeclareFieldFormat[article]{title}{#1}. You will also notice that I did not change the author format, but the sortname format, this will give more uniform results in the bibliography if you add a second editor. – moewe Sep 5 '15 at 14:16
  • Awesome! Thanks a lot! This works like a charm! – Grodon Sep 6 '15 at 10:04

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.