TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is this something that I can do with bibtex? I have a few different manuscripts with some other collaborators and it would be easier for me if I could make \cite{foo} and \cite{bar} point to the same thing. Of course there are ways to work around this by changing \cite{foo} to \cite{bar} everywhere in the manuscripts, or by duplicating bibtex entries in the .bib file, but I would rather not do these things.

share|improve this question
I have on my todo list to try out cs.cornell.edu/people/egs/crosstex, which should solve this kind of problem... – Jeremy Apr 25 '13 at 14:08

I'm not aware of any possibility to remap keys in a .bib file; if this is true (and I think it is) then this is really a shortcoming.

So my solution is based on doing the remapping in the LaTeX preamble, and as often these days I use the prop datatype of LaTeX3 as that is really useful in such circumstances.

The basic idea is to use a property list that stores the citation keys as keys and the target keys as values. Then whenever a citation command is run we look up the key and if there is a mapping we use the mapping instead. This way the .aux file will end up having only the remapped keys in it and BibTeX will only find those.



\prop_new:N \g_cite_map_prop
\tl_new:N \l_citekey_result_tl

\cs_new:Npn \mapcitekey #1#2 {
  \clist_map_inline:nn {#2}
       {  \prop_gput:Nnn  \g_cite_map_prop  {##1} {#1}   }

\cs_new:Npn \getcitekey #1 {
   \prop_get:NoN \g_cite_map_prop{#1}  \l_citekey_result_tl
   \quark_if_no_value:NF \l_citekey_result_tl
       {  \tl_set_eq:NN #1  \l_citekey_result_tl  }

\cs_new:Npn \showcitekeymaps {\prop_show:N  \g_cite_map_prop }

This gives us \mapcitekey with two arguments: the first is our major key that we want to use with BibTeX and the second is the alternate key that we want to remap. In fact the second argument can also be a comma separated list, e.g.,



This will give us

The property list \g_cite_map_prop contains the pairs (without outer braces):
>  {world}  =>  {hello}
>  {bar}  =>  {foo}
>  {baz}  =>  {foo}
>  {foobar}  =>  {foo}.

Now to look things up we have \getcitekey and what remains to be done is to patch the citation commands to make use of this key. I have done this below for \cite and \nocite from standard LaTeX. If some other citation package such as natbib is used one needs to patch its citation commands. Basically you need to look for the places where the command \citation is being written to the .aux file and the command that is used in the argument to \citation is the one that holds the key needs to be changed.

So here are the patches necessary:

\patchcmd{\@citex}{\if@filesw}{\getcitekey\@citeb \if@filesw}%
    {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}}
\patchcmd{\nocite}{\if@filesw}{\getcitekey\@citeb \if@filesw}%
    {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}}

With those definitions and the remapping above, the input

\cite{foo} \cite{bar} \cite{world} \cite{baz}

will give us the following citations in the aux file:


By the way, duplicating BibTeX entries with different keys is not going to work (as suggested in the question). That would result in getting the same reference twice.

share|improve this answer

This is a bit of a hack, it might work for you.

\newcommand\OurCite[2]{\cite{#1}}% In the source for author 1


\newcommand\OurCite[2]{\cite{#2}}% In the source for author 2

and in the document :

(...) see e.g.{} \OurCite{foo}{bar}
share|improve this answer
the OP is looking for a a way to remap from the outside and not to change all the different manuscripts he received (and perhaps get in a different version later again). If he does what you suggest then he would be easier of just to replace the cite keys directly. – Frank Mittelbach Mar 18 '12 at 22:10

Your Answer


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.