LaTeX forum ⇒ 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.
samfaith
Posts: 4
Joined: Mon Nov 17, 2014 12:44 am

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

Postby samfaith » Mon Nov 17, 2014 12:48 am

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?!
  1. \documentclass{article}
  2. \usepackage{filecontents}%
  3. %\usepackage[style=authoryear,natbib]{biblatex}
  4. \usepackage[style=apa,backref=true,backend=biber,natbib=true,hyperref=true] {biblatex}
  5. \usepackage[american]{babel}
  6. \DeclareLanguageMapping{american}{american-apa}
  7.  
  8. \begin{filecontents*}{apabibli1.bib}
  9. @article{Sampson1989,
  10. author = {Sampson, R J and Groves, W B},
  11. year = {1989},
  12. title = {Community structure and crime: testing social-disorganization theory},
  13. volume = {94},
  14. number = {4},
  15. journal = {Am J Soc},
  16. pages = {774}
  17. }
  18. @book{Rijsbergen1979,
  19. author = {Rijsbergen, C V},
  20. year = {1979},
  21. title = {Information retrieval},
  22. address = {London},
  23. publisher = {Butter Worths}
  24. }
  25. \end{filecontents*}
  26. \addbibresource{apabibli1.bib}
  27. \renewcommand*{\labelnamepunct}{\addspace}
  28. \usepackage{xpatch}
  29. \xpatchbibmacro{author}
  30. {%
  31. \newunit\newblock
  32. }
  33. {%
  34. \setunit{\addspace}\newblock
  35. }{}{}
  36. \xpatchbibmacro{name:apa:last-first}
  37. {%
  38. \addcomma\addlowpenspace\mkbibnamefirst{#3}\isdot
  39. }
  40. {%
  41. \addlowpenspace\mkbibnamefirst{#3}\isdot
  42. }{}{}
  43. \renewbibmacro*{journal+issuetitle}{%
  44. \usebibmacro{journal}%
  45. \setunit*{\addspace\thinspace}%
  46. \iffieldundef{series}
  47. {}
  48. {\newunit
  49. \printfield{series}
  50. \setunit{\addspace}}%
  51. \printfield{volume}%
  52. \printfield{number}%
  53. \setunit{\addspace}\newblock
  54. \usebibmacro{issuename}%
  55. \newunit}
  56. \AtBeginBibliography{\renewcommand*{\finalnamedelim}{%
  57. \ifthenelse{\value{listcount}>\maxprtauth}
  58. {}
  59. {\ifthenelse{\value{liststop}>2}
  60. {\addcomma\space}%
  61. {\addcomma\space}}}}
  62. \renewcommand\bibinitperiod{}
  63. \renewcommand\bibinitdelim{}
  64. \renewcommand\bibpagespunct{\addcolon\space}
  65. \DeclareFieldFormat{journaltitle}{#1}
  66. \DeclareFieldFormat[article]{volume}{\apanum{#1}}
  67. \DeclareFieldFormat{title}{\iffieldequalstr{titleisdescription}{true}
  68. {\mkbibbrackets{#1}}{#1\isdot}}
  69.  
  70. \renewcommand*{\finentrypunct}{\relax}
  71. \setlength{\bibhang}{1.2em}
  72. \usepackage[colorlinks]{hyperref}
  73. \usepackage{hyperref}
  74. \hypersetup{
  75. colorlinks = true,
  76. citecolor = blue,
  77. linkcolor = blue,
  78. urlcolor=blue
  79. }
  80. \begin{document}
  81. \citealt{Sampson1989, Rijsbergen1979}\\
  82. \citet{Sampson1989, Rijsbergen1979}\\
  83. \citep{Sampson1989, Rijsbergen1979}\\
  84. \citeauthor{Sampson1989}
  85. \nocite{*}
  86. \printbibliography
  87. \end{document}


I need your help please :cry:

User avatar
Johannes_B
Site Moderator
Posts: 4097
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Nov 17, 2014 5:53 pm

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

Postby samfaith » Tue Nov 18, 2014 10:44 am

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: 4097
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Nov 18, 2014 5:41 pm

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

Postby samfaith » Sat Nov 22, 2014 10:59 am

I don't know how I use this command. I try to use it this :
  1. \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: 4097
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Nov 22, 2014 1:03 pm

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.


Return to “BibTeX, biblatex and biber”

Who is online

Users browsing this forum: No registered users and 6 guests