自我声明的“DeclareCiteCommand”不得增加引用计数

自我声明的“DeclareCiteCommand”不得增加引用计数

我创建了一个 BibLaTeX 库,其中包含我所有同事的自定义 BibTeX 格式的条目。借助DeclareCiteCommand,我定义了几个自定义“引用”命令,可以在 LaTeX 文本中使用这些命令。这非常有用,因为我只需使用自定义的引用命令即可自动获取同事的电话号码、地址、姓名、所属机构等,而无需将所有这些明确输入到文本中。

到目前为止一切顺利,一切进展顺利!

但是,我有一个问题:每当我有一个文本,其中混合了文本、通过插入的参考文献\cite和我自己的“引用”命令时,参考文献的编号就会被我自己的“引用”命令打乱(例如,在参考文献部分)。事实上,每当我使用我自己的“引用”命令之一时,参考文献计数器就会增加 +1。

问题:我怎样才能避免计数器增加1?

这里有一个平均能量损失,下面以图像形式输出。可以清楚看到,引用从 1 开始,一直延续到 3,因为\citeColleague{Colleague_1}Ref1 和 Ref2 之间存在命令。

谢谢您的帮助!

\RequirePackage{filecontents}

% __________________________________________________________ The BibTeX library
\begin{filecontents*}{\jobname.bib}
@Article{Bib1,
  Title          = {{Self-inhibition of water dissociation on magnesium oxide surfaces}},
  Author         = {Abriou, D. and Jupille, J.},
  Journal        = {Surf. Sci.},
  Year           = {1999},
  Number         = {1-3},
  Pages          = {L527--L532},
  Volume         = {430},
}

