1

The following is what I am doing now.

\documentclass[11pt,english]{extarticle}
\usepackage{listings}
\lstset{language=Matlab}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{booktabs}
\usepackage{float}
\usepackage{color}
\usepackage[title,titletoc,toc]{appendix}
\usepackage[nohead]{geometry}
\usepackage[bottom]{footmisc}
\usepackage{endnotes}
\usepackage{graphicx}
\usepackage[center,bf]{caption}
\usepackage{morefloats}
\usepackage{epstopdf}
\usepackage{rotating}
\usepackage{enumerate}
\usepackage{bbm}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\numberwithin{equation}{section}
\usepackage{fancyhdr}
\setlength{\parindent}{24pt}
\setlength{\headheight}{0in}
\usepackage{longtable}
\usepackage{import}
\usepackage{natbib}
\setlength{\bibsep}{0pt plus 0.3ex}
\usepackage{microtype}

\usepackage{multirow} \usepackage{adjustbox}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{verbatim} \usepackage{setspace} \linespread{1.3} \usepackage{pdflscape} \usepackage{subcaption} \usetikzlibrary{arrows,calc} \usepackage{setspace} \usepackage{ragged2e}

%%%%%%%%%%% Suppress Warning \usepackage{silence} \WarningFilter{latex}{Text page} \WarningFilter{natbib}{Citation} \WarningFilter{natbib}{There}

\usepackage{changepage} \newlength{\wideitemsep} \setlength{\wideitemsep}{\itemsep} \addtolength{\wideitemsep}{5pt} \let\olditem\item \renewcommand{\item}{\setlength{\itemsep}{7pt}\olditem}

