0

I have a little problem with my bibliography. When i dont write a date in this field, there is only

()

in the bibliography, mainly in @online citations.

Tex file:

\documentclass[12pt]{scrartcl}                      
\usepackage[T1]{fontenc}            
\usepackage[utf8]{inputenc}         
\usepackage[ngerman]{babel}         
\usepackage{lmodern}            
\usepackage{siunitx}                
\usepackage{url}                    
\usepackage[hidelinks]{hyperref}    

%% Literatur Allgemein
\usepackage[babel,german=quotes]{csquotes}
\usepackage[
style=numeric,                                          
sorting=none,                                           
maxbibnames=3,                                          
]{biblatex} 
\addbibresource{latexlit.bib}

%% Definiert Online Eintrag
\DefineBibliographyStrings{german}{ 
    andothers = {{et\,al\adddot}},                      % et al. an Stelle von u.a.
    urlseen = {Abruf am},                               % Url-Notiz ändern
}

\DeclareBibliographyDriver{online}{% 
    \printnames{author}% 
    \iffieldundef{year} 
    {} 
    { \mkbibparens{% 
            \printfield{year}} 
    } 
    \newunit\newblockpunct 
    \printfield{title}% 
    \setunit*{.\space}% 
    %\newunit\newblock 
    \printfield{url}% 
    \setunit*{.\space}% 
    \printurldate% 
    \finentry
}

\DeclareFieldFormat{url}{\newline URL: \url{#1}}        % URL mit \newline ausgeben

\begin{document}
    Dies ist ein Test \autocite{traeger}.               
    \printbibliography
\end{document}

Bib File:

@Online{traeger,
    author = {Geldsetzer und Schäfers GmbH},
    title = {WG-Stahlschieber online},
    date = {},
    url = {https://www.geldsetzer.de/stahlschieber/online/itraegerschmal.html},
    urldate =   {2019-04-09}
}

Result:

enter image description here

How can I print "o. J." in () ?

  • Note that your redefinition of the bibliography driver misses some common bibliography macros that are present in all standard drivers: usebibmacro{bibindex}, \usebibmacro{begentry}, \usebibmacro{finentry} (which is possibly more than just \finentry) and the related macros. The output won't change a lot, but consistency can be important if you want to make use of biblatex standard idioms. Instead of \setunit*{.\space} one would normally write \setunit*{\addperiod\space} as that can clean up some cases of spurious spaces. – moewe May 18 at 6:22
1

There are two problems here.

In your redefinition of @online citations, you have (comments added by me):

\iffieldundef{year}% if the year of publication is undefined,
    {}             %   do nothing;
    { \mkbibparens{% otherwise, print a pair of parentheses
            \printfield{year}} % with the year inside
    }

Which means: "If the year of publication is undefined, do nothing; otherwise, print a pair of parentheses with the year inside."

However, in your citation example, the year is not undefined, it's just empty (date = {}), so it uses the second option.

So you need to

  • Remove the date = {} from the bib file, so that it counts as "year not defined", and

  • Change the "undefined year" branch to the behaviour you want - by replacing the above piece of code with

\iffieldundef{year}% if the year of publication is undefined,
    { \mkbibparens{% print parentheses
            o. J.}% with "o. J." inside
    }
    { \mkbibparens{% otherwise, print a pair of parentheses
            \printfield{year}}% with the year inside
    }

"If the year of publication is undefined, print "(o. J.)"; otherwise, print a pair of parentheses with the year inside."

  • The fact that date = {}, does not yield an empty year seems to be an artefact of the date parsing done by Biber and is not usual behaviour (for all other fields <field> = {}, should give you an undefined/empty field in the sense of \iffieldundef). I usually suggest to avoid bare formatting commands like \mkbibparens in bibmacros, they don't work well together with the punctuation tracker. Instead it is better to use \printtext or the field format settings. I am also quite strongly opposed to hard-coded strings like o. J. and would normally prefer bibstrings here. ... – moewe May 18 at 6:18
  • ... In fact there is a bibstring that should almost do the right thing nodate, but by default it prints o.D. in German not o.J. (of course that can be changed with \DefineBibliographyStrings). – moewe May 18 at 6:19
  • Forgot to add the link to the Biber issue: github.com/plk/biber/issues/265 – moewe May 18 at 7:26
  • The inconsistent behaviour of date = {}, in this instance should be fixed in the next Biber release (see link above). – moewe May 19 at 8:08

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.