2

Running this example:

% How does 'filecontents' keep LaTeX parsing while temporarily stop writing output
% https://tex.stackexchange.com/questions/104159/how-does-filecontents-keep-latex
\RequirePackage{filecontents}

\begin{filecontents*}{references.bib}
@book{koma-scrguien,
  author = {Markus Kohm},
  edition = {2017-04-13},
  howpublished = {\url{http://mirrors.ibiblio.org/CTAN/.../scrguien.pdf}},
  publisher = {Online Material; \url{https://www.ctan.org/pkg/koma-script}},
  title = {The Guide KOMA -Script},
  urlaccessdate = {2017-08-28},
  year = {2017}
}
\end{filecontents*}

\PassOptionsToPackage{brazil,main=english}{babel}
\documentclass[
10pt,
a5paper,
twoside
chapter=TITLE,
section=TITLE
]{abntex2}
\pdfstringdefDisableCommands{\let\uppercase\relax}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[
style=abnt,
language=english,
backref=true,
backend=biber,
citecounter=true
]{biblatex}
\addbibresource{references.bib}

\usepackage{csquotes}
\hypersetup{colorlinks=true}

\begin{document}

    Citing \cite[p. 47-52 and 135]{koma-scrguien}

    \printbibliography

\end{document}

We got the following output:

enter image description here

Where the comma between KOHM and 2017 is also green. Is possible to change its color to black, like in this montage bellow?

enter image description here


Related:

  1. Biblatex, authoryear-comp, and hyperlinks
  2. Single link in (Author, Year) citation style using natbib and hyperref
  3. natbib and hyperref for (Author, Year) style produces two links
  • 3
    The whole “KOHM, 2017” is the link. I guess one could make two distinct links. – egreg Sep 16 '17 at 17:08
  • 2
    Personally, I would not do that, as that would technically and visually make it two links, which confuses the reader. As it is, the comma's just part of the one link (like @egreg already said). With the comma in black, I as a reader would definitely wonder whether the year's a second link. – magula Sep 16 '17 at 17:24
  • It would be better to have KOHM 2017 with no comma then if that is supposed to be a single link. – user4686 Sep 16 '17 at 17:46
  • Interesting! You are the first person to ask for a link to be split, normally people want more parts of the citation label to be linked in the standard styles and insist on a continuous link (and colouring). Your style explicitly links the entire label. May I ask why you want this. – moewe Sep 17 '17 at 10:02
  • @moewe, thanks for the fix! I did not liked coloring only the first comma , as the immediate second comma , is not colored. It also creates the impression of two distinct links, but I think it is nicer to have the coloring symmetry other the double link impression. We could think about coloring the second comma also , but extending a link into the remaining part would make it wrong as the reader would think the link is going to open the p. 47-52 and 135, which is not true. – user Sep 17 '17 at 13:58
4

abnt.cbx contains the lines

\savebibmacro{cite}%

\renewbibmacro*{cite}{%% >>>2
  \printtext[citehyperref]{%
    \restorebibmacro{cite}%
    \usebibmacro{cite}}%
}% <<<2

This effectively wraps the entire output of cite into citehyperref, so that all of it linked.

If we do

\DeclareFieldFormat{citehyperref}{#1}

this undoes the lines from above so that they don't have an effect any more. Since most parts of cite still use bibhyperref quite extensively, you retain exactly the links you want.

\PassOptionsToPackage{brazil,main=english}{babel}
\documentclass[
10pt,
a5paper,
twoside
chapter=TITLE,
section=TITLE
]{abntex2}
\pdfstringdefDisableCommands{\let\uppercase\relax}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[
style=abnt,
language=english,
backref=true,
backend=biber,
citecounter=true
]{biblatex}
\addbibresource{biblatex-examples.bib}

\usepackage{csquotes}
\hypersetup{colorlinks=true}

\DeclareFieldFormat{citehyperref}{#1}

\begin{document}
  Citing \cite[\ppno~47-52 and 135]{nussbaum}

  \printbibliography
\end{document}

citation with non-linked comma between labelname and labelyear

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.