2

I converted citation format to alphabetical according to this answer. But, it created an abnormal behavior in hyperref. Although the citations are still clickable in the PDF, nothing happens when I click on them. (With hyperref, when a citation is clicked, it should be dereferenced and the PDF viewer should jump to bibliography page where the citation was declared.)

MWE:

\documentclass[12pt]{article}
\usepackage{hyperref, lipsum}
\makeatletter
\renewcommand\@bibitem[1]{\item\if@filesw \immediate\write\@auxout{%
\string\bibcite{#1}{\theenumiv}}\fi\ignorespaces} %%% instead of \the\value{\@listctr}

\renewenvironment{thebibliography}[1]
     {\section*{\refname}
      \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
      \list{\@biblabel{\alph{enumiv}}}% %% instead of "\@arabic\c@enumiv"
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\alph{enumiv}}}% 
                                    %% instead of "\@arabic\c@enumiv"
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
    {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
\makeatother

\begin{document}
\lipsum[1]
\cite{A1}
\lipsum[2]
\pagebreak
\begin{thebibliography}{9}
\bibitem{A1}{John (2011)} 
\bibitem{B1}{Carl (2015)}
\end{thebibliography}
\end{document}

Any idea how to fix it? I am using XeLaTeX engine to compile the document. (Because I intend to use package polyglossia later.)

My attempts to identify the problem:

After a little investigation, it became clear that when I renewed only \@bibitem command and not \thebibliography environment, the citation dereferencing error still remained.

Then I tried the following code, which is completely identical to the original definition of \@bibitem according to the LaTeX Bibliography manual. The error is here too.

Can anyone explain what is exactly happening?

\documentclass[12pt]{article}
\usepackage{hyperref, lipsum}
\makeatletter
\renewcommand\@bibitem[1]{\item\if@filesw \immediate\write\@auxout{%
\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces}
\makeatother

\begin{document}
\lipsum[1]
\cite{A1}
\lipsum[2]
\pagebreak
\begin{thebibliography}{9}
\bibitem{A1}{John (2011)} 
\bibitem{B1}{Carl (2015)}
\end{thebibliography}
\end{document}
  • Just a suggestion: why not use BibTeX or Biber in conjunction with biblatex? In the same question you linked there's a solution for biblatex by lockstep – Guilherme Zanotelli Dec 13 '16 at 8:41
  • The answer you appear to be referring to deals with a much more contained issue, viz., how to change the numeric-type citation call-outs from the default style to a different, but fundamentally still numeric style. As such, the answer in question is not a good basis for coding a switch to an authoryear-type citation call-out style. Also, that answer makes no provisions for interacting with hyperref. Instead of modifying \@bibitem directly, I'd make use of the natbib package and provide the required new pieces of information in the optional argument of each \bibitem instruction. – Mico Dec 13 '16 at 9:35
  • @Mico, I wanted alphabetical style numbering, ie- [a] John(2011) [b] Carl(2015). And when cited I wanted them to be appear like [a], [b] etc. If you run my MWE, you'll see that's what I was doing. The author year format was used for just a sample bibliography. – zigs211567 Dec 13 '16 at 10:56
  • Thanks. I'm afraid I understand even less now what you're objective is. – Mico Dec 13 '16 at 11:02
  • @Mico, Please run my MWE, and click on the first citation (ie \cite{A1}) in the PDF. One would expect to be forwarded to the References page (ie next page), but nothing happens. That is what I want to 'fix' – zigs211567 Dec 13 '16 at 11:11
3

The main problem is that the hyperref package has to be loaded after you have redefined the bib commands since it modifies them, too. I suggest to modify \bibitem and \thebibliography a little bit less invasive.

\documentclass[12pt]{article}
\usepackage{hyperref, lipsum}
\usepackage{xpatch}
\makeatletter
\xpatchcmd\@bibitem{\the\value}{\alph}{}{}
\xpatchcmd\thebibliography{\@arabic}{\@alph}{}{}
\makeatother
\begin{document}
  • Oh, yes, classic xpatch. It worked. Thanks, @gernot – zigs211567 Dec 13 '16 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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