\begingroup \endgroup 更改引用编号

\begingroup \endgroup 更改引用编号

谢谢“moewe 我有如下解决方案:

\documentclass[10pt,oneside,a4paper]{book}

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

\usepackage     [left=3.5cm,right=2.5cm,tmargin=2.5cm,bmargin=2.5cm]{geometry}

\usepackage     {titlesec}
\titleformat    {\chapter}[hang]{\raggedright\Large\bfseries}{\arabic{chapter}.\space\space}{0pt}{}{}
\titlespacing*  {\chapter}{0pt}{-\baselineskip}{\baselineskip}


\usepackage[
  backend=biber,
  bibstyle=authoryear,
  citestyle=numeric,
  sorting=none,
  giveninits=true,
  dashed=false,
  refsegment=chapter,
  backref=true,
]{biblatex}

\makeatletter
\input{numeric.bbx}
\makeatother

\BiblatexSplitbibDefernumbersWarningOff

\DeclareSortingTemplate{none}{
  \sort{\field{usera}}
  \sort{\citeorder}
  \sort{\intciteorder}
}


\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{book}
      \step[fieldset=usera, fieldvalue=aa]
    }
    \map{
      \pertype{article}
      \step[fieldset=usera, fieldvalue=bb]
    }
    \map{
      \pertype{online}
      \step[fieldset=usera, fieldvalue=cc]
    }
    \map{
      \pertype{inproceedings}
      \step[fieldset=usera, fieldvalue=dd]
    }
  }
}

\DeclareNameAlias{author}{family-given}                         
\DeclareNameAlias{translator}{family-given}                         
\renewcommand*{\revsdnamepunct}{}


\defbibheading{subsubbibintoc}[\refname]{\subsection*{#1}} 
\defbibheading{subsubbibliography}[\refname]{\subsection*{#1}}  

\addbibresource{biblatex-examples.bib}

\usepackage{silence}
\WarningFilter{latex}{Empty bibliography}


\begin{document}
\pagestyle{empty}
\tableofcontents
\chapter{First chapter}

Lorem \autocite{sigfridsson}
ipsum \autocite{nietzsche:ksa1}
dolor \autocite{moraux}
sit \autocite{knuth:ct:c}~\autocite{spiegelberg}.

\printbibheading[title=Chapter bibliography,heading=subbibintoc]
\printbibliography[segment=\therefsegment,type=book,heading=subsubbibintoc,title={Books}]
\printbibliography[segment=\therefsegment,type=article,heading=subsubbibintoc,title={Articles}]
\printbibliography[segment=\therefsegment,type=online,heading=subsubbibintoc,title={Online}]
\printbibliography[segment=\therefsegment,type=inproceedings,heading=subsubbibintoc,title={Conferences}]

\vspace{5mm}
{\let\clearpage\relax \chapter{Second chapter}}

Lorem~\cite{vizedom:related}
ipsum~\cite{gerhardt}
dolor~\cite{augustine}
sit~\cite{ctan}.

\printbibheading[title=Chapter bibliography,heading=subbibintoc]
\printbibliography[segment=\therefsegment,type=book,heading=subsubbibintoc,title={Books}]
\printbibliography[segment=\therefsegment,type=article,heading=subsubbibintoc,title={Articles}]
\printbibliography[segment=\therefsegment,type=online,heading=subsubbibintoc,title={Online}]
\printbibliography[segment=\therefsegment,type=inproceedings,heading=subsubbibintoc,title={Conferences}]

\vspace{5mm}
{\let\clearpage\relax \chapter{Third chapter}}

Lorem~\cite{wassenberg},
ipsum~\cite{baez/online}.

\printbibheading[title=Chapter bibliography,heading=subbibintoc]
\printbibliography[segment=\therefsegment,type=book,heading=subsubbibintoc,title={Books}]
\printbibliography[segment=\therefsegment,type=article,heading=subsubbibintoc,title={Articles}]
\printbibliography[segment=\therefsegment,type=online,heading=subsubbibintoc,title={Online}]
\printbibliography[segment=\therefsegment,type=inproceedings,heading=subsubbibintoc,title={Conferences}]

\printbibheading[title=Global Bibliography,heading=bibintoc]
\printbibliography[type=book,heading=subsubbibliography,title={Books}]
\printbibliography[type=article,heading=subsubbibliography,title={Articles}]
\printbibliography[type=online,heading=subsubbibliography,title={Online}]
\printbibliography[type=inproceedings,heading=subsubbibliography,title={Conferences}]

\csletcs{saved@blx@refcontext@context}{blx@refcontext@context}
\newrefcontext[sorting=nyt]
\begingroup
\makeatletter
\preto\blx@thelabelnumber{%
  \global\csletcs{blx@refcontext@context}{saved@blx@refcontext@context}}
\makeatother
\printbibliography[title=Global Bibliography (alphabetic),heading=bibintoc]
\endgroup

\newrefcontext[sorting=nyt]
\begingroup
\DeclareFieldFormat{labelnumberwidth}{#1\addperiod}
\printbibliography[title={Global Bibliography (alphabetic \& continuous numbering)},heading=bibintoc]
\endgroup

\end{document}

\开始组 \结束组我有全球书目(按字母顺序和连续编号),这没问题。

在此处输入图片描述

但例如在文本中[6]参考书目 位置现在已从[8]上一个全球参考书目编号(按字母顺序和连续编号)。它更改了文本中的所有引用。这应该保留[6]等。

在此处输入图片描述

在此处输入图片描述

当我评论\开始组 \结束组

在此处输入图片描述

引用是正确的

在此处输入图片描述

连续编号 被打破 :(。

在此处输入图片描述

我需要的全球书目(按字母顺序和连续编号)仅是数字[1], [2] [3]...[11] 未连接[6] [1]包含应保留的文本和先前的引用编号。

答案1

尝试以下精简版本,其中考虑到最后的参考书目通常会设置默认的 refcontext(我们在这里不想要)。

\documentclass[10pt,oneside,a4paper]{book}

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

\usepackage[
  backend=biber,
  bibstyle=authoryear,
  citestyle=numeric,
  sorting=none,
  giveninits=true,
  dashed=false,
  refsegment=chapter,
  backref=true,
]{biblatex}

\makeatletter
\input{numeric.bbx}
\makeatother

\BiblatexSplitbibDefernumbersWarningOff

\DeclareSortingTemplate{none}{
  \sort{\field{usera}}
  \sort{\citeorder}
  \sort{\intciteorder}
}


\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{book}
      \step[fieldset=usera, fieldvalue=aa]
    }
    \map{
      \pertype{article}
      \step[fieldset=usera, fieldvalue=bb]
    }
    \map{
      \pertype{online}
      \step[fieldset=usera, fieldvalue=cc]
    }
    \map{
      \pertype{inproceedings}
      \step[fieldset=usera, fieldvalue=dd]
    }
  }
}

\DeclareNameAlias{author}{family-given}                         
\DeclareNameAlias{translator}{family-given}                         
\renewcommand*{\revsdnamepunct}{}


\defbibheading{subsubbibintoc}[\refname]{\subsection*{#1}} 
\defbibheading{subsubbibliography}[\refname]{\subsection*{#1}}  

\addbibresource{biblatex-examples.bib}

\begin{document}
\pagestyle{empty}
\tableofcontents
\chapter{First chapter}

Lorem \autocite{sigfridsson}
ipsum \autocite{nietzsche:ksa1}
dolor \autocite{moraux}
sit \autocite{knuth:ct:c}~\autocite{spiegelberg}.

\printbibheading[title=Chapter bibliography,heading=subbibintoc]
\printbibliography[segment=\therefsegment,type=book,heading=subsubbibintoc,title={Books}]
\printbibliography[segment=\therefsegment,type=article,heading=subsubbibintoc,title={Articles}]
\printbibliography[segment=\therefsegment,type=online,heading=subsubbibintoc,title={Online}]
\printbibliography[segment=\therefsegment,type=inproceedings,heading=subsubbibintoc,title={Conferences}]

\vspace{5mm}
{\let\clearpage\relax \chapter{Second chapter}}

Lorem~\cite{vizedom:related}
ipsum~\cite{gerhardt}
dolor~\cite{augustine}
sit~\cite{ctan}.

\printbibheading[title=Chapter bibliography,heading=subbibintoc]
\printbibliography[segment=\therefsegment,type=book,heading=subsubbibintoc,title={Books}]
\printbibliography[segment=\therefsegment,type=article,heading=subsubbibintoc,title={Articles}]
\printbibliography[segment=\therefsegment,type=online,heading=subsubbibintoc,title={Online}]
\printbibliography[segment=\therefsegment,type=inproceedings,heading=subsubbibintoc,title={Conferences}]

\vspace{5mm}
{\let\clearpage\relax \chapter{Third chapter}}

Lorem~\cite{wassenberg},
ipsum~\cite{baez/online}.

\printbibheading[title=Chapter bibliography,heading=subbibintoc]
\printbibliography[segment=\therefsegment,type=book,heading=subsubbibintoc,title={Books}]
\printbibliography[segment=\therefsegment,type=article,heading=subsubbibintoc,title={Articles}]
\printbibliography[segment=\therefsegment,type=online,heading=subsubbibintoc,title={Online}]
\printbibliography[segment=\therefsegment,type=inproceedings,heading=subsubbibintoc,title={Conferences}]

\printbibheading[title=Global Bibliography,heading=bibintoc]
\printbibliography[type=book,heading=subsubbibliography,title={Books}]
\printbibliography[type=article,heading=subsubbibliography,title={Articles}]
\printbibliography[type=online,heading=subsubbibliography,title={Online}]
\printbibliography[type=inproceedings,heading=subsubbibliography,title={Conferences}]


\csletcs{saved@blx@refcontext@context}{blx@refcontext@context}
\newrefcontext[sorting=nyt]
\makeatletter
\AtNextBibliography{%
  \def\blx@setdefaultrefcontext#1{}%
  \csletcs{blx@refcontext@context}{saved@blx@refcontext@context}}
\makeatother
\printbibliography[title=Global Bibliography (alphabetic),heading=bibintoc]

\newrefcontext[sorting=nyt]
\makeatletter
\AtNextBibliography{%
  \def\blx@setdefaultrefcontext#1{}%
  \DeclareFieldFormat{labelnumberwidth}{#1\addperiod}}
\makeatother
\printbibliography[title={Global Bibliography (alphabetic \& continuous numbering)},heading=bibintoc]

\end{document}

相关内容