1

I am using the following command for my bibliography

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

and additional macro for the "author(year)[#]" citation style, described here: Cite author(year)[1] using one command BibLatex

Now when I use multiple citations and the output in

bla blah blah [1][3][7]

But I want

Blah blah blah [1,3,7]

I tried numeric-comp style but it does not work.

MWE is

\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}
3
  • 1
    Then please show us a full MWE/MWEB of what you tried an how it did not work for you. Both suggestions work for me if I add them to the code in my answer to your linked question.
    – moewe
    Commented Jul 3, 2018 at 15:31
  • 1
    You are missing m} at the end of the line starting with \geometry{. We also don't have your .bib file and the example does not actually cite anything! Please add fully working examples that actually show the undesired behaviour.
    – moewe
    Commented Jul 3, 2018 at 15:41
  • 1
    Note that this is by design: the IEEE style is explicitly clear that each citation is given in square brackets.
    – Joseph Wright
    Commented Jul 3, 2018 at 16:22

1 Answer 1

9

style=ieee implements verbose numeric citations of the form

[1], [2], [3]

if you want more compact citations you need to replace

style=ieee 

with

bibstyle=ieee,citestyle=numeric,

to obtain

[1, 2, 3]

or even

bibstyle=ieee,citestyle=numeric-comp,

to obtain

[1-3]

Naturally you must use one \cite command for those citations

\cite{sigfridsson,worman,nussbaum}

single citations that are written as

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

are not converted.

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=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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .