我想使用 Biblatex 为 \parencite 命令使用方括号,就像这里建议的那样:Biblatex,作者年份,方括号,并且我希望有完整的引用作为链接,如下所示:编辑 \cite 的链接范围。
我无法让两者协同工作。如果我现在使用 \parencite,则只有年份是链接,或者,当不使用 \DeclareCiteCommand{\parencite} 注释掉该部分时,括号会丢失。理想情况下,我希望括号也成为链接的一部分。
MWE 使用我复制粘贴的 bib 定制:
\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
\parencite
好吧,我有一个解决方法。将的定义更改为
\DeclareCiteCommand{\parencite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{[\usebibmacro{cite}]}}
% ^ ^
{\multicitedelim}
{\usebibmacro{postnote}}
添加缺失的括号。
使用以下 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}
你会得到