Overleaf 中出现异常,首次使用新文件时运行良好

Overleaf 中出现异常,首次使用新文件时运行良好

我发现 Oveleaf 有点奇怪。第一次粘贴下面的代码时,它起作用了:

\documentclass{article}
\usepackage{xpatch}

\usepackage{enumitem} % macros to modify appearance of 'itemize' environments
% \usepackage[style = authoryear-comp, maxnames = 99]{biblatex}

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

\usepackage[backend=biber, 
% style=authoryear, 
 style=authoryear-comp,
% citestyle=authoryear, 
dashed=false,
maxcitenames=2,
maxbibnames=99,
giveninits,
alldates=comp, %for online citing
dateabbrev=false, %for online citing for data format month in full
uniquename=init]{biblatex}


\urlstyle{same}

% to make volume (number), eg. 4(2)
\newcommand*{\volnumdelim}{}
\DeclareFieldFormat[article,periodical]{number}{\mkbibparens{#1}}

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

\newcommand*{\jourvoldelim}{\addcomma\space}
\newcommand*{\jourserdelim}{\newunitpunct}
\newcommand*{\servoldelim}{\jourvoldelim}
\newcommand*{\volnumdatedelim}{\addspace}

\renewbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\jourvoldelim}%
  \iffieldundef{series}
    {}
    {\setunit*{\jourserdelim}%
     \printfield{series}%
     \setunit{\servoldelim}}%
  \usebibmacro{volume+number+eid}%
  \setunit{\volnumdatedelim}%
  \usebibmacro{issue+date}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \newunit}  
