2

I want to use square brackets for the \parencite command using Biblatex, like suggested here: Biblatex, author-year, square brackets, and I want to have the complete citation as link like here: Edit the link span of a \cite .

I cannot get both things to work together. If I now use \parencite, only the year is a link, or, when not commenting out the section with \DeclareCiteCommand{\parencite}, the brackets are lost. Ideally, I want the brackets to be part of the link, too.

MWE using my copy-pasted bib customizations:

\documentclass[12pt,a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[colorlinks=true, citecolor=blue]{hyperref}
%Bibliographie und Quellenverzeichnis
\usepackage[backend = biber,
    style=authoryear,
    citestyle=authoryear-ibid,    
    sorting=nyt,
    autocite=plain, 
    citereset=none,
    url=true,                   %URL drucken, wenn angegeben
    doi=false,                  %DOI drucken, wenn angegeben
    hyperref=true,              %Zitationen in klickbare Links
    backref=false,              %zeige in der Bibl Rücklinks 
    isbn=false,
    maxbibnames=3,  
    useeditor=true]{biblatex}
\setlength{\bibitemsep}{1em}
\setlength{\bibhang}{2em}
\renewcommand{\bibfootnotewrapper}[1]{\bibsentence#1}
\DeclareFieldFormat{postnote}{#1}  

\renewcommand*{\nameyeardelim}{\space}
\renewcommand*{\postnotedelim}{\addcolon}

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{citeyear}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\makeatletter

\newrobustcmd*{\parentexttrack}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \blx@bibopenparen#1\blx@bibcloseparen
  \endgroup}

\AtEveryCite{%
  \let\parentext=\parentexttrack%
  \let\bibopenparen=\bibopenbracket%
  \let\bibcloseparen=\bibclosebracket}
\makeatother  

\addbibresource{biblatex-examples.bib}

% here the doc begins
\begin{document}
  \parencite{aksin}
  \printbibliography
\end{document}

1 Answer 1

2

Well, I have a workaround for you. Change the definition of \parencite to

\DeclareCiteCommand{\parencite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{[\usebibmacro{cite}]}}
  %                        ^                  ^
  {\multicitedelim}
  {\usebibmacro{postnote}}

by adding the missing brackets.

With the following MWE

\documentclass[12pt,a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[colorlinks=true, citecolor=blue]{hyperref}
%Bibliographie und Quellenverzeichnis
\usepackage[%
  backend = biber,
  style=authoryear,
  citestyle=authoryear-ibid,    
  sorting=nyt,
  autocite=plain, 
  citereset=none,
  url=true,                   %URL drucken, wenn angegeben
  doi=false,                  %DOI drucken, wenn angegeben
  hyperref=true,              %Zitationen in klickbare Links
  backref=false,              %zeige in der Bibl Rücklinks 
  isbn=false,
  maxbibnames=3,  
  useeditor=true
]{biblatex}
\setlength{\bibitemsep}{1em}
\setlength{\bibhang}{2em}
\renewcommand{\bibfootnotewrapper}[1]{\bibsentence#1}

\DeclareFieldFormat{postnote}{#1}  

\renewcommand*{\nameyeardelim}{\space}
\renewcommand*{\postnotedelim}{\addcolon}

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{citeyear}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{[\usebibmacro{cite}]}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\makeatletter
\newrobustcmd*{\parentexttrack}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \blx@bibopenparen#1\blx@bibcloseparen
  \endgroup}

\AtEveryCite{%
  \let\parentext=\parentexttrack%
  \let\bibopenparen=\bibopenbracket%
  \let\bibcloseparen=\bibclosebracket}
\makeatother  

\addbibresource{biblatex-examples.bib}

% here the doc begins
\begin{document}
  parencite:\parencite{aksin} cite:\cite{companion} textcite:\textcite{knuth:ct}
  \printbibliography
\end{document}

you will get

resulting page

1
  • This answered my question. I need to add though, that I intended to include pre- and postnotes in the brackets, too, which was a detail I left out in the question. With your start, I used ` \DeclareCiteCommand{\parencite}` ` {\printtext[bibhyperref]{[\usebibmacro{prenote}}}` ` {\usebibmacro{citeindex}%` ` \printtext[bibhyperref]{\usebibmacro{cite}}}` ` {\multicitedelim}` ` {\printtext[bibhyperref]{\usebibmacro{postnote}]}}` and got it to work.
    – Ulu83
    Aug 20, 2017 at 8:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .