错误:使用 \cite、\textcite、\parencite 时未定义控制序列

错误:使用 \cite、\textcite、\parencite 时未定义控制序列

我尝试了答案如何在文中引用页码在我的工作中,但有一个错误:

Undefined control sequence

细节:

The compiler is having trouble understanding a command you have used. Check that the command is spelled correctly. If the command is part of a package, make sure you have included the package in your preamble using \usepackage{...}.

在此处输入图片描述

我的 MWE:

02background.tex文件:

this is cite \cite[150]{gaver1986auditory}\\
This book is done by \textcite[150]{gaver1986auditory}\\
ABC book is done \parencite[150]{gaver1986auditory}\\

main.tex 文件

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

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

% for the purpose to change "paper title" to 'paper title' in reference
\usepackage[style=british]{csquotes}
% \usepackage[style=english]{csquotes}
% for the purpose to change "paper title" to 'paper title' in reference

\addbibresource{references.bib}

\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}{\addcolon\space}%
   \usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite:postnote}}
% for Quoting AuthorA (1999: 22), Part 2



% for Quoting AuthorA (1999: 22), Part 1
\DeclareDelimFormat[textcite]{postnotedelim}{\addsemicolon\space}
\DeclareDelimFormat[parencite]{postnotedelim}{\addcolon\space}

\DeclareFieldFormat{postnote}{\mknormrange{#1}}
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}}
% for Quoting AuthorA (1999: 22), Part 1

\usepackage[hypcap=false]{caption}



\begin{document}

\include{chapters/02-background}

\addcontentsline{toc}{chapter}{Bibliography}
\markboth{\MakeUppercase{Bibliography}}{}

\printbibliography


\end{document}

uorthesis.sty 文件:

% This defines everything necessary for a thesis
% Master's/PhD at UoR (or anywhere else).
%
% Do what you will with this package
% 
\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 %cancel off for the single quote in referencing the journal title
\usepackage[font=small,labelfont={bf,sf}, textfont={sf}, justification=centering]{caption}

% 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



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

参考.bib 文件:

@article{gaver1986auditory,
  title={Auditory icons: Using sound in computer interfaces},
  author={Gaver, William W},
  journal={Human-computer interaction},
  volume={2},
  number={2},
  pages={167--177},
  year={1986},
  publisher={Taylor \& Francis}
}

答案1

如果仔细查看错误消息,您会发现 LaTeX 抱怨的确切命令是\mknormrange。 (通常有问题的命令是错误消息第一行中的最后一个命令。)

biblatex这意味着您正在使用不支持该命令的旧版本。请替换

\DeclareFieldFormat{postnote}{\mknormrange{#1}}
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}}

\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}

注意Overleaf 刚刚将其系统更新至 TeX live 2018,其中\mknormrange支持。因此,如果您现在开始一个新项目或将您的项目克隆到一个新项目中,则代码\mknormrange应该可以正常工作而不会出现错误。

相关内容