# Nigrification of references for double-blind refereeing

I really love biblatex, the only disadvantage is that it is not so simple any more to mess with the bibitems manually any more.

Here is a problem that caused me grief: I was asked to blacken out (nigrify) the identifying parts of self-references in a paper to maintain double-blind refereeing. When I used regular bib, I just define

\def\blackbox#1{\setbox0=\hbox{#1}\rule{\wd0}{\ht0}}


and put around the text after every \newblock. Not very elegant, but doable. (note that there are better ways of nigrification, see Efficient ways to anonymize a document but that is not the point)

In biblatex, I can do the same, but things are much more tedious since the data is organized in a much more granular way.... very very tedious (I just did it for two papers and it took me more than an hour).

Ideally, I would like to just specify the authors whose citations I would like to nigrify and then in these bib entries the author names, the title, URL, and page ranges are nigrified e.g. by \blackbox. But I would also be willing to do some editing e.g. by replacing \entry and \endentry by \blackentry and \endblackentry. This \blackentry could call things like \renewbibmacro*{url}{\blackbox....} locally for nigrification. In principle biblatex should be uniquely suited for this; I just do not understand the code deeply enough to do it myself.

-
Welcome to TeX.SE. Your question is really well-stated, but it is always better to compose a minimal working example, that can other people use when trying to solve your problem. It saves them time and hence increases motivation to give attention to your question ;) As well, I took the liberty to format your post a little. See Editing Help. –  yo' Jun 13 '12 at 7:35

The apa6 class works with biblatex and defines \maskcite macros that remove the citation from the text and reference list:

\documentclass[biblatex,mask]{apa6}
\begin{document}
You can cite with \verb-\cite- and get: \cite{book-full}\par
\end{document}


If you are willing to replace \cite with \maskcite, then the way apa6 works is pretty universal. Essentially the class checks for the mask flag. If it is not there it does \let\maskcite\cite otherwise it defines \maskcite to print some text (handling pre- and post-notes nicely). You could easily make it print a black box. It would take some work to make the black box be exactly the size of the reference with the identical line breaks.

-
I think there is a backslash missing after \verb-\maskcite- –  Vivi Jun 13 '12 at 9:58
@vivi something was wrong. Apparently, \printbibliography doesn't trivially work with apa6. This one should work. –  StrongBad Jun 13 '12 at 10:11

I think you can do this by redefining two macros that appear in biblatex.def and are used for name formatting. (I haven't checked this with all styles, of course, and some might use different macros, in which case there would need to be different redefinition.)

This tests for a coincidence of initials and lastname (or lastname but no initials). If your lastname is not common it could possibly be simplified.

\documentclass{article}

\usepackage[backend=biber,style=numeric]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{my.bib}
@book{me01,
author    = {Me Myself},
title     = {This Should Be Blackened},
publisher = {August House},
date      = {2012},
}
@article{me02,
author       = {Me Myself},
title        = {This Should be Blackened Too},
journaltitle = {Worty Journal},
volume       = {100},
pages        = {103--145},
date         = {2011},
}
@article{notme01,
author       = {Brother of Myself},
title        = {This Should be Patent},
journaltitle = {Marginal Quarterly},
volume       = {10},
pages        = {23--24},
date         = {2010},
}
\end{filecontents}

\renewcommand\mkbibnamelast[1]{%
\ifauthorisme
{\setbox0=\hbox{#1}\rule{\wd0}{\ht0}}
{#1}}

\renewcommand\mkbibnamefirst[1]{%
\ifauthorisme
{\setbox0=\hbox{#1}\rule{\wd0}{\ht0}}
{#1}}

\newtoggle{iamauthor}

\def\ifauthorisme#1#2{%
\togglefalse{iamauthor}%
\printnames[setiamauthor]{author}%
\iftoggle{iamauthor}{#1}{#2}}

\DeclareNameFormat{setiamauthor}{%
\ifboolexpr{ test {\ifstrequal{#1}{Myself}}
and ( test {\ifstrequal{#4}{M\bibinitperiod}}
or test {\ifblank{#4}} )}
{\global\toggletrue{iamauthor}}
{}}

\begin{document}

Test \cite{me01} and \cite{notme01} and \cite{me02}
\printbibliography
\end{document}


-
On reflection, of course, one needs to "censor" other fields. Audrey's version is therefore clearly better. –  Paul Stanley Jun 13 '12 at 16:42

The tricky part here is ensuring that raw bibliographic data are always passed to \blackbox/\anonymize. You can do this by aliasing the innermost format applied to the fields you want to censor.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage{biblatex}

\makeatletter
\def\anonymize#1{\setbox0=\hbox{#1}\rule{\wd0}{\ht0}}
\makeatother

% Define anonymized formats
\DeclareFieldFormat{anonfield}{\anonymize{#1}}
\DeclareNameFormat{anonnames}{\anonymize{#3#5#1}}
\DeclareFieldFormat{anontitle}{\anonymize{#1}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{anontitle}{\mkbibquote{\anonymize{#1}\isdot}}
\DeclareFieldFormat[suppbook,suppcollection,suppperiodical]
{anontitle}{\anonymize{#1}}
\DeclareFieldFormat{anontitlecase}{%
\ifboolexpr{ test {\ifcurrentfield{title}}
or test {\ifcurrentfield{subtitle}} }
{\anonymize{#1}}
{#1}}

% Define category of entries to anonymize
\DeclareBibliographyCategory{byname}

% Specify entries in category via comma-separated list of author names
\newcommand*{\anonlist}{}
\DeclareIndexNameFormat{byname}{%
\xifinlist{\detokenize{#4#5#1}}{\anonlist}
{}}

% Hook in anonymized formats
\newrobustcmd*{\anonalias}{%
\ifcategory{byname}
{\DeclareNameAlias{author}{anonnames}%
\DeclareNameAlias{labelname}{anonnames}%
\DeclareFieldAlias{pages}{anonfield}%
\DeclareFieldAlias{url}{anonfield}%
\DeclareFieldAlias{doi}{anonfield}%
\DeclareFieldAlias{citetitle}{anontitle}%
\DeclareFieldAlias[article]{citetitle}[article]{anontitle}%
\DeclareFieldAlias{titlecase}{anontitlecase}}
{}}
\newtoggle{anonymize}
\AtDataInput{\iftoggle{anonymize}{\indexnames[byname][1-99]{author}}{}}
\AtEveryBibitem{\iftoggle{anonymize}{\anonalias}{}}
\AtEveryCitekey{\iftoggle{anonymize}{\anonalias}{}}

% Example
\toggletrue{anonymize}
{Aristotle, L.V{\'a}zques{ de }Parga, A.vanGennep, N.Markey, M.~A.Kastenholz}
{L\bibinitperiod V{\'a}zques{\bibnamedelimb de\bibnamedelimb }Parga,
A\bibinitperiodvanGennep, N\bibinitperiod Markey,
M\bibinitperiod \bibinitdelim A\bibinitperiod Kastenholz}

\begin{document}
Filler text \parencite{companion,aristotle:anima,markey,vazques-de-parga}.
\Textcite{companion,aristotle:anima,kastenholz} showed that...
The results from \citetitle{companion,aristotle:anima,vangennep} showed that...
\printbibliography
\end{document}


Commenting out \toggletrue{anonymize} gives:

A few notes:

• The censored text won't break across lines. To resolve this, use gablin's \anonymize command. Even with this improvement, the anonymized formats only give an approximation to the original document layout; some bibliographic data (particularly names) are heavily formatted.
• Some of these entries need additional fields censored to make their authors non-identifiable; they were simply chosen to give some variety in the name list.
• The name list under biber needs to make use of delimiter commands (\bibinitperiod and friends). If you find this tedious, you could categorize entries with biber's sourcemap option. It supports regular expressions.
-