BibTeX, biblatex and biberWhy only the year is as a link in \cite reference

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
samfaith
Posts: 4
Joined: Mon Nov 17, 2014 12:44 am

Why only the year is as a link in \cite reference

Post by samfaith »

I have a problem in citing references with \cite, I have only the year as a link. I want to display the author and year as a single link. I don't know where the problem is?!

Code: Select all

\documentclass{article}
   \usepackage{filecontents}%
   %\usepackage[style=authoryear,natbib]{biblatex}
   \usepackage[style=apa,backref=true,backend=biber,natbib=true,hyperref=true]    {biblatex} 
  \usepackage[american]{babel}
  \DeclareLanguageMapping{american}{american-apa}

  \begin{filecontents*}{apabibli1.bib}
  @article{Sampson1989,
  author = {Sampson, R J and Groves, W B},
  year = {1989},
  title = {Community structure and crime: testing social-disorganization theory},
  volume = {94},
  number = {4},
  journal = {Am J Soc},
  pages = {774}
  }
 @book{Rijsbergen1979,
 author = {Rijsbergen, C V},
 year = {1979},
 title = {Information retrieval},
 address = {London},
 publisher = {Butter Worths}
 }
\end{filecontents*}
\addbibresource{apabibli1.bib}
  \renewcommand*{\labelnamepunct}{\addspace}
  \usepackage{xpatch}
  \xpatchbibmacro{author}
 {%
 \newunit\newblock
  }
  {%
  \setunit{\addspace}\newblock
   }{}{}
   \xpatchbibmacro{name:apa:last-first}
   {%
   \addcomma\addlowpenspace\mkbibnamefirst{#3}\isdot
   }
 {%
 \addlowpenspace\mkbibnamefirst{#3}\isdot
 }{}{}
 \renewbibmacro*{journal+issuetitle}{%
 \usebibmacro{journal}%
 \setunit*{\addspace\thinspace}%
 \iffieldundef{series}
 {}
 {\newunit
 \printfield{series}
  \setunit{\addspace}}%
   \printfield{volume}%
  \printfield{number}%
  \setunit{\addspace}\newblock
   \usebibmacro{issuename}%
   \newunit}
   \AtBeginBibliography{\renewcommand*{\finalnamedelim}{%
   \ifthenelse{\value{listcount}>\maxprtauth}
   {}
   {\ifthenelse{\value{liststop}>2}
   {\addcomma\space}%
   {\addcomma\space}}}}
   \renewcommand\bibinitperiod{}
   \renewcommand\bibinitdelim{}
    \renewcommand\bibpagespunct{\addcolon\space}
    \DeclareFieldFormat{journaltitle}{#1} 
    \DeclareFieldFormat[article]{volume}{\apanum{#1}}
    \DeclareFieldFormat{title}{\iffieldequalstr{titleisdescription}{true}
     {\mkbibbrackets{#1}}{#1\isdot}}

   \renewcommand*{\finentrypunct}{\relax}
  \setlength{\bibhang}{1.2em}
  \usepackage[colorlinks]{hyperref}
  \usepackage{hyperref}
  \hypersetup{
   colorlinks   = true,
   citecolor    = blue,
   linkcolor = blue,
   urlcolor=blue
   }
   \begin{document}
   \citealt{Sampson1989, Rijsbergen1979}\\
   \citet{Sampson1989, Rijsbergen1979}\\
   \citep{Sampson1989, Rijsbergen1979}\\
   \citeauthor{Sampson1989}
   \nocite{*}
   \printbibliography
   \end{document} 
I need your help please :cry:

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Why only the year is as a link in \cite reference

Post by Johannes_B »

Hi and welcome, a look into the documentation reveals the following:
Refactored hyperref to only link from years to make it consistent across cite commands
So, this is by design.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
samfaith
Posts: 4
Joined: Mon Nov 17, 2014 12:44 am

Re: Why only the year is as a link in \cite reference

Post by samfaith »

Thanks for your repley, but I want to display the author and the year as a single link, any help please?
Last edited by samfaith on Wed Nov 19, 2014 9:22 am, edited 1 time in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Why only the year is as a link in \cite reference

Post by Johannes_B »

You have to either enclose all ocurrences of any names in \printtext[bibhyperref]{}, which will simply add yet another link, or somehow try to enclose the whole string of the citation within \printtext[bibhyperref]{}.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
samfaith
Posts: 4
Joined: Mon Nov 17, 2014 12:44 am

Why only the year is as a link in \cite reference

Post by samfaith »

I don't know how I use this command. I try to use it this :

Code: Select all

\printtext[bibhyperref]{\cite {Li2001}}
But I have an error:
Undefined control sequence \printtext[bibhyperref]{\cite {Li2001}}
Any help please, I need the reponse to submit my paper?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Why only the year is as a link in \cite reference

Post by Johannes_B »

I am not very experienced in modyfying biblatex styles. And i have to say, the effort isn't worth it. The author of biblatex-apa had some good reasons to do it the way it is (it was changed at a later point).

How are you submitting your paper? The chances are pretty high, that they will do stuff with your files anyway.

Modifying the style would take me hours, if your editor rejects the paper, because the expected style isn't applied, all my work would have been useless.

http://tex.stackexchange.com/q/213407/37907
http://tex.stackexchange.com/q/212495/37907
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply