Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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)

share|improve this question
    
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 7 '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 7 '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 7 '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 7 '11 at 23:50

3 Answers 3

up vote 10 down vote accepted

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.

share|improve this answer
    
Have you tried this? It doesn't actually work. The @string command works on a per-bib-file basis. –  Alan Munn May 7 '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 7 '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 7 '11 at 17:16
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 7 '11 at 17:45
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 7 '11 at 17:47

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.

share|improve this answer
    
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 7 '11 at 16:57
1  
@Alan: I guess I'm used to numerical citations, where this never arises! –  Joseph Wright May 7 '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 7 '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 7 '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 7 '11 at 17:08

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.