% to make volume (number), eg. 4(2)
\DeclareNameAlias{sortname}{family-given} %for second and third author name
\DeclareFieldFormat{postnote}{\printtext[bibhyperref]{#1}}

\RequirePackage{xcolor}

\definecolor{darkblue}{rgb}{0, 0, 0.5}
\usepackage[colorlinks=true, allcolors=darkblue]{hyperref}   

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

\usepackage[english]{babel}
\usepackage[style=british]{csquotes}
% % --------------------------------------------------------------------
% \usepackage[raise]{fmtcount}

% \DefineBibliographyExtras{english}{%
%   \renewcommand*{\mkbibordedition}[1]{\ordinalnum{#1}[f]}
% }

% \DefineBibliographyStrings{english}{%
%     edition = {edn\adddot},%
% }
% % --------------------------------------------------------------------

\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}


% \usepackage[unicode,colorlinks,citecolor=blue]{hyperref}


% for a chapter edited by a book
\usepackage{xpatch}
% \renewcommand*{\finalnamedelim}{\addspace\&\space} 
% \renewcommand*{\intitlepunct}{\space} (to become In:)
\renewcommand{\labelnamepunct}{\space} %to delete . after (1997)
% \DeclareFieldFormat[article, incollection, unpublished]{pages}{#1} % to add in PP. (page)
\DeclareFieldFormat[article, incollection, unpublished]{title}{#1}
% \renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}} %cancel out this in order to add in PP. (page)


% for title italic
% \DeclareFieldFormat*{title}{\mkbibemph{#1}} %for title italic in all format (conference, paper..)
\DeclareFieldFormat*{title}{#1} %for conference title delete ".."
\DeclareFieldFormat[incollection]{title}{\mkbibemph{#1}} %for incollecion title italic ONLY
\DeclareFieldFormat[thesis]{title}{\mkbibemph{#1}} %for phdthesis title italic ONLY
% for title italic

% to delete "In:" for article
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
% to delete "In:" for article


% for delete comma after Author A and Aurhor b
\DefineBibliographyExtras{english}{%
   \let\finalandcomma\empty
   \let\finalandsemicolon\empty
 }
\renewcommand{\compcitedelim}{\space\&\space}
\DeclareNameAlias{editorin}{given-family}

\newbibmacro*{byeditor:in}{%
  \ifnameundef{editor}
    {}
    {\printnames[editorin]{editor}%
     \setunit{\addcomma\space}%
     \usebibmacro{editorstrg}%
     \clearname{editor}}}     


\DeclareDelimFormat[textcite]{postnotedelim}{\addcolon\space}
\DeclareDelimFormat[parencite]{postnotedelim}{\addcolon\space}

% \DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{postnote}{\printtext[bibhyperref]{#1}}
\DeclareFieldFormat{multipostnote}{#1}


% 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]
  {\renewcommand*{\postnotedelim}{\addcolon\space}%
   \usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\cbx@textcite}
  {\renewcommand*{\postnotedelim}{\addsemicolon\space}%
   \usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite: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)


% \DeclareFieldFormat[book]{title}{\mkbibemph{#1}}
%  \usepackage[raise]{fmtcount}
%  \DefineBibliographyExtras{english}{%
%   \renewcommand*{\mkbibordedition}[1]{\ordinalnum{#1}[f]}
%  }

%  \DefineBibliographyStrings{english}{%
%      edition = {edn\adddot},%
% }

% --------------------------------------------------------------------
\DeclareFieldFormat[book]{title}{\mkbibemph{#1}}
\usepackage[raise]{fmtcount}

\DefineBibliographyExtras{english}{%
   \renewcommand*{\mkbibordedition}[1]{\ordinalnum{#1}[f]}
 }

 \DefineBibliographyStrings{english}{%
     edition = {edn\adddot},%
 }
% --------------------------------------------------------------------

\usepackage[normalem]{ulem}
\useunder{\uline}{\ulined}{}%
\DeclareUrlCommand{\bulurl}{\def\UrlFont{\ttfamily\color{blue}\ulined}}

\makeatletter
\DeclareUrlCommand\ULurl@@{%
  \def\UrlLeft{\uline\bgroup}%
  \def\UrlRight{\egroup}}
\def\ULurl@#1{\hyper@linkurl{\ULurl@@{#1}}{#1}}
\DeclareRobustCommand*\ULurl{\hyper@normalise\ULurl@}
\makeatother

\DeclareFieldFormat{doi}{%
    \newline
    \mkbibacro{doi}\addcolon\space
    \ifhyperref
        {\href{http://dx.doi.org/#1}{\ULurl{#1}}}
        {\ULurl{#1}}}


\DeclareFieldFormat{url}{Available at\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{\mkbibbrackets{\bibstring{urlseen}\space#1}}
\DeclareFieldFormat[online]{title}{\mkbibemph{#1}}
\DefineBibliographyStrings{english}{%
  urlseen = {Accessed},
}

\DefineBibliographyExtras{english}{%
  \protected\def\mkdaterangecomp{%
    \mkdaterangetrunc{long}}%
  \protected\def\mkdaterangeterse{%
    \mkdaterangetrunc{short}}%
  \protected\def\mkdaterangecompextra{%
    \mkdaterangetruncextra{long}}%
  \protected\def\mkdaterangeterseextra{%
    \mkdaterangetruncextra{short}}%
  \protected\def\mkbibdatelong#1#2#3{%
    \iffieldundef{#3}
      {}
      {\thefield{#3}%
       \iffieldundef{#2}{}{\nobreakspace}}%
    \iffieldundef{#2}
      {}
      {\mkbibmonth{\thefield{#2}}%
       \iffieldundef{#1}{}{\space}}%
    \iffieldbibstring{#1}
      {\bibstring{\thefield{#1}}}
      {\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}}%
}





% \DeclareFieldFormat{doi}{\bibstring{urlfrom}\addcolon\space\url{#1}}
% \DefineBibliographyStrings{english}{%
%     urlfrom = {Available at}
% }


\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}

@article{primarysource,
   title={primary source},
   author={Ennis, Peter},
   journal={Proceedings of the Human Factors and Ergonomics society Annual Meeting},
   volume={52},
   number={21},
   pages={1747--1750},
   year={1996},
   organization={Sage Publications Sage CA: Los Angeles, CA},
   url= "https://doi.org/10.1177/154193120805202112",
 }


@article{secondarysource,
  title={Teaching logic and teaching critical thinking: revisiting McPeck},
  author={Robinson, Susan Rebecca},
  journal={Higher Education Research and Development},
  volume={30},
  number={3},
  pages={275--287},
  year={2011},
  publisher={Taylor \& Francis}
}

@article{harris2009using,
  title={Using Statistics to Analyse Listening Test Data: Some Sources and Advice for Non-statisticians},
%   author={Harris, Lr and Holland, Saleh},
  journal={Proceedings of the Institute of Acoustics},
     author={Harris, L. E. and Holland, K. R.},
  year={2009},
  volume={31},
}

 @article{ghasemi2012normality,
   title={Normality Tests for Statistical Analysis: A Guide for Non-Statisticians},
   author={Ghasemi, Asghar and Zahediasl, Saleh},
   journal={International journal of endocrinology and metabolism},
   volume={10},
   number={2},
   pages={486},
   year={2012},
   publisher={Kowsar Medical Institute}
 }


%---------------------------------------------------------------


\end{filecontents*}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{WinNT}

Text is incorrect \textcite{harris2009using}

This is correct \textcite{ghasemi2012normality}

% \textcite{primarysource}\parencite[cited in][]{secondarysource}


\printbibliography
\end{document}

输出:

在此处输入图片描述

然后,我添加了这个错误的代码:

\addbibresource{references.bib}

使用新的 MWE:

\documentclass{article}
\usepackage{xpatch}

\usepackage{enumitem} % macros to modify appearance of 'itemize' environments
% \usepackage[style = authoryear-comp, maxnames = 99]{biblatex}

\usepackage[backend=biber, 
% style=authoryear, 
 style=authoryear-comp,
% citestyle=authoryear, 
dashed=false,
maxcitenames=2,
maxbibnames=99,
uniquelist=false, % for Author1 et al. (year) instead of Author1, Author2 et al. (year)
giveninits,
alldates=comp, %for online citing
dateabbrev=false, %for online citing for data format month in full
uniquename=init]{biblatex}

\DeclareNameAlias{sortname}{family-given}

\addbibresource{references.bib}

它有一个错误:

在此处输入图片描述

在此处输入图片描述

然后,我知道这是错误的代码,所以我取消了,但仍然不起作用。

奇怪的是,即使我已经取消了,它仍然无法恢复到原来状态。

\documentclass{article}
\usepackage{xpatch}

\usepackage{enumitem} % macros to modify appearance of 'itemize' environments
% \usepackage[style = authoryear-comp, maxnames = 99]{biblatex}

\usepackage[backend=biber, 
% style=authoryear, 
 style=authoryear-comp,
% citestyle=authoryear, 
dashed=false,
maxcitenames=2,
maxbibnames=99,
uniquelist=false, % for Author1 et al. (year) instead of Author1, Author2 et al. (year)
giveninits,
alldates=comp, %for online citing
dateabbrev=false, %for online citing for data format month in full
uniquename=init]{biblatex}

\DeclareNameAlias{sortname}{family-given}

% \addbibresource{references.bib}

相关内容