# How to ignore uniquename for an specific author with biblatex

I'm writing about this author and most of my references are of her work. There's only one single entry by another person with the same lastname and I'd like that only this entry were disambiguated with the given name, as in

I tried to manually edit the .bbl file and set the uniquename field to 0, and that works. So I tried this:

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=hash,
match={d6cfb2b8c4b3f9440ec4642438129367},
final]
\step[fieldset=uniquename, fieldvalue=0]
}
}
}


But it doesn't work (I don't think hash and uniquename are "fields", but I don't know how to call them)

Here's a non working mwe:

\begin{filecontents}{\jobname.bib}
@book{mainauthor,
author = {Jane Doe},
title = {Title},
year = {2016},
option = {uniquename=false},
}
@book{another,
author = {Hans Doe},
title = {Title},
year = {2016},
}
\end{filecontents}
\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=hash,
match={d6cfb2b8c4b3f9440ec4642438129367},
final]
\step[fieldset=uniquename, fieldvalue=0]
}
}
}
\begin{document}
\autocites{mainauthor,another}
\printbibliography
\end{document}

• The problem is that the sourcemapping step occurs much earlier than the actual disambiguation process. So you can't overwrite uniquename using source mapping. – moewe Sep 14 '16 at 13:27
• According to the documentation, though, uniquename should be a per-entry option, but not even that seems to work in your MWE - maybe that is a bug, or I misunderstand what should be happening in that case. – moewe Sep 14 '16 at 13:29

This here should imho work:

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{xpatch}
\xpretonameformat{labelname}{%
\iffieldequalstr{entrykey}{mainauthor}{\setcounter{uniquename}{0}}{}}{}{}

\begin{document}

\autocites{mainauthor,another}
\printbibliography
\end{document}


As you probably have more than one entry with Jane Doe, it is as moewe remarked better to test again a hash, probably the hash field for the name Jane Doe is the best suited:

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{xpatch}
\xpretonameformat{labelname}{%
\iffieldequalstr{hash}{d6cfb2b8c4b3f9440ec4642438129367}{\setcounter{uniquename}{0}}{}}{}{}

\begin{document}

\autocites{mainauthor,another}
\printbibliography
\end{document}


• +1 though I would test against the hash: \iffieldequalstr{namehash}{d6cfb2b8c4b3f9440ec4642438129367} (or fullhash?) and not the entrykey. – moewe Sep 14 '16 at 16:00
• @moewe: right, I forgot that J. Doe would have more than one entry. – Ulrike Fischer Sep 14 '16 at 16:05
• That would be the idea, presumably. – moewe Sep 14 '16 at 16:11
• @moewe: I edited the answer, imho hash is the best field (but the example is to mini to be sure). – Ulrike Fischer Sep 14 '16 at 16:13
• Thanks, works perfectly! I prefer testing against the hash as @moewe suggested, it covers cases where the author's name is given by sortauthor as well. – henrique Sep 14 '16 at 16:13