使用 ieee 样式和 biblatex 对引文进行分组

使用 ieee 样式和 biblatex 对引文进行分组

我正在使用以下命令来获取我的参考书目

\usepackage[backend=biber,style=ieee,sorting=none,labeldateparts,maxbibnames=99,maxcitenames=2,mincitenames=1]{biblatex} 

以及针对“作者(年份)[#]”引用样式的附加宏,如下所述: 使用一个命令 BibLatex 引用作者(年份)[1]

现在,当我使用多个引用和输出时

啦啦啦 [1][3][7]

但我想要

啦啦啦 [1,3,7]

我尝试了numeric-comp风格,但是没有效果。

MWE 是

\documentclass[a4paper,12pt,oneside,openright]{report}
\usepackage{listings}
\usepackage{amsmath,amssymb}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{appendix}
\usepackage[T1]{fontenc} 
\usepackage{siunitx}
\usepackage{geometry}
\geometry{a4paper, total={170mm, 257mm},left=20mm, top=20mm, right=15mm, bottom=20m
\usepackage[english]{babel}
\frenchspacing
\renewcommand{\baselinestretch}{1.2}
\usepackage[backend=biber,style=ieee,sorting=none,labeldateparts,maxbibnames=99,maxcitenames=2,mincitenames=1]{biblatex} 
\DefineBibliographyStrings{english}{%
    andothers = {\em et\addabbrvspace al\adddot}
}
\ExecuteBibliographyOptions{
    url=false
}
\urlstyle{same}

\addbibresource{Biblio.bib}
\makeatletter
\newbibmacro*{simple:cite}{%
    \printtext[bibhyperref]{%
        \printfield{labelprefix}%
        \printfield{labelnumber}%
        \ifbool{bbx:subentry}
        {\printfield{entrysetcount}}
        {}}}

\newbibmacro*{textcite:init}{%
    \ifnumless{\value{multicitecount}}{2}
    {\global\boolfalse{cbx:parens}}
    {}%
    \global\undef\cbx@lasthash
    \global\undef\cbx@lastyear}

\renewbibmacro*{textcite}{%
    \ifboolexpr{test {\iffieldequals{namehash}{\cbx@lasthash}}
        and test {\iffieldequals{labelyear}{\cbx@lastyear}}}
    {\setunit{\multicitedelim}}
    {\ifnameundef{labelname}
        {\printfield[citetitle]{labeltitle}}
        {\printnames{labelname}}%
        \setunit*{\printdelim{nameyeardelim}}%
        \printlabeldate
        \setunit{\printdelim{namelabeldelim}}%
        \printtext{\bibopenbracket}\global\booltrue{cbx:parens}%
        \stepcounter{textcitecount}}%
    \savefield{namehash}{\cbx@lasthash}%
    \savefield{labelyear}{\cbx@lastyear}%
    \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
    \usebibmacro{simple:cite}%
    \setunit{%
        \ifbool{cbx:parens}
        {\bibclosebracket\global\boolfalse{cbx:parens}}
        {}%
        \textcitedelim}}

\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
{\gdef\cbx@savedkeys{}%
    \citetrackerfalse%
    \pagetrackerfalse%
    \DeferNextCitekeyHook%
    \usebibmacro{textcite:init}}
{\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
    {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
        \global\clearfield{multipostnote}}
    {}%
    \xappto\cbx@savedkeys{\thefield{entrykey},}%
    \ifboolexpr{test {\iffieldequals{namehash}{\cbx@lasthash}}
        and test {\iffieldequals{labelyear}{\cbx@lastyear}}}
    {}
    {\stepcounter{textcitetotal}}%
    \savefield{namehash}{\cbx@lasthash}%
    \savefield{labelyear}{\cbx@lastyear}}
{}
{\protected@xappto\cbx@savedcites{%
        [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

\AtBeginBibliography{%
    \renewcommand{\mkbibnamefamily}{\textbf}
    \renewcommand{\mkbibnamegiven}{\textbf}
    \renewcommand{\mkbibnameprefix}{\textbf}
    \renewcommand{\mkbibnamesuffix}{\textbf}
}

\begin{document}
[content of report]
\end{document}

答案1

style=ieee实现以下形式的详细数字引用

[1], [2], [3]

如果你想要更紧凑的引用,你需要替换

style=ieee 

bibstyle=ieee,citestyle=numeric,

获得

[1, 2, 3]

甚至

bibstyle=ieee,citestyle=numeric-comp,

获得

[1-3]

当然,你必须使用一个\cite命令来引用这些内容

\cite{sigfridsson,worman,nussbaum}

单个引用写成

\cite{sigfridsson}, \cite{worman}, \cite{nussbaum}

未转换。

平均能量损失

\documentclass[a4paper,12pt,oneside,openright]{report}
\usepackage{listings}
\usepackage{amsmath,amssymb}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{appendix}
\usepackage[T1]{fontenc} 
\usepackage{siunitx}
\usepackage{geometry}
\geometry{a4paper, total={170mm, 257mm},left=20mm, top=20mm, right=15mm, bottom=20mm}
\usepackage[english]{babel}
\frenchspacing
\renewcommand{\baselinestretch}{1.2}
\usepackage[backend=biber,bibstyle=ieee,citestyle=numeric,sorting=none,labeldateparts,maxbibnames=99,maxcitenames=2,mincitenames=1]{biblatex} 
\DefineBibliographyStrings{english}{%
    andothers = {\mkbibemph{et\addabbrvspace al\adddot}}
}
\ExecuteBibliographyOptions{
    url=false
}
\urlstyle{same}

\addbibresource{biblatex-examples.bib}
\makeatletter
\newbibmacro*{simple:cite}{%
  \printtext[bibhyperref]{%
    \printfield{labelprefix}%
    \printfield{labelnumber}%
    \ifbool{bbx:subentry}
      {\printfield{entrysetcount}}
      {}}}

\newbibmacro*{textcite:init}{%
  \ifnumless{\value{multicitecount}}{2}
    {\global\boolfalse{cbx:parens}}
    {}%
  \global\undef\cbx@lasthash
  \global\undef\cbx@lastyear}

\renewbibmacro*{textcite}{%
  \ifboolexpr{test {\iffieldequals{namehash}{\cbx@lasthash}}
              and test {\iffieldequals{labelyear}{\cbx@lastyear}}}
    {\setunit{\multicitedelim}}
    {\ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\printnames{labelname}}%
     \setunit*{\printdelim{nameyeardelim}}%
     \printlabeldate
     \setunit{\printdelim{namelabeldelim}}%
     \printtext{\bibopenbracket}\global\booltrue{cbx:parens}%
     \stepcounter{textcitecount}}%
  \savefield{namehash}{\cbx@lasthash}%
  \savefield{labelyear}{\cbx@lastyear}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{simple:cite}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibclosebracket\global\boolfalse{cbx:parens}}
      {}%
    \textcitedelim}}

\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
      {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \ifboolexpr{test {\iffieldequals{namehash}{\cbx@lasthash}}
               and test {\iffieldequals{labelyear}{\cbx@lastyear}}}
     {}
     {\stepcounter{textcitetotal}}%
   \savefield{namehash}{\cbx@lasthash}%
   \savefield{labelyear}{\cbx@lastyear}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

\AtBeginBibliography{%
  \renewcommand{\mkbibnamefamily}{\textbf}%
  \renewcommand{\mkbibnamegiven}{\textbf}%
  \renewcommand{\mkbibnameprefix}{\textbf}%
  \renewcommand{\mkbibnamesuffix}{\textbf}%
}

\begin{document}
\cite{sigfridsson,worman,nussbaum}
\end{document}

在此处输入图片描述

相关内容