defernumbers 选项与定制环境之间的冲突

defernumbers 选项与定制环境之间的冲突

我有一份文档(下面不是 MWE),我想有一个A类文件B类文件参考书目。我使用biblatex\newrefcontext命令来实现这一点。

该文档还有一个名为的自定义环境req,可以在其中放置文本。

我面临的问题是,如果A型或者B型引用文件里面第一次进入环境时,参考书目计数器不再起作用,返回 [0](或 [TA-0] 或 [TB-0],根据文档中的定义)作为参考。

如果引用文件,则不会发生这种情况外部环境req第一(见第 130 行)。

显然,这种行为不是由req环境中定义的计数器引起的(这是我的第一个想法,我尝试了一些调试)。

相反,它可以追溯到defernumbers=true的选项biblatex,这是实现不同 的正确编号所必需的refcontext。通过将其注释掉,可以实现编号(即使它不是正确的编号)。

同时,我无法从日志文件中识别出一些有价值的信息。

我应该如何改进我自己定义的环境,以便恢复biblatex和的正常行为?\newrefcontext

\documentclass[a4paper,titlepage,draft,openany]{scrbook}

\usepackage{csquotes}

\usepackage[%
    sorting       = none,
    defernumbers  = true,
    backend       = biber,
    % bibstyle    = ieee,
    % % citestyle = numeric,
    % isbn        = true,
    % doi         = false,
    % % sorting   = nty,
    % % sorting   = debug,
    % % url       = false,
    % bibencoding = utf8,
]{biblatex}

% required to define the 'req' environment:
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{fmtcount}

%%% definition of the 'req' environment and its associated comments
\newcounter{reqCounter}
\counterwithin*{reqCounter}{section}

\newcommand{\theReqCounter}{%
    \padzeroes[3]{\decimal{reqCounter}}%
}

\makeatletter
    \newcommand{\reqlabel}[2]{\protected@edef\@currentlabel{#2}\label{#1}} % https://tex.stackexchange.com/a/328051/177
\makeatother

\newenvironment{req}[9]
{ % begin code
    \refstepcounter{reqCounter}%
    \subsection{#2}
    \begin{center}
        \begin{tabularx}{\textwidth}{>{\scshape}lX}
            \toprule
            row 1 & {#1}-\theReqCounter \reqlabel{#8}{{#1}-\theReqCounter}  \\
            % id & {#1}-\theReqCounter \reqlabel{thisisthelabel}{thisisthereference} \\
            \midrule
            row 2 & #2 \\
            \midrule
            row 3 & #3 \\
            \midrule
            row 4 & #4 \\
            \midrule
            row 5 & #5 \\
            \midrule
            row 6 & #6 \\
            \midrule
            row 7 & #9 \\
            \midrule
            row 8 & #7 \\
            \bottomrule
        \end{tabularx}
    \end{center}
}
{ % end code
    % nothing to declare
}

\addbibresource{\jobname.bib}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
    @TechReport{doc01,
        author      = {author, first},
        title       = {{project name doc 1}},
        institution = {company one},
        year        = {2021},
        type        = {type A},
        number      = {documet code 1},
        address     = {},
        keywords    = {tadoc},
    }

    @TechReport{doc02,
        author      = {author, first},
        title       = {{project name doc 2}},
        institution = {company one},
        year        = {2021},
        type        = {type A},
        number      = {documet code 2},
        address     = {},
        keywords    = {tadoc},
    }

    @TechReport{doc03,
        author      = {author, first},
        title       = {{project name doc 3}},
        institution = {company one},
        year        = {2021},
        type        = {type A},
        number      = {documet code 3},
        address     = {},
        keywords    = {tadoc},
    }

    @TechReport{doc04,
        author      = {author, second},
        title       = {{type B document title}},
        institution = {Company B},
        year        = {2021},
        type        = {Type B},
        number      = {n/a},
        address     = {},
        keywords    = {tbdoc},
    }
\end{filecontents}

\begin{document}

\printbibliography

\newrefcontext[labelprefix=TA-]
\printbibliography[keyword=tadoc,title=Type A Documents]

\newrefcontext[labelprefix=CD-]
\printbibliography[keyword=tbdoc,title=Type B Documents]



\chapter{first chapter}

%%% If the following cite commands are commented out, the references are printed as [0]
%%% Uncommenting the \cite commands the references behave normally as expected
% \cite{doc01}
% % \cite{doc02}
% % \cite{doc03}
% \cite{doc04}


\begin{req}{AA-BB}
{title 1}
{statement 1}
{\cite[page 4, Table 1,][]{doc01}}
{T}
{False}
{lorem ipsum}
{req:01} % no spaces between these brackets!
{}
\end{req}

\begin{req}{AA-CC}
{   title 2}
{   statement 2}
{ \cite[page 4, Table 1,][]{doc01}}
{ T}
{ False}
{ lorem ipsum}
{req:02} % no spaces between these brackets!
{}
\end{req}

\section{section title}

\begin{req}{BB-AA}
{title 3}
{statement 3}
{ \cite[page 29,][]{doc01}}
{ default}
{ False}
{ lorem ipsum}
{req:03} % no spaces between these brackets!
{n/a}
\end{req}

\begin{req}{BB-CC}
{title 5}
{statement 5}
{   \cite[page 29,][]{doc01}}
{ T}
{ False}
{ \cite{doc04}}
{req:05} % no spaces between these brackets!
{n/a}
lorem ipsum  \cite[Sec.~4, p.~13]{doc02} dolor sit amet \cite{doc04}
\end{req}

% \begin{req}{BB-DD}
% {title 6}
% {statement 6}
% {\cite[Sec.~xxx, p.~xxx][]{doc03}}
% % {  }
% { % verification method
%   R
% }
% { % verification status
%   False
% }
% { % validation
%   lorem ipsum
% }
% {req:06} % no spaces between these brackets!
% {n/a}
% \end{req}

\ref{req:01}
\ref{req:02}
\ref{req:03}
\ref{req:05}
\ref{req:06}

\end{document}

答案1

更新biblatex至版本 >= 3.13 可解决该问题。请参阅重复引用的问题。

相关内容