我对 biblatex 进行了自定义,结果是“Smith (1992), 1993”。它假设为“Smith (1992&1993)”

我对 biblatex 进行了自定义,结果是“Smith (1992), 1993”。它假设为“Smith (1992&1993)”

我遵循回答类似问题

但是,当我在 Overleaf 中使用它时,它给出了不同的输出:假设:

Smith (1992 & 1993)

最终给出:

圣经

\documentclass[12pt,oneside]{book}  % Remove draft option to show figures (for final draft), otherwise keep for faster production


\usepackage{enumitem} % macros to modify appearance of 'itemize' environments
\usepackage{uorthesis}  % Loads the LaTeX style package

\usepackage[
% backend=biber, 
% style=authoryear, 
style=authoryear-comp, 
% citestyle=authoryear, 
dashed=false,
maxcitenames=2,
maxbibnames=99,
giveninits,
uniquename=init]{biblatex}


\DeclareNameAlias{sortname}{family-given} %for second and third author name

\addbibresource{references.bib}
\usepackage{uorbib}

% for combine both year for an author
\renewcommand{\compcitedelim}{\space\&\space}

% for references 's studies (year)
\renewcommand*{\nameyeardelim}{\addcomma\space}
\newcommand{\mycite}[1]{\citeauthor{#1}'s \citeyear{#1}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printtext[bibhyperref]{\printnames{labelname}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyear} % <======================================
    {}
    {(\bibhyperref{\printdate})}
    {\multicitedelim}
    {}

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


\makeatletter
\let\abx@macro@textciteOrig\abx@macro@textcite
\renewbibmacro{textcite}{% <============================================
   \bibhyperref{%
   \let\bibhyperref\relax\relax%
   \abx@macro@textciteOrig%
   }%
}%
\makeatother
% for references 's studies (year)



\usepackage{enumitem} %for tab in Latex (macros to modify appearance of 'itemize' environments)
% Put custom packages to be loaded here
% \usepackage{linguex}  % For linguistic examples
% \usepackage{tikz}     % For drawing

%for section paragraph
% https://tex.stackexchange.com/questions/60209/how-to-add-an-extra-level-of-sections-with-headings-below-subsubsection
\makeatletter
%%%%% Change the style of paragraph headings %%%%%
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%  %for section paragraph
            {-2.5ex\@plus -1ex \@minus -.25ex}%   %for section paragraph
            {1.25ex \@plus .25ex}%  %for section paragraph 
            {\normalfont\normalsize\bfseries}}  %for section paragraph
%%%%% Change the style of subparagraph headings %%%%%
\renewcommand\subparagraph{\@startsection{paragraph}{4}{\z@}%  %for section paragraph
            {-2.5ex\@plus -1ex \@minus -.25ex}%   %for section paragraph
            {1.25ex \@plus .25ex}%  %for section paragraph 
            {\normalfont\normalsize\bfseries}}  %for section paragraph
\makeatother
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

%for paragraph spacing
\setlength{\parindent}{4em} %for paragraph spacing
\setlength{\parskip}{1em} %for paragraph spacing
%for paragraph spacing

%for table spacing to second row
\usepackage{tabularx,seqsplit, caption} %for table spacing to second row
\usepackage{booktabs, ragged2e}       % Use booktabs rules and get rid of vertical rules, ragged2e to ragged text
\usepackage{makecell,siunitx} %for table spacing to second row
%for table spacing to second row

\usepackage{threeparttable} %to add footnote below table
\renewcommand{\TPTtagStyle}{\itshape} % optional
\usepackage{lipsum} % for filler text


% for bold in table using \small
\usepackage{makecell} % for bold in table using \small
\renewcommand\theadfont{\small\bfseries} % for bold in table using \small
\usepackage{tabulary,siunitx} 
% for bold in table using \small 
\renewcommand\theadgape{}



\usepackage{graphicx}

\usepackage{libertine} %added by ryan


%\usepackage{float}
%\restylefloat{table}


%for table multirow
%\usepackage{multirow} %for table multirow
%\usepackage{multicol} %for table multirow
\usepackage{makecell, multirow, tabularx} %for table multirow
%for table multirow


\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc, positioning,matrix,fit,calc, arrows.meta,
                backgrounds,
                chains}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}              % <---

