10

I typically use a variable for my name in .bib bibliography entries, for instance:

@String {myname = "Prof. Dr. Hortensia Audactor"}
String {myname = "Anonymized" }

@article{audactor2005pflanzen,
  title = {Wie Pflanzen hören... die Geheimnisse der Sonobotanik},
  author = myname,
  journal = {Draft: \url{http://www.inventionen.de/vortrag_audactor.html}},
  year = {2005}
}

... since some article submissions require anonymization. Then, in principle, I can just change the at sign @ in front of the String command, to determine which one is active; so if I want to anonymize, I'd simply make sure that instead of the above, I have something like:

String {myname = "Prof. Dr. Hortensia Audactor"}
@String {myname = "Anonymized" }

However, now I've ran into a problem, where I have to work on two articles, both fed from the same bibtex file and referring to the same citation -- in the one, anonymization is required; in the other, it isn't. Which means, in essence, that now I have to maintain two .bib files -- one with anonymized name, other without -- if I don't want to manually change the @ sign each time I compile the one or the other article ... and of course, I find either of these approaches to be a pain.

Ideally, what I'd want to do is to pass an option to the \bibliography command in the .tex file; say the article which requires anonymization would "pass a variable" to bibtex in the LaTeX code, as in:

\bibliography[anon=yes]{mybibliography}

... and then, there would be some code in the .bib file, which if it encounters anon=yes, would set the @String {myname to "Anonymized" -- otherwise, the actual name would remain (which would be the case for the article with no anonymization requirements, which would call \bibliography without any arguments).

So, any ideas if what I want to do is possible? (In section "19 Some practical tricks" of Tame the BeaST there are some functions using if$, which makes me think what I'd want to do is possible -- unfortunately, I cannot as of yet determine whether that is the case; EDIT: that section is for .bst files, so it's not applicable here; I wouldn't want to mess with .bst, only .bib)

Thorsten
  • 12,872
sdaau
  • 17,079
  • It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. – Thorsten May 07 '11 at 17:06
  • 1
    Is this a common way to do things in your field? In mine, we just try to avoid obvious self-references such as "In previous work (Smith 2009) we have shown" but otherwise leave references alone. (Especially since one can easily figure out the reference by looking up the paper in the journal using the rest of the citation information.) – Alan Munn May 07 '11 at 17:10
  • @Thorten - sorry about that, bad habit from email (I often hate it when people can't be bothered to write lead in/lead out); @Alan Munn - well, some require that references to author are anonymized ('double blind', I guess), so I'd rather be safe than sorry :) Cheers! – sdaau May 07 '11 at 17:37
  • 1
    @Alan I also wondered about this when reading the question. This approach even seems to disclose more information about who the author is (less "blind"!), because one would understand that the author coincides with the "anonymized" author, and if they then look up the published referenced work (perhaps, in order to understand this work better), they will know the author definitely... – imz -- Ivan Zakharyaschev May 07 '11 at 23:50

3 Answers3

12

You can include multiple bibliography files.

For instance, you can have two (very short) Bibtex files: anon.bib that defines the anonymised version of your macro and myname.bib defines it in the usual way. Then you have mybibliography.bib with everything else.

Now it is easy to use either

\bibliography{anon,mybibliography}

or

\bibliography{myname,mybibliography}

in your Latex source depending on which version you want. No need to edit any *.bib files.


A minimal working example.

x.bib:

@STRING{test = {Xxxx}}

y.bib:

@STRING{test = {Yyyy}}

z.bib:

@MISC{z,
    author = test,
    title = test,
    year = {2000}
}

a.tex:

\documentclass[a4paper]{article}
\begin{document}
\cite{z}
\bibliographystyle{plain}
\bibliography{x,z}
\end{document}

b.tex:

\documentclass[a4paper]{article}
\begin{document}
\cite{z}
\bibliographystyle{plain}
\bibliography{y,z}
\end{document}

The following files are generated by Bibtex.

a.bbl:

\begin{thebibliography}{1}

\bibitem{z}
Xxxx.
\newblock Xxxx, 2000.

\end{thebibliography}

b.bbl:

\begin{thebibliography}{1}

\bibitem{z}
Yyyy.
\newblock Yyyy, 2000.

\end{thebibliography}

In general, including multiple Bibtex files is a powerful technique with which you can easily control the behaviour of Bibtex by including the right combination of Bibtex files. Here is another example of the trick.

Jukka Suomela
  • 20,795
  • 13
  • 74
  • 91
  • Have you tried this? It doesn't actually work. The @string command works on a per-bib-file basis. – Alan Munn May 07 '11 at 17:11
  • @Alan: I actually use a similar trick often: I have files that contain a bunch of @STRING definitions (and nothing else), and they are used in another file (that does not define them). – Jukka Suomela May 07 '11 at 17:14
  • 1
    @Jukka So I wonder why my test of this didn't work. It was the first thing I thought of but it didn't seem to work for me. – Alan Munn May 07 '11 at 17:16
  • @Alan: I now tried it with a minimal example; works fine. See the edits. (By the way, it also works perfectly with rubber; you can simply run something like rubber -Wall a.tex b.tex and both versions are up-to-date.) – Jukka Suomela May 07 '11 at 17:31
  • @Jukka My reference manager makes was adding braces to the name field; editing the raw bibtex makes the solution work. – Alan Munn May 07 '11 at 17:38
  • @Jukka Suomela - I did try to hint that I find maintaining multiple bibliographies a pain; however, thanks and +1 for the detailed answer! – sdaau May 07 '11 at 17:38
  • 1
    @sdaau: Here you are not maintaining multiple bibliography files. You have two files that you do not need to edit ever (unless your name changes...). You only need to edit mybibliography.bib, and you do not need to duplicate any information. – Jukka Suomela May 07 '11 at 17:45
  • @Jukka Suomela - ah, sorry, I misread your answer (I guess x.bib and y.bib got the better of me :) ) Yeah, it seems as a much more straightforward solution. Cheers! – sdaau May 07 '11 at 17:47
  • 2
    @sdaau I don't think you understand Jukka's solution. Your "multiple bibliographies" would just be the following: anon.bib = @STRING {myname = "Anonymized" } and non-anon.bib = @STRING {myname = "Prof. Dr. Hortensia Audactor"}. Your main bibliography remains the same. When you want to anonymize your name, you use \bibliography{anon,mainbibfile} This is by far the best solution to your problem. – Alan Munn May 07 '11 at 17:47
  • @Alan Munn - yes, exactly; sorry about that, I misread @Jukka Suomela's answer; thanks for the clarification - cheers! – sdaau May 07 '11 at 17:49
1

The easiest way would be to use a macro in the .bib file, for example \myname, and then define this in the LaTeX file. You would probably want to \providecommand the macro in the @preamble of the .bib file, so that there is not an error if you forget to define it in the LaTeX file.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • Does this really work? Will the macro allow the parts of the name to be used for formatting? For example, if your bibentry is name="\ifanon Anonymized\else\Your Name\fi", then "Your Name" shows up in the citations/bibliography instead of e.g. "Your Name (2011)" instead of "Name (2011)" etc. Wouldn't a macro for the name field work the same way? – Alan Munn May 07 '11 at 16:57
  • 1
    @Alan: I guess I'm used to numerical citations, where this never arises! – Joseph Wright May 07 '11 at 17:02
  • (How would that work anyway with 'anonymous'? I'm actually confused by the whole concept: if the names are wrong, the reference is wrong.) – Joseph Wright May 07 '11 at 17:03
  • @Joseph Ok, so I'm not imagining things. What really is needed is the concept of a conditional within the bib field itself, but not in the form of latex source, instead operating on the field content. – Alan Munn May 07 '11 at 17:05
  • 1
    I agree that it's kind of a weird request, since just anonymizing the name doesn't really seem to achieve much. Normally when submitting papers for blind review you mainly watch for obvious self-references such as "in previous work (Smith et al. 2009) we have shown..." but otherwise leave in references as they are. – Alan Munn May 07 '11 at 17:08
  • @Alan: In my area (chemistry), we don't review that way so I would not know. As you say, 'previous work' would always make it clear who the authors are. We only have anonymous reviewers. – Joseph Wright May 07 '11 at 17:10
  • @Joseph when my field (Linguistics) shifted to true blind review (a long time ago now; probably in the 70s) the number of accepted papers by women and junior faculty increased dramatically. I'm still surprised that other fields don't have it. – Alan Munn May 07 '11 at 17:13
  • @Joseph Wright - thanks for that, I guess my solution below follows the approach you stated; @Alan Munn - I believe that my example below illustrates that only the name variable would be changed, the rest of the references remain the same... – sdaau May 07 '11 at 17:40
  • @Alan: [Well OT] I can see a few reasons why we don't do blind reviews: For the editorial offices, it would mean more work (currently, they just send out raw authors drafts, which would need to be edited for example in the 'thanks'). Quite often experimental work gives away where people work ('this was run on instrument XXX'). As we are a paper-based subject, there would be a load of refs which pointed up who the authors are. Finally, if you keep up with the area you'll immediate recognise a particular groups work. (You can usually tell who the reviewers are!) – Joseph Wright May 07 '11 at 17:53
1

Sorry, haven't yet seen the responses, but I think I got it running somewhat...

Here's the example test.bib file:

------------- NEEDED MACRO
-------------
@preamble{ "\def\ConditionalName#1{\ifx\anonme\undefined#1\else\if\anonme1{Anonymized}\else#1\fi\fi}" }

------------- DEFINITION OF ANONYMIZED VARS/NAMES
-------------
@preamble{ "\def\myname{\ConditionalName{Prof. Dr. Hortensia Audactor}}" }
@String {myname = "\myname"}

------------- BIB ENTRIES
-------------
@article{audactor2005pflanzen,
  title = {Wie Pflanzen hören... die Geheimnisse der Sonobotanik},
  author = myname,
  journal = {Draft: \url{http://www.inventionen.de/vortrag_audactor.html}},
  year = {2005}
}

Then, this is test.tex - which should show the names as they are (and there's nothing special in it):

% test.tex
%
% build with:
% pdflatex test.tex
% bibtex test
% pdflatex test.tex
% pdflatex test.tex

\documentclass{article}
\usepackage{url}
\begin{document}

\section{Content}

Blah, blah, blah \cite{audactor2005pflanzen}; blah blah.

\bigskip

% no anonymization here
\bibliographystyle{plain}
\bibliography{test}

\end{document}

... and finally, here is testanon.tex:

% testanon.tex
%
% build with:
% pdflatex testanon.tex
% bibtex testanon
% pdflatex testanon.tex
% pdflatex testanon.tex

\documentclass{article}
\usepackage{url}
\begin{document}

\section{Content}

Blah, blah, blah \cite{audactor2005pflanzen}; blah blah.

\bigskip

\def\anonme{1}
\bibliographystyle{plain}
\bibliography{test}

\end{document}

... where \def\anonme{1} is used as a "signal" that anonymization should be made.

 

Just for personal reference, here is the .tex file I used for testing:

% macrotest.tex
\documentclass{minimal}

\begin{document}

% via \newcommand:
\newcommand\ConditionalName[1]{
\ifx\anonme\undefined%
#1%
\else%
  \if\anonme1%
  {Anonymized}%
  \else%
  #1%
  \fi%
\fi%
}

% via \def, in single line (handles punctuation better)
% \def\ConditionalName#1{\ifx\anonme\undefined#1\else\if\anonme1{Anonymized}\else#1\fi\fi}

Test of \verb!\ConditionalName!: \ConditionalName{John A}, then def (\def\anonme{1}), then again: \ConditionalName{John B}, then def 0 (\def\anonme{0}), then again: \ConditionalName{John C} .. then undef (\makeatletter\let\anonme\@undefined\makeatother), then again: \ConditionalName{John D} .. then def (\def\anonme{1}), then again: \ConditionalName{John E}.

\end{document}

Thanks for all the comments, I'll take a look at them now :)
Cheers!

sdaau
  • 17,079