Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I found this code here:

\documentclass{article}

\usepackage{biblatex}

\DeclareCiteCommand{\supercite}[\mkbibsuperscript]
  {\iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}}
  {\usebibmacro{citeindex}%
   \bibopenbracket\usebibmacro{cite}\bibclosebracket}
  {\supercitedelim}
  {}

\usepackage{filecontents}

\begin{filecontents}{test.bib}
@book{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@book{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@article{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}

\addbibresource{test.bib}

\let\cite=\supercite

\begin{document}

We are citing \supercite{A01,C03} and \supercite{B02} and \cite{A01,B02,C03}

\printbibliography

\end{document}

which puts the numbers in brackets and in superscript, but i'd like to group them. In the example i get [1],[3] but i want [1,3] and instead of [1],[2],[3] I want [1-3].

Is this possible? And if so, how?

share|improve this question
1  
Welcome to TeX.SX! –  Marco Daniel May 18 '13 at 18:37

1 Answer 1

up vote 3 down vote accepted

You have to put the commands \bibopenbracket and \bibclosebracket outsite of the cite-loop:

\DeclareCiteCommand{\supercite}[\mkbibsuperscript]
  {\iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}%
   \bibopenbracket}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\supercitedelim}
  {\bibclosebracket}

To get a compact version of the numeric style you can use the style numeric-comp. Therefor you need an other modification of \supercite.

\DeclareCiteCommand{\supercite}[\mkbibsuperscript]
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}%
  \bibopenbracket}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}\bibclosebracket}

Here the complete MWE:

\documentclass{article}

\usepackage[style=numeric-comp]{biblatex}


\DeclareCiteCommand{\supercite}[\mkbibsuperscript]
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}%
  \bibopenbracket}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}\bibclosebracket}

\usepackage{filecontents}

\begin{filecontents}{test.bib}
@book{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@book{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@article{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie},
}
\end{filecontents}

\addbibresource{test.bib}

\let\cite=\supercite

\begin{document}

We are citing \supercite{A01,C03} and \supercite{B02} and \cite{A01,B02,C03}

\printbibliography

\end{document}

enter image description here

share|improve this answer
    
thanks! this worked for the first part of my question :) What about making [1,2,3] turn into [1-3]? –  titto May 18 '13 at 18:43
    
@titto: Please see my edit. –  Marco Daniel May 18 '13 at 18:49
    
Great! works like a charm. Thanks a lot! –  titto May 18 '13 at 18:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.