\newcommand{\sym}[1]{{#1}}

\long\def/#1/{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Make Title appear in the top of the page %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{titling} %\setlength{\droptitle}{-4em} \setlength{\droptitle}{-2em}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Directly brought from Lyx %%%% \usepackage[T1]{fontenc} \geometry{verbose,tmargin=2.7cm,bmargin=2.7cm,lmargin=2.5cm,rmargin=2.5cm} \usepackage{amsthm}

\makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands. \theoremstyle{plain} \newtheorem{thm}{\protect\theoremname} \theoremstyle{plain} \newtheorem{prop}[thm]{\protect\propositionname} \ifx\proof\undefined \newenvironment{proof}[1][\protect\proofname]{\par \normalfont\topsep6\p@@plus6\p@\relax \trivlist \itemindent\parindent \item[\hskip\labelsep\scshape #1]\ignorespaces }{% \endtrivlist@endpefalse } \providecommand{\proofname}{Proof} \fi \theoremstyle{plain} \newtheorem{cor}[thm]{\protect\corollaryname}

\makeatother

\usepackage{babel} \providecommand{\corollaryname}{Corollary} \providecommand{\propositionname}{Proposition} \providecommand{\theoremname}{Theorem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This package makes you cross-reference across different tex files. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{xr-hyper} \usepackage[colorlinks=true,urlcolor=blue, linkcolor=blue, citecolor=blue]{hyperref} \hypersetup{ filecolor=black }

\makeatletter \newcommand*{\addFileDependency}[1]{ \typeout{(#1)} @addtofilelist{#1} \IfFileExists{#1}{}{\typeout{No file #1.}} } \makeatother

\newcommand*{\myexternaldocument}[1]{ \externaldocument{#1} \addFileDependency{#1.tex} \addFileDependency{#1.aux} } %%% END HELPER CODE

\myexternaldocument{online_appendix}

\begin{document}

\newpage{} \setcounter{page}{1}

\section{Introduction} \label{section:introduction}

Words\footnote{hi}

Citation examples:

\cite{Coase1992AER}

\newpage{}

\begin{singlespacing} %\nocite{*} \bibliographystyle{aer} \bibliography{Reference} \end{singlespacing}

\end{document}

The reference I am using is

@article{Coase1992AER,
  title={The Institutional Structure of Production},
  author={Ronald H. Coase},
  journal={American Economic Review},
  volume={82},
  number={4},
  pages={713---719},
  year={1992}
}

Then, what happens is I get two separate links.

I correctly get this

enter image description here

But if I hover my mouse over the author name, this link applies only to the author name

enter image description here

IF I hover my mouse over the year, this link applies only to the year part.

enter image description here

But the standard way to make hyperlink is to create one unified link across the author names and the year, correct? Then I want to follow the standard practice. How can I do that?


Addendum: The same material as before, but now in the form of a minimum working example or MWE:

\documentclass[11pt,english]{extarticle}
\begin{filecontents}[overwrite]{Reference.bib}
@article{Coase1992AER,
  title  ={The Institutional Structure of Production},
  author ={Ronald H. Coase},
  journal={American Economic Review},
  volume ={82},
  number ={4},
  pages  ={713-719},
  year   ={1992}
}
\end{filecontents}

\usepackage{natbib} \bibliographystyle{aer}

\usepackage{babel} \usepackage[T1]{fontenc} \usepackage[colorlinks=true,urlcolor=blue, linkcolor=blue, citecolor=blue, filecolor=black]{hyperref}

\begin{document} \cite{Coase1992AER} \bibliography{Reference} \end{document}

Mico
  • 506,678
user1849133
  • 217
  • 2
  • 7
  • 1
    I'm not sure if we can say there is a standard way that would imply that the entire citation has to be linked in one go. I don't know the exact implementation and rationale in natbib, but in biblatex the author is usually not linked at all and linking it and the year in one go would make things significantly more fiddly in the implementation. ... – moewe Oct 02 '22 at 05:44
  • 1
    ... I guess it is similar for natbib. If you cite a second work by the same author from a different year, say, \cite{Coase1992AER,Coase1993} gives you "Coase (1992, 1993)". It's not clear which source the name should link to here (granted, this may not be a strong argument in your book, as you could just pick one), but here linking in one go is not really possible as you have two works and you have to split the link somewhere to take your readers to both works. Frankly, I wouldn't bother. – moewe Oct 02 '22 at 05:46
  • 3
    For future questions you may want to consider reducing the code you post a bit to focus on the relevant parts only. The preamble contains a bunch of packages that have no impact on bibliography, citations and links. And it's a nice gesture to show that you value the time of those who read your question to try and present them with only the necessary code. – moewe Oct 02 '22 at 05:48
  • Off-topic: With pages={713---719}, LaTeX will employ an em-dash as the connector between the page numbers. That's highly unusual, to put it mildly. Do consider changing the field to pages={713--719}. – Mico Oct 02 '22 at 06:41
  • I've taken the liberty of condensing your code into an MWE. Feel free to revert. – Mico Oct 02 '22 at 06:50

1 Answers1

0

You wrote

But the standard way to make [a] hyperlink is to create one unified link across the author names and the year, correct? Then I want to follow the standard practice. How can I do that?

I would like to begin by echoing the view that @moewe has expressed in a comment, that there may not be a single, let alone "standard", way to create a hyperlink from an author-year style citation call-out to the corresponding formatted bibliographic entry. AFAICT, having the citation call-out feature two separerate hyperlinks or a single, unified hyperlink is equally good. For sure, I can't see readers ever getting confused by the fact that a citation call-out may contain two separate hyperlinks.

A solution to your question is actually readily available in Audrey B.'s answer, posted in 2011, to the query natbib and hyperref for (Author, Year) style produces two links. Happily, even though the code is more than 11 years old by now, it would appear to continue to work just fine. This could be due to the fact that the natbib package hasn't experienced any major changes either over this time period.

Consider the following example and associated screenshot. The citation call-outs produced by \citet{Coase1992AER} and \citep{Coase1992AER} are now single hyperlinks. And, in the citation callout "(Coase, 1992a,b, 1993)", the particles Coase, 1992a, b, and 1993 are 3 separate hyperlinks, not 4. Aside: observe that the parentheses that surround the output of \citep are not part of the hyperlink. This practice is "standard" for the natbib citation management package.

enter image description here

\documentclass[11pt,english]{extarticle}

%% Create a bib file on the fly: \begin{filecontents}[overwrite]{Reference.bib} @article{Coase1992AER, title ={The Institutional Structure of Production}, author ={Ronald H. Coase}, journal={American Economic Review}, volume ={82}, number ={4}, pages ={713-719}, year ={1992}, } @misc{Coase1992alt, title={Thoughts}, author={Ronald H. Coase}, year=1992} @misc{Coase1993, title={Further Thoughts}, author={Ronald H. Coase}, year=1993} \end{filecontents}

\usepackage[sort,round]{natbib} \bibliographystyle{plainnat} % or some other suitable bibliography style

\usepackage{babel} \usepackage[T1]{fontenc} \usepackage[colorlinks=true,citecolor=blue]{hyperref}

%% The following code block is copied straight from Audrey B.'s answer %% given at https://tex.stackexchange.com/a/27235/5001

\usepackage{etoolbox}

\makeatletter

\pretocmd{\NAT@citex}{% \let\NAT@hyper@\NAT@hyper@citex \def\NAT@postnote{#2}% \setcounter{NAT@total@cites}{0}% \setcounter{NAT@count@cites}{0}% \forcsvlist{\stepcounter{NAT@total@cites}@gobble}{#3}}{}{} \newcounter{NAT@total@cites} \newcounter{NAT@count@cites} \def\NAT@postnote{}

% include postnote and \citet closing bracket in hyperlink \def\NAT@hyper@citex#1{% \stepcounter{NAT@count@cites}% \hyper@natlinkstart{@citeb@extra@b@citeb}#1% \ifnumequal{\value{NAT@count@cites}}{\value{NAT@total@cites}} {\ifNAT@swa\else\if\NAT@postnote\else% \NAT@cmt\NAT@postnote\global\def\NAT@postnote{}\fi\fi}{}% \ifNAT@swa\else\if\relax\NAT@date\relax \else\NAT@@close\global\let\NAT@nm@empty\fi\fi% avoid compact citations \hyper@natlinkend} \renewcommand\hyper@natlinkbreak[2]{#1}

% avoid extraneous postnotes, closing brackets \patchcmd{\NAT@citex} {\ifNAT@swa\else\if#2\else\NAT@cmt#2\fi \if\relax\NAT@date\relax\else\NAT@@close\fi\fi}{}{}{} \patchcmd{\NAT@citex} {\if\relax\NAT@date\relax\NAT@def@citea\else\NAT@def@citea@close\fi} {\if\relax\NAT@date\relax\NAT@def@citea\else\NAT@def@citea@space\fi}{}{}

\makeatother %% end of copied code block

\begin{document} \citet{Coase1992AER}, \citep{Coase1992AER}

\citep{Coase1992AER,Coase1993,Coase1992alt}

\bibliography{Reference} \end{document}

Mico
  • 506,678