# Web links in the bibliographical labels

The class for the AIMS journals has one nice feature: In the bibliography, one can click over the label of a bib reference and the AMS' MathReview pops out in the browser. See an example. I used to put an \href{...} after the other bib data, but the AIMS way is more elegant.

However, I don't like some other features of AIMS class (one of them is that it only allows numeric labels for bib references) and I don't want to use it.

So, how can I emulate AIMS trick without creating a whole new document class? I tried to do the following (example):

\bibitem[\href{http://www.ams.org/mathscinet-getitem?mr=1464693}{Fu}]{Fulton} Fulton, W. Young tableaux. With applications to representation theory and geometry. Cambridge Univ.\ Press, 1997.


However this doesn't work as desired: if I click on a [Fu] link in the middle of the PDF then I'd like to jump to the Bibliography section (as usual everywhere and also in AIMS class), not to open the browser.

To summarize, the question is how to create those links for MR (or ArXiv or DOI or whatever) over the reference label when it appears in the bibliography section, while links in the main text work as normal (namely, point to the bibliography section).

-
is it true that the link in the bibliography is live if you use the class file linked from your message (hyperref is commented out), or are you referring only to published articles? the aims class is modified from amsart.cls, which has many/most of the same features, and doesn't restrict one to a numbered bibliography. the biblio requirements aren't built into the class; they must be added with \bibliographystyle (if using bibtex) and perhaps a package (if using natbib), or with amsrefs. you must also explicitly \usepackage{hyperref} to make links live. – barbara beeton Dec 23 '11 at 13:27
Thanks for your answer. I'm not referring only to published articles; I actually tested the AIMS.cls. You're right, AIMS.cls is modified from amsart.cls; but they changed several things (section headers is another example). So I'd prefer to keep using amsart than try to fix the numbered bibliography as you suggested. I'm ok with loadind hyperref package; I always do that. I don't like bibtex. – Jairo Bochi Dec 24 '11 at 10:28

Here is my aproach. There are two macros which are responsible for creating the items in the references: \@lbibitem and \@bibitem. You can find it in latex.ltx. The first macro is for items with optional argument, the other one without argument. With this knowledge we can create our own bibitem which we can use together with the standard items in one bibliography.

\documentclass{article}
\usepackage{color}

\makeatletter

% branch between the items with and without optional argument
\def\myhyperbibitem{\@ifnextchar[\my@lbibitem\my@bibitem}

% format the bibitem number incl. the url hyperlink
\def\mybiblabel#1#2{\@biblabel{\textcolor{magenta}{\hyperref{#1}{}{}{#2}}}}

% create a 'label' for referencing from citation in the text to the biblography

% this is just to highlight the citations in the text because the 'hidelinks' argument
% in the hyperref package. I don't like the boxes around the links.
% it is unimportant for our bibitems
\def\@cite#1#2{[\textcolor{magenta}{{#1\if@tempswa , #2\fi}}]}

% bibitem with optional argument
\def\my@lbibitem[#1]#2#3{%
\item[\mybiblabel{#2}{#1}\myhyperanchor{#3}\hfill]%
\if@filesw{\let\protect\noexpand\immediate% write to aux-file
\write\@auxout{\string\bibcite{#3}{#1}}}\fi\ignorespaces%
}

% bibitem without optional argument
\def\my@bibitem#1#2{%
\refstepcounter\@listctr% standard tex item counter for the generic item number
\item[\mybiblabel{#1}{\the\value\@listctr}\myhyperanchor{#2}\hfill]%
\if@filesw\immediate\write\@auxout% write to aux-file
{\string\bibcite{#2}{\the\value\@listctr}}\fi\ignorespaces%
}

\makeatother

\begin{document}
Lorem ipsum dolor sit amet\cite{Fulton}, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit sed pharetra\cite{FAQ} amet enim. Suspendisse id velit vitae ligula\cite{Tolkin} volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. MoVivamus pharetra\cite{Stack} posuere sapien. Nam consectetuer. Sed aliquam, nunc eget euismod ullamcorper\footnote{lectus\cite{Cooking} nunc Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mo  ullamcorperorci} fermentum bibendum  enim nibh eget ipsum\cite{Silmarillion}. Donec porttitor ligula eu dolonsectetuer. Sed aliquam, nunc eget euismod ullam or. Maecenas vitae\cite{Hobbit} nulla consequat libero cursus venenatis. Nam magna enim, accumsan eu, blandit sed, blandit a, eros.

\newpage
\begin{thebibliography}{}

\myhyperbibitem[Fu]{http://www.amazon.de/Young-Tableaux-Applications-Representation-Mathematical/dp/0521567246}%
{Fulton} Fulton, W. Young Tableaux: With Applications to Representation Theory and Geometry (London Mathematical Society Student Texts)

\myhyperbibitem[St]{http://tex.stackexchange.com/}{Stack} Stackexchange -- Tex

\bibitem{FAQ}UK List of TeX Frequently Asked Questions

\bibitem[Ho]{Hobbit} The Hobbit \url{http://www.amazon.de/The-Hobbit-ebook/dp/B002RI9ZY0}

\myhyperbibitem{http://www.amazon.de/Cooking-Geeks-Science-Great-Hacks/dp/0596805888/ref=sr_1_2?ie=UTF8&qid=1326013214&sr=8-2}%
{Cooking} Cooking for Geeks: Real Science, Great Hacks, and Good Food

\myhyperbibitem[Si]{http://www.amazon.de/gp/product/B004L9MFAY/ref=s9_simh_gw_p351_d0_g351_i3?pf_rd_m=A3JWKAKR8XB7XF&pf_rd_s=center-2&pf_rd_r=0YWAQ6CE1DS71NT68Z3T&pf_rd_t=101&pf_rd_p=463375173&pf_rd_i=301128}%
{Silmarillion} The Silmarillion [Kindle Edition] -- new style bibitem --

\bibitem{Tolkin} The Silmarillion [Kindle Edition]   -- old style bibitem --\\ \url{http://www.amazon.de/gp/product/B004L9MFAY/ref=s9_simh_gw_p351_d0_g351_i3?pf_rd_m=A3JWKAKR8XB7XF&pf_rd_s=center-2&pf_rd_r=0YWAQ6CE1DS71NT68Z3T&pf_rd_t=101&pf_rd_p=463375173&pf_rd_i=301128}

\end{thebibliography}
\end{document}


Ok, to support the backref option we have to add one argument and the \par to each macro. Furthermore we use the \BR@backref command from the backref package to print the back references. But before printing we shouldt check if the backref option is active by the use of 'ifbackrefparscan'. This boolean is defined only if the hyperref loaded the backref package.

\def\my@lbibitem[#1]#2#3#4\par{%
\item[\mybiblabel{#2}{#1}\myhyperanchor{#3}]#4%
\@ifundefined{ifbackrefparscan}{}{\BR@backref{#3}}%
\if@filesw{\let\protect\noexpand\immediate%
\write\@auxout{\string\bibcite{#3}{#1}}}\fi\ignorespaces%
}

\def\my@bibitem#1#2#3\par{%
\refstepcounter\@listctr%
\item[\mybiblabel{#1}{\the\value\@listctr}\myhyperanchor{#2}]#3%
\@ifundefined{ifbackrefparscan}{}{\BR@backref{#2}}%
\if@filesw\immediate\write\@auxout%
{\string\bibcite{#2}{\the\value\@listctr}}\fi\ignorespaces%
}

-
That was amazing! Thanks! I have still another question: Can you make that work with the backref=page option offered by the hyperref package? – Jairo Bochi Jan 8 '12 at 16:21
err... sorry, but I have still another question. I've started to use these tricks. My bibliography contains both \myhyperbibitem's and old style \bibitem's. But \myhyperbibitem's labels are right-justified while \bibitem's are left-justified. Do you guys know how to make \myhyperbibitem's labels right-justified? Thanks. – Jairo Bochi Jan 10 '12 at 7:44
I forgot to place the '\hfill' command in my second version. Like in the first version (after the 'myhyperanchor{}') you can place the command on the right of the label for left side justification or to the left for right side justification. – Holle Jan 10 '12 at 11:13