# Remove parentheses for empty year field biblatex ieee style

By using biblatex ieee style, I found that the reference will display empty brackets even though the field "year" is undefined. How can I remove it without having to change the biblatex.bst?

\documentclass{article}

\usepackage[style=ieee,backend=bibtex]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\x.bib}
@ELECTRONIC{MEMSnet,
title = {What is {MEMS}?},
organization = {MEMSnet},
url = {http://www.memsnet.org/mems/what_is.html},
urldate = {Dec. 01, 2013}
}
\end{filecontents}

\nocite{*}

\begin{document}

\printbibliography

\end{document}


I got

(). What is MEMS? MEMSnet, [Online]. Available: http://www.memsnet.org/mems/what_is.html.

which is not a correct citation style. I would like to have:

What is MEMS? MEMSnet, [Online]. Available: http://www.memsnet.org/mems/what_is.html.

Many Thanks

• The demo for the IEEE seems to indicate a year is required: can you point to them publishing something without a year? – Joseph Wright Dec 25 '13 at 8:15

In ieee.bbx we find the lines

\DeclareBibliographyDriver{online}{%
[...]
\printtext[parens]{\usebibmacro{date}}%
[...]


So biblatex tries to use the date macro (which actually just defaults to \printdate) and wrap its output into parentheses. If it does not print anything, well, then an empty string is wrapped into parentheses, resulting in what you got above.

The obvious cure is to provide the entry with a date field (after all, [almost] every bib entry should have one, see also Joseph Wright's comment above), this can be difficult and outright impossible with some @online resources though.

Since we do not want to rewrite the whole @online driver (an obvious way to fix the porblem), we patch it using xpatch.

Load \usepackage{xpatch} and put this code into your preamble

\xpatchbibdriver{online}
{\printtext[parens]{\usebibmacro{date}}}
{\iffieldundef{year}
{}
{\printtext[parens]{\usebibmacro{date}}}}
{}
{\typeout{There was an error patching biblatex-ieee (specifically, ieee.bbx's @online driver)}}


It will replace the offending line discussed above (\printtext[parens]{\usebibmacro{date}}) by a (more or less sophisticated) construction in which we check if there is a year field (i.e. a sufficient date field) and only if that condition is met (i.e. only if a year exists; here of course we presuppose that year is the bare minimum requirement for a date output in the bibliography) we go on to print the date, otherwise nothing is done.

\documentclass{article}
\usepackage[style=ieee,backend=bibtex]{biblatex}
\usepackage{xpatch}

\begin{filecontents}{\jobname.bib}
@ELECTRONIC{MEMSnet,
title = {What is {MEMS}?},
organization = {MEMSnet},
url = {http://www.memsnet.org/mems/what_is.html},
urldate = {2013-12-01},
}
\end{filecontents}

\xpatchbibdriver{online}
{\printtext[parens]{\usebibmacro{date}}}
{\iffieldundef{year}
{}
{\printtext[parens]{\usebibmacro{date}}}}
{}
{\typeout{There was an error patching biblatex-ieee (specifically, ieee.bbx's @online driver)}}

\begin{document}
\nocite{MEMSnet,wilde,markey}
\printbibliography
\end{document}


• Incidentally, it is never a bad idea to have an author and biblatex is not too indisposed to accept corporate authors. So one might go with author = {{MEMSnet}} here. – moewe Dec 25 '13 at 8:27
• Also the urldate should have the format yyyy-mm-dd, so better use urldate = {2013-12-01},. – moewe Dec 25 '13 at 8:52
• Is there a way to do something analogous with style=alphabetic and with the reference @article? I would need it for arxiv stuff, where the year is not listed. – Stefano Aug 25 '16 at 16:01
• @Stefano The modifications needed for @article in the standard styles (e.g. alphabetic) are vastly different, so I suggest you ask a new question. – moewe Aug 25 '16 at 20:43