混合引用两个参考书目中的字母和数字

混合引用两个参考书目中的字母和数字

我用这个答案在我的文档中创建两个参考书目,一个包含我自己的出版物,按字母编号,另一个包含其他参考文献,按数字编号。这对于我仅引用我自己的或其他参考文献的引用来说没问题。但是,现在我想在一个实例中引用两个参考书目中的多个参考文献,然后字母和数字的使用就会混淆。

以下 MWE 对此进行了说明:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
    @report{me1,
        author = {Me},
        title = {My first article},
        keywords = {own}
    }
    @report{me2,
        author = {Me},
        title = {My second article},
        keywords = {own}
    }
    @report{me3,
        author = {Me},
        title = {My third article},
        keywords = {own}
    }
    @report{others1,
        author = {Someone else},
        title = {Some article}
    }
    @report{others2,
        author = {Someone else},
        title = {Some other article}
    }
\end{filecontents*}
\usepackage[%
    backend=biber,
    defernumbers=true,
    citestyle=numeric-comp
]{biblatex}
\addbibresource{\jobname.bib}
\makeatletter
\newrobustcmd*{\mknumAlph}[1]{%
  \begingroup
  \blx@tempcnta=#1\relax
  \ifnum\blx@tempcnta>702 %
  \else
    \ifnum\blx@tempcnta>26 %
      \advance\blx@tempcnta\m@ne
      \divide\blx@tempcnta26\relax
      \blx@numalph\blx@tempcnta
      \multiply\blx@tempcnta26\relax
      \blx@tempcnta=\numexpr#1-\blx@tempcnta\relax
    \fi
  \fi
  \blx@numAlph\blx@tempcnta
  \endgroup}
\def\blx@numAlph#1{%
  \ifcase#1\relax\blx@warning@entry{Value out of range}\number#1\or
  A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
  N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\else
  \blx@warning@entry{Value out of range}\number#1\fi}
\makeatother
\DeclareFieldFormat{labelnumber}{\ifkeyword{own}{\mknumAlph{#1}}{#1}}
\ExecuteBibliographyOptions{sorting=none}
\begin{document}
\nocite{me1,me2,me3}
\section{Introduction}
My own articles are~\cite{me1,me2,me3}.

All articles are~\cite{me1,me2,me3,others1,others2}.

It should look like this~[A--C, 1, 2].
\section{List of publications}
\printbibliography[keyword=own,resetnumbers=true,heading=none]
\section{References}
\printbibliography[notkeyword=own,resetnumbers=true,heading=none]
\end{document}

在此处输入图片描述

我怎样才能同时使用正确的键引用两个参考书目中的条目?

答案1

我发现我可以使用\cites手动指定两组引文,它们分别设置并用一对方括号中的逗号分隔。这样就产生了所需的输出:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
    @report{me1,
        author = {Me},
        title = {My first article},
        keywords = {own}
    }
    @report{me2,
        author = {Me},
        title = {My second article},
        keywords = {own}
    }
    @report{me3,
        author = {Me},
        title = {My third article},
        keywords = {own}
    }
    @report{others1,
        author = {Someone else},
        title = {Some article}
    }
    @report{others2,
        author = {Someone else},
        title = {Some other article}
    }
\end{filecontents*}
\usepackage[%
    backend=biber,
    defernumbers=true,
    citestyle=numeric-comp
]{biblatex}
\addbibresource{\jobname.bib}
\makeatletter
\newrobustcmd*{\mknumAlph}[1]{%
  \begingroup
  \blx@tempcnta=#1\relax
  \ifnum\blx@tempcnta>702 %
  \else
    \ifnum\blx@tempcnta>26 %
      \advance\blx@tempcnta\m@ne
      \divide\blx@tempcnta26\relax
      \blx@numalph\blx@tempcnta
      \multiply\blx@tempcnta26\relax
      \blx@tempcnta=\numexpr#1-\blx@tempcnta\relax
    \fi
  \fi
  \blx@numAlph\blx@tempcnta
  \endgroup}
\def\blx@numAlph#1{%
  \ifcase#1\relax\blx@warning@entry{Value out of range}\number#1\or
  A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
  N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\else
  \blx@warning@entry{Value out of range}\number#1\fi}
\makeatother
\DeclareFieldFormat{labelnumber}{\ifkeyword{own}{\mknumAlph{#1}}{#1}}
\ExecuteBibliographyOptions{sorting=none}
\begin{document}
\nocite{me1,me2,me3}
\section{Introduction}
My own articles are~\cite{me1,me2,me3}.

All articles are~\cites{me1,me2,me3}{others1,others2}.
\section{List of publications}
\printbibliography[keyword=own,resetnumbers=true,heading=none]
\section{References}
\printbibliography[notkeyword=own,resetnumbers=true,heading=none]
\end{document}

在此处输入图片描述

相关内容