%---------------- show page layout. don't use in a real document!
% \usepackage{showframe}
% \renewcommand\ShowFrameLinethickness{0.15pt}
% \renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

% for making a comma after the volumn
\renewbibmacro*{volume+number+eid}{%
  \setunit{\addcomma\space}%
  \printfield{volume}%
  \setunit*{\adddot}%
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}


% \usepackage{parskip}  

\usepackage[hypcap=false]{caption}

\begin{document}

% Title page
\include{structure/title}

% All subsequent pages must be numbered, title page is considered page i,
% front matter is numbered in lowercase Roman numerals
\pagestyle{fancy}
\pagenumbering{roman}
\setcounter{page}{2}
\doublespacing

% Dedication (optional)
\include{structure/dedication}

% Acknowledgments
\include{structure/acknowledgements}

% Abstract
\include{structure/abstract}

% Table of Contents, List of Tables, List of Figures
\tableofcontents

%List of Tables & Figures
\include{structure/tablesfigures}


%%%%%%%%%%%%%%%%%%%% DISSERTATION CONTENT %%%%%%%%%%%%%%%%%%%%

% Regular numbering starts now, first page of first chapter is page 1
\clearpage
\setcounter{page}{0}
\pagenumbering{arabic}

% Body


Test writing \textcite{flowers1992ear, flowers1993sound} and \textcite{peres2003sonification} studies. 
\\
Follow-up in \textcite{flowers1993sound}, blablabla


% References
\clearpage
\addcontentsline{toc}{chapter}{Bibliography}
\markboth{\MakeUppercase{Bibliography}}{}
%\singlespacing
\printbibliography
\appendix
\include{chapters/99-appendix}
\end{document}

uorbib.sty在文件中添加:

% This contains styling elements for bibliography
% stuff: Entire citation is colored instead of just
% year.
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{uorbib}
  [2018/01/18 v0.01 LaTeX package for UOR thesis]

%% Bib stuff
\DeclareFieldFormat{citehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{#1}}

\DeclareFieldFormat{textcitehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{%
    #1%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}}}

\savebibmacro{cite}
\savebibmacro{textcite}

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

\renewbibmacro*{textcite}{%
  \ifboolexpr{
    ( not test {\iffieldundef{prenote}} and
      test {\ifnumequal{\value{citecount}}{1}} )
    or
    ( not test {\iffieldundef{postnote}} and
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
  }
    {\DeclareFieldAlias{textcitehyperref}{noformat}}
    {}%
  \printtext[textcitehyperref]{%
    \restorebibmacro{textcite}%
    \usebibmacro{textcite}}}

\endinput
%%
%% End of file `uorbib.sty'.

uorthesis.sty在文件中添加:

\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{uorthesis}
  [2018/01/18 v0.01 LaTeX package for UOR thesis]

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{enumitem}
\setlist{nosep} % Removes too much vertical spacing in lists
\usepackage{booktabs}           % makes tables look good
\usepackage{fancyhdr}           % For page number in the upper right (required) and other running headers(optional)
\usepackage{setspace}           % For double-spacing (required)
\usepackage{titlesec}           % For keeping chapter/chapter titles single-spaced
\usepackage{etoolbox}           % For the flag determining if front matter goes into the TOC
\usepackage{float}              % Helps float images to the top
\RequirePackage{xcolor}
% Define custom colors
\definecolor{darkblue}{rgb}{0, 0, 0.5}
\usepackage[colorlinks=true, allcolors=darkblue]{hyperref}           % Adds hyperlinks in the pdf
\usepackage{csquotes}           % Makes quotes look good
\usepackage[font=small,labelfont={bf,sf}, textfont={sf}, justification=centering]{caption}

%% Font setup
\usepackage{mathptmx}
% \usepackage{lmodern}
\usepackage{helvet}

% Header height (to avoid fancyhdr error)
\setlength{\headheight}{13.6pt}

% Header formatting for regular pages
\fancyhf{}
\fancyhead[L]{\it\small\leftmark}
\fancyhead[R]{\small\thepage}

% Header formatting for chapter title pages
\fancypagestyle{plain}{%
  \fancyhf{}
  \fancyhead[R]{\small\thepage}
  \renewcommand{\headrulewidth}{0pt}
}

% Formatting of chapter and chapter titles: keep them single-spaced in the midst of double-spaced text

\usepackage{sectsty}
\titleformat{\chapter}[hang]{\Huge\sffamily\bfseries}{\thechapter{. }}{0pt}{\Huge}
\allsectionsfont{\normalfont\sffamily\bfseries}
\usepackage{subfigure}
\usepackage[subfigure]{tocloft} % subfigure option only if using subfigure package
\renewcommand{\cfttoctitlefont}{\Huge \bfseries \sffamily} % ToC title
\addto\captionsenglish{
\renewcommand{\listfigurename}{\textsf{List of Figures}}
\renewcommand{\listtablename}{\textsf{List of Tables}}
}

% Flag for whether to add front matter to TOC
\newtoggle{fulltoc}
\toggletrue{fulltoc}  % Change to \togglefalse{fulltoc} to remove front matter
\renewcommand{\contentsname}{Table of Contents}

\endinput
%%
%% End of file `uorthesis.sty'.

答案1

你的代码看起来uorbib.sty好像来自奥黛丽对超链接名称与 biblatex 作者年份 (biblatex 1.4b)。该答案是style=authoryear专门citestyle=authoryear针对 而写的。如果您想使用 ,则style=authoryear-comp,可能无法按预期工作。事实上, 的定义\textcite在样式上要复杂得多-comp,因此事情崩溃并不令人意外。

不仅代码是uorbib.sty为编写的authoryear,而且你的序言中的修改假设authoryear和会产生低于标准的结果authoryear-comp。序言中的代码uorbib.sty在某些地方也相互矛盾。

在下面的例子中,我将收集全部 biblatex-相关代码在序言中,以使示例自成一体(并避免在我回答时让我感到困惑)。这意味着在实际文档中,您只应使用此代码,而不应加载uorbib.sty

的实现textcite在 中非常复杂authoryear-comp,这意味着我们不能使用它\printtext[citehyperref]来生成链接。标点符号跟踪器会出错,并在错误的位置释放和打印标点符号。相反,我们需要求助于原始宏\bibhyperref,这通常是一个非常糟糕的主意。

有更多的代码尝试链接textcite,因此我删除了重复的工作。

此外,的重新定义与的\parencite正常定义不一致,但它足够接近标准,可以完全删除。\parenciteauthoryear-comp

\documentclass{article}

\usepackage[
  backend=biber, 
  style=authoryear-comp, 
  dashed=false,
  maxcitenames=2,
  maxbibnames=99,
  giveninits,
  uniquename=init]{biblatex}
\usepackage[colorlinks]{hyperref}

\DeclareNameAlias{sortname}{family-given}

\DeclareDelimFormat{nameyeardelim}{\addcomma\space}

\DeclareFieldFormat{citehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{#1}}

\savebibmacro{cite}

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

\renewcommand{\compcitedelim}{\addspace\&\space}

\savebibmacro{textcite}

\renewbibmacro*{textcite}{%
  \DeclareFieldAlias{bibhyperref}{noformat}%
  \bibhyperref{%
    \restorebibmacro{textcite}%
    \usebibmacro{textcite}}}


\newcommand{\mycite}[1]{\citeauthor{#1}'s \citeyear{#1}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printtext[bibhyperref]{\printnames{labelname}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyear}
    {}
    {(\bibhyperref{\printdate})}
    {\multicitedelim}
    {}


\renewbibmacro*{volume+number+eid}{%
  \setunit{\addcomma\space}%
  \printfield{volume}%
  \setunit*{\adddot}%
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}

\addbibresource{biblatex-examples.bib}

\begin{document}
Test writing \textcite{knuth:ct:a,knuth:ct:b}, blablabla

Test writing \cite{knuth:ct:a,knuth:ct:b}, blablabla

Test writing \parencite{knuth:ct:a,knuth:ct:b}, blablabla

\printbibliography
\end{document}

完全链接的引用命令。

相关内容