使用 xelatex 编译时出现 langsci-unified 书目样式错误‘IsDOIGray’

使用 xelatex 编译时出现 langsci-unified 书目样式错误‘IsDOIGray’

如果可能的话,我真的需要帮助。我正在努力解决一个我不知道如何修复的错误。跟踪它后,它指向我正在使用的langsci-unified样式,因为使用其他书目样式(例如,apa),文档打印得很好。错误总是与类似的东西有关灰色像这个 :! 未定义控制序列。\blx@theformat #1->{\color {lsDOIGray}DOI\addcolon \space \ifhyperref {\href... l.17 或者! 软件包 xcolor 错误:未定义颜色‘lsDOIGray’

如果可能的话,请帮我修复它。我正在使用 Xelatex 进行编译。

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage[style=langsci-unified, natbib]{biblatex}
\makeatletter

\addbibresource{bibliography.bib}

\begin{document}

\citet{Thompson1996}

\printbibliography


\end{document}

答案1

显然langsci-unified,这是在 CTAN 上分发的langsci,被认为与文档类一起使用langscibook

如果您将样式与其他类一起使用,则需要确保加载xcolor并提供合适的颜色定义lsDOIGray。下面的定义取自langscibook.cls

\documentclass{article}

\usepackage[style=langsci-unified, natbib]{biblatex}

\usepackage{xcolor}
\definecolor{lsDOIGray}{cmyk}{0,0,0,0.45}

\addbibresource{biblatex-examples.bib}

\begin{document}
\citet{sigfridsson}

\printbibliography
\end{document}

Sigfridsson, Emma 和 Ulf Ryde。1998 年。从电势和电势矩推导原子电荷的方法比较。计算化学杂志 19(4)。377–395。DOI:10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P。

参考书目样式默认你正在使用特定类别的情况很不寻常,因此你可能需要联系样式开发人员https://github.com/langsci/langscibook/issues

答案2

我可能有一个解决方法。诀窍可能是,不使用langsci-class,而是使用您通常的文档类(例如scrartcl),并将大量代码粘贴到序言中,以便在文档中定义 langsci 样式。例如,我甚至无法实现style=langsci-unified,因为它被视为没有这种样式。

Stefan Müller 建议简单地将以下代码粘贴到序言中,对我来说效果很好(来源:https://hpsg.hu-berlin.de/~stefan/Lehre/unified-biblatex.sty):

\usepackage[
    natbib=true,
    style=langsci-unified,
    citestyle=langsci-unified,
    datamodel=langsci,   % add authauthor and autheditor as possible fields to
                                % bibtex entries
    useprefix = true, %sort von, van, de where they should appear
    %refsection=chapter,
    maxbibnames=99,
    mincrossrefs=99,
    maxcitenames=2,
        uniquename=false,
    isbn=false,
    doi=true,
    url=true,
    eprint=false,
        useprefix=true,
    backend=biber,
    indexing=cite,
        autolang=hyphen,
%        sorting=ydnt,
]{biblatex}

\usepackage{xcolor}
\definecolor{lsDOIGray}{cmyk}{0,0,0,0.45}


% if no langid is set, it is English:
% https://tex.stackexchange.com/a/279302
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldset=langid, fieldvalue={english}]
    }
  }
}

% If the user provided a shortauthor in the bibtex entry, we use the authentic author (as with the
% authorindex package) if it is defined, otherwise we use the author.
% This gets F/T as shorthand right and puts the guys in the index.

\renewbibmacro*{citeindex}{%
  \ifciteindex
    {\iffieldequalstr{labelnamesource}{shortauthor} % If biblatex uses shortauthor as the label of a bibitem
      {\ifnameundef{authauthor}                     % we check whether there is something in authauthor
        {\indexnames{author}}                       % if not, we use author
        {\indexnames{authauthor}}}                  % if yes, we use authauthor
      {\iffieldequalstr{labelnamesource}{author}    % if biblatex uses author we similarly test for
                                                    % authauthor and use this field
        {\ifnameundef{authauthor}% if defined use authauthor
          {\indexnames{author}}
          {\indexnames{authauthor}}} % if defined use this field
        {\iffieldequalstr{labelnamesource}{shorteditor} % same for editor
          {\ifnameundef{autheditor}
            {\indexnames{editor}}
            {\indexnames{autheditor}}}
          {\indexnames{labelname}}}}}               % as a fallback we index on whatever biblatex used.
    {}}


%\bibliography{bib-abbr,biblio}

%\usepackage{fixcitep}


% cite somebodys work
\let\citew=\citet


%\usepackage{biblatex-series-number-checks}

注意:如果您\addbibresource使用必须将其放在该行之后]{biblatex}和之前\usepackage{xcolor}

相关内容