@Article{Bib2,
  Title          = {{Aggregation Pathways and Suzuki phase formation in doped Alkali Halides}},
  Author         = {Aceituno, P. and Cuss\'{o}, F. and de Andr\'{e}s, A. and Jaque, F.},
  Journal        = {Solid State Commun.},
  Year           = {1984},
  Pages          = {209},
  Volume         = {49},
}

@Article{Bib3,
  Title          = {{Precipitation of KCI:PbCI$_{\rm 2}$ system: an X-ray study }},
  Author         = {Acharya, B. S.},
  Journal        = {J. Mater. Sci. Lett.},
  Year           = {1985},
  Pages          = {593},
  Volume         = {4},
}

@Colleague{Colleague_1,
  Colleague         = {Frau Musterfrau},
  Degree            = {Dr},
  Type              = {Collaboration},
  Titlework         = {},
  Titlethesis       = {},
  Position          = {Researcher},
  Employer          = {},
  Program           = {},
  Director          = {},
  Codirector        = {},
  Tutor             = {},
  Myrole            = {},
  Street            = {},
  Venueorigin       = {},
  Venueoriginshort  = {},
  Venue             = {A research center},
  Venueshort        = {Name of center},
  Cityorigin        = {},
  Countryorigin     = {},  
  City              = {Town},
  Zipcode           = {},
  Country           = {Europe},
  Date              = {},
  Defencedate       = {},
  Telephone         = {0562259345347946},
  Email             = {[email protected] },
  Urlcolleague      = {https://www.blabla.eu},
  Note              = {},
  Timestamp         = {}
}
\end{filecontents*}



% ______________________________________________ The declaration of the entries.
\begin{filecontents}{colleague.dbx}
% Declarations used by all new BibLaTeX entry types
% Dates additional
\DeclareDatamodelFields[type=field, datatype=datepart]{
  defencedateyear,
  defencedatemonth,
  defencedateday,
}
% Dates
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
  defencedate,
}
% Urls
\DeclareDatamodelFields[type=field,datatype=verbatim]{
  urlcolleague,
}
% Literal (text) fields
\DeclareDatamodelFields[type=field,datatype=literal]{
  city,
  cityorigin,
  colleague,
  country,
  countryorigin,
  codirector,
  datestart,
  degree,
  director,
  employer,
  email,
  league,
  lecturer,
  level,
  myrole,
  partners,    
  position,
  program, 
  state,  
  street,  
  telephone,
  titlethesis,
  titlework,
  tutor,
  type,
  venueorigin,
  venueoriginshort,
  venueshort,
  zipcode,
}
% Declarations for BibLaTeX entry type: colleague
\DeclareDatamodelEntrytypes{colleague}
\DeclareDatamodelEntryfields[colleague]{
  colleague,
  degree,
  type,
  titlework, 
  titlethesis,
  position,
  employer,
  program,
  director,
  codirector,
  tutor,
  myrole,
  venueorigin,
  venueoriginshort,
  street,
  venue,
  venueshort,
  cityorigin,
  countryorigin,
  city,
  country,
  zipcode,
  telephone,
  email,
  date,
  defencedate,
  urlcolleague,
  note,
  timestamp,
}
\end{filecontents}

% _____________________________________________________ The standard LaTeX head

\documentclass[english]{book}
\usepackage{babel}
\usepackage{ifmtarg}
\usepackage{xstring}
\usepackage{ifthen}
\usepackage[datamodel=colleague,      % The data model
            maxnames=99,              % Maximum number of authors
            dateabbrev=false,         % Do not abbreviate the date
            natbib=true,              % Natbin compatibility
            sorting=none,             % No sorting
            backend=biber]
           {biblatex}        
\addbibresource{\jobname.bib}

%
%              Here it is. What shal I do here that the counter is not
%              modified?
% ____________________________________________________________ The cite command
%
\DeclareCiteCommand{\citeColleague}
    {\boolfalse{citetracker}%
     \boolfalse{pagetracker}%
     \usebibmacro{prenote}}
    {%
     {%
     \printfield{colleague}%
     \space(\printfield{venueshort}%
             \newunit%
             \printfield{city}%
             \newunit%
             \printfield{country})%
     }%

    }%
    {\multicitedelim}
    {\usebibmacro{postnote}}

% Many, many other cite commands would follow here, but for simplicity,
% I leave them all out.


% __________________________ This is just for that all appears on only one page 

\usepackage{etoolbox}
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother


% ______________________________________________________________ BEGIN DOCUMENT

\begin{document}

\chapter{Introduction}

This is some text that cites first this reference here: \cite{Bib1}. Then, the 
text mentions this person: \citeColleague{Colleague_1}. After, the text cites
\cite{Bib2} and \cite{Bib3}.

\nopagebreak

\printbibliography[nottype=colleague,
                   nottype=project,
                   nottype=event,
                   nottype=researchstay,
                   nottype=contribution,
                   nottype=lecture,
                   title={Bibliography}]

\end{document}

在此处输入图片描述

答案1

您实际上是在这里创建一个拆分书目。numeric样式中的拆分书目几乎总是受益于(甚至需要)全局defernumbers选项。使用

\usepackage[datamodel=colleague,      % The data model
            maxnames=99,              % Maximum number of authors
            dateabbrev=false,         % Do not abbreviate the date
            natbib=true,              % Natbib compatibility
            sorting=none,             % No sorting
            backend=biber,
            defernumbers]
           {biblatex}  

编号与所需一致。

如果你永远不会使用该类型@colleague和你定义的所有其他新类型的标签编号,你可以使用以下命令关闭它们

\ExecuteBibliographyOptions[colleague, project, event, researchstay, contribution, lecture]{skiplab}

确实,skiplab单独使用就足够了,但拆分参考书目的情况下通常需要,所以即使你使用,defernumbers我仍然建议。defernumbersskiplab


在使用 进行排序时,完全忽略某些\cites 并非易事sorting=none,因为排序基于写入 的引用请求.bcf。定义时没有简单的选项可以设置,\citeColleague这将产生这种效果,需要较低级别的黑客(并且该黑客不能只是阻止将引用请求写入.bcf,这是处理引用所必需的。请求可能会被延迟...)。


你可能想让你\citeColleaguebiblatex

\DeclareCiteCommand{\citeColleague}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\printfield{colleague}%
   \setunit{\space}%
   \printtext[parens]{%
     \printfield{venueshort}%
     \newunit
     \printfield{city}%
     \newunit
     \printfield{country}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

尽可能避免在 bibmacros 和 cite 命令中使用硬编码/裸标点符号和空格(如(and)\addspace不带 a) 。\setunit

相关内容