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.
Best Answer
This uses my
readarray
package. It relies on there being space separators between fields, and exactly 3 fields in each row:<variable> = <value>
. See ADDENDUM for improved version.EDITED (12/2016) to use preferred syntax of upgraded
readarray
package, namely,\MyDat[\arabic{datacount},3]
in lieu of deprecated\arrayij{MyDat}{\arabic{datacount}}{3}
. Likewise,\readarray\data\MyDat[-,3]
in lieu of\readArrayij{\data}{MyDat}{3}
.Note also that
\value{datacount}
of original answer was necessarily revised to\arabic{datacount}
, as well.ADDENDUM
Note that with latest
readarray
package version, the field separator can be set to other characters or strings. Thus, for this application, it would be preferable to set the field separator as the=
character (using\readarraysepchar{=}
), so that spaces around the=
sign are not a requirement. Then, using the starred version of the new/improved\readarray
, leading/trailing spaces can be excised automatically from the data. Thus, the best version of the above code, producing identical results, can be given as