Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Alias for Bibtex Keys

653 views
Skip to first unread message

P. Peters

unread,
Mar 18, 2009, 1:22:13 PM3/18/09
to
Suppose I have '@article{a, ...}'. Then I can cite the article using the
Bibtex key 'a', i.e., '\cite{a}'. Now I want a second key 'b' to act exactly
in the same way, so that I can use '\cite{a}' and '\cite{b}' interchangeably.

There is a suggestion to be found in the archives, which introduces a
'aliasbib' command:

\makeatletter
\def\aliasbib#1#2{\expandafter\xdef
\csname b@#1\endcsname{\csname b@#2\endcsname}}
\makeatother

With that I can say '\aliasbib{b}{a}', and then I've got what I wanted
_provided_ that I do a '\cite{a}', i.e., use the original key, at least once
in the document. This make that approach essentially useless for me.

Question 1: Is there a better way to do it?


It would be acceptable to simply duplicate the Bibtex entry in order to have
'a' and 'b'. That would result in two entries in the bibliogaphy if one uses
both keys in the same document, but it is not intended to support that. It is
okay if one has to stick to one of the keys per document.

Now, it looks quite clumsy to me to really duplicate Bibtex entries manually.
However, how about using a different markup to _store_ the database of
references (maybe something XML-based, although I'd prefer something else
maybe), which can be exported into Bibtex format? Then one could have this
markup support "aliases", which would mean that duplicate Bibtex entries
would be created, each with one of the different keys specified.

There seem to be tons of Bibtex conversion tools out there.

Question 2: Which one would allow that kind of functionality?


Thank you!

tyler

unread,
Mar 18, 2009, 1:55:14 PM3/18/09
to
"P. Peters" <p.peters_no...@invalid.invalid> writes:

> Suppose I have '@article{a, ...}'. Then I can cite the article using the
> Bibtex key 'a', i.e., '\cite{a}'. Now I want a second key 'b' to act exactly
> in the same way, so that I can use '\cite{a}' and '\cite{b}' interchangeably.

Out of curiosity, why? I've gone to some trouble to make sure that I
have meaningful, consistent keys in my bibtex database, what advantage
is there to arbitrarily changing them with each paper you write?

I'm not trying to be irritating, but maybe there's a better approach to
solve the underlying issue you are dealing with.

Cheers,

Tyler


--
Philosophy of science is about as useful to scientists as ornithology is
to birds. --Richard Feynman

P. Peters

unread,
Mar 18, 2009, 2:40:38 PM3/18/09
to
tyler <tyler...@mail.mcgill.ca> writes:
> "P. Peters" <p.peters_no...@invalid.invalid> writes:
>
>> Suppose I have '@article{a, ...}'. Then I can cite the article using the
>> Bibtex key 'a', i.e., '\cite{a}'. Now I want a second key 'b' to act exactly
>> in the same way, so that I can use '\cite{a}' and '\cite{b}' interchangeably.
>
> Out of curiosity, why? I've gone to some trouble to make sure that I
> have meaningful, consistent keys in my bibtex database, what advantage
> is there to arbitrarily changing them with each paper you write?
>
> I'm not trying to be irritating, but maybe there's a better approach to
> solve the underlying issue you are dealing with.

Maybe.

We intend to switch from one naming scheme to another. New entries are made
using the new scheme. Old entries should be available under the old scheme
(in order not to break old documents) and also under the new scheme. There
should be only one database for all documents, so that in case, e.g., someone
fixes a mistake, it takes effect for all documents immediately.

So what I am looking for are aliases intended for backward-compatibility.

jon

unread,
Mar 18, 2009, 3:04:05 PM3/18/09
to
On Mar 18, 1:22 pm, "P. Peters"

<p.peters_no_mail_ple...@invalid.invalid> wrote:
> Suppose I have '@article{a, ...}'. Then I can cite the article using the
> Bibtex key 'a', i.e., '\cite{a}'. Now I want a second key 'b' to act exactly
> in the same way, so that I can use '\cite{a}' and '\cite{b}' interchangeably.
>
> There is a suggestion to be found in the archives, which introduces a
> 'aliasbib' command:
>
> \makeatletter
> \def\aliasbib#1#2{\expandafter\xdef
> \csname b@#1\endcsname{\csname b@#2\endcsname}}
> \makeatother
>
> With that I can say '\aliasbib{b}{a}', and then I've got what I wanted
> _provided_ that I do a '\cite{a}', i.e., use the original key, at least once
> in the document. This make that approach essentially useless for me.

why? if you're willing to add in a whole new 'aliasbib' command, why
can't you also add a \nocite{a} to the beginning of your document?
(not that i've tried what you're suggesting yet....)

cheers,
jon.

Turgut Durduran

unread,
Mar 18, 2009, 3:30:51 PM3/18/09
to

my two cents because I have a similar issue sometimes too. multiple,
independent investigators have their own bibtex files and it is not
feasible to enforce a common naming scheme. so, when I get a chunk of a
file from someone else I laborously edit it to match mine.

what I would be needing is something that takes the lists and matches
them. say aliases them. I do the laborious work once. then the other other
can continue to use whatever he/she wants to use. but "XY2000" and
"2000XY" not only refer to same citation but also appear only once, i.e.

"I did \cite{XY2000} in year 2000 ....... She also did it in year
2000\cite{2000XY}"

returns something like

"I did[1] in year 2000 ....... She also did it in year 2000[1]
[1] I and she , 20000"

tyler

unread,
Mar 18, 2009, 4:23:26 PM3/18/09
to
"P. Peters" <p.peters_no...@invalid.invalid> writes:

Ok, I understand that. I don't know how a solution, though, sorry.

Cheers,

Tyler

--
I never loan my books, for people never return them. The only books
remaining in my library are those I’ve borrowed from others.
--unknown

Pavel Iosad

unread,
Mar 19, 2009, 9:54:43 AM3/19/09
to
Hello,

P. Peters skreiv:


> Suppose I have '@article{a, ...}'. Then I can cite the article using the
> Bibtex key 'a', i.e., '\cite{a}'. Now I want a second key 'b' to act exactly
> in the same way, so that I can use '\cite{a}' and '\cite{b}' interchangeably.

I believe crosstex (http://www.cs.cornell.edu/people/egs/crosstex/) has
this functionality, but I have not tried it.

HTH,
Pavel

P. Peters

unread,
Mar 19, 2009, 10:05:11 AM3/19/09
to
Pavel Iosad <edri...@gmail.com> schrieb:

The description of that tool reads great.

I will try an report here later.

Thank you!

Turgut Durduran

unread,
Mar 19, 2009, 1:20:47 PM3/19/09
to


it sounds interesting. Is it a viable project that appears to be surviving
the test of time?

Also, it does require some changes in behavior. from the FAQ..

# Is CrossTeX compatible with BibTex? Yes, it reads .BIB files and
generates .BBL files to be used with LaTeX. If you are not using a custom
BibTex style file, you should be able to use CrossTeX instead of BibTex. It
supports the abbrv, alpha, full and plain styles of BibTex.

If you are using a BibTex style file, you are probably using some
goobledygook that someone kludged together without understanding, and
chances are that no mortal will be able to translate it into anything
reasonable. But you can probably write something from scratch in half an
hour that'll do what you want in CrossTeX. CrossTeX's internal programming
language is Python, a nice and clean platform that is easy to learn.

Robin Fairbairns

unread,
Mar 20, 2009, 6:24:24 AM3/20/09
to
Turgut Durduran <ug...@ugdc.org> writes:
>On 2009-03-19, Pavel Iosad <edri...@gmail.com> wrote:
>> I believe crosstex (http://www.cs.cornell.edu/people/egs/crosstex/) has
>> this functionality, but I have not tried it.
>
>it sounds interesting. Is it a viable project that appears to be surviving
>the test of time?

i've corresponded with the people involved: which is why the system is
on ctan. they seem to have their heads attached pretty firmly, so
i have hopes the project will continue its work.

>Also, it does require some changes in behavior. from the FAQ..
>
># Is CrossTeX compatible with BibTex? Yes, it reads .BIB files and
>generates .BBL files to be used with LaTeX. If you are not using a custom
>BibTex style file, you should be able to use CrossTeX instead of BibTex. It
>supports the abbrv, alpha, full and plain styles of BibTex.
>
>If you are using a BibTex style file, you are probably using some
>goobledygook that someone kludged together without understanding, and
>chances are that no mortal will be able to translate it into anything
>reasonable. But you can probably write something from scratch in half an
>hour that'll do what you want in CrossTeX. CrossTeX's internal programming
>language is Python, a nice and clean platform that is easy to learn.

sigh. (a) a large proportion of non-standard bib files nowadays come
from makebst, which produces well-structured stuff, and (b) despite
the airy hopefulness of that text, it's my experience that telling
people to program something will put a large majority off.

i hadn't noticed that text (indeed, i don't believe the faq was there
when i was looking at the project; but then i'm good at missing vital
things...).
--
Robin Fairbairns, Cambridge

Turgut Durduran

unread,
Mar 21, 2009, 9:41:04 AM3/21/09
to
On 2009-03-20, Robin Fairbairns <rf...@cl.cam.ac.uk> wrote:
> i've corresponded with the people involved: which is why the system is
> on ctan. they seem to have their heads attached pretty firmly, so
> i have hopes the project will continue its work.

I am inclined to wait a bit more and see right now , mainly because of
what I cited from the FAQ and that you commented on. I do not mind
spending half hour on major projects to figure out a new .bst but if the
project disappears suddenly and I can't use it in newer system, I am not
willing to end up with a methodology that I can't use.

Turgut

Ulrich M. Schwarz

unread,
Mar 23, 2009, 4:25:49 PM3/23/09
to
On Wed, 18 Mar 2009 18:22:13 +0100, P. Peters
<p.peters_no...@invalid.invalid> wrote:

> Suppose I have '@article{a, ...}'. Then I can cite the article using the
> Bibtex key 'a', i.e., '\cite{a}'. Now I want a second key 'b' to act
> exactly
> in the same way, so that I can use '\cite{a}' and '\cite{b}'
> interchangeably.
>
> There is a suggestion to be found in the archives, which introduces a
> 'aliasbib' command:
>
> \makeatletter
> \def\aliasbib#1#2{\expandafter\xdef
> \csname b@#1\endcsname{\csname b@#2\endcsname}}
> \makeatother
> With that I can say '\aliasbib{b}{a}', and then I've got what I wanted
> _provided_ that I do a '\cite{a}', i.e., use the original key, at least
> once
> in the document. This make that approach essentially useless for me.
>
> Question 1: Is there a better way to do it?

I think it's too late to hook in there: BibTeX will always complain about
the absence of b. You may try the following, but I've not put too much
thought into it. The syntax is \acite[stuff]{labels} which ends up as
\cite stuff{labels}, so stuff could have stars, the optional argument etc.,
I believe there's too much variation in syntax of different implementations
of \cite to handle it more gracefully. Also note it doesn't handle multiple
occurences of the same citation in one \cite gracefully. (I don't think the
ordinary \cite will handle \cite{x,x} in the meaningful way either.)
\documentclass{article}

\bibliographystyle{plain}

\makeatletter
% \bibalias{x}{y} makes \cite{x}
% equiv. to \cite{y}
\newcommand\bibalias[2]{%
\@namedef{bibali@#1}{#2}%
}

\newtoks\biba@toks
\newcommand\acite[2][]{%
\biba@toks{\cite#1}%
\def\biba@comma{}%
\def\biba@all{}%
\@for\biba@one:=#2\do{%
\@ifundefined{bibali@\biba@one}{%
\edef\biba@all{\biba@all\biba@comma\biba@one}%
}{%
\PackageInfo{bibalias}{%
Replacing citation `\biba@one' with `\@nameuse{bibali@\biba@one}'
}%
\edef\biba@all{\biba@all\biba@comma\@nameuse{bibali@\biba@one}}%
}%
\def\biba@comma{,}%
}%
\edef\biba@tmp{\the\biba@toks{\biba@all}}%
\biba@tmp
}

\makeatother

\bibalias{x}{y}

\begin{document}
An earlier version was \acite[{[p.~13]}]{x},
or was it \acite{y}?

\bibliography{bibalias}
\end{document}
@article{y,
title={Foo and the art or Bar, revised.},
author={me}
}

HTH
Ulrich

0 new messages