I am in a similar situation as described in this question: uncompressing cite references locally, but I have a slight complication. I think it is preferable to start a new question instead of leaving a comment on the original one. So here goes:
Problem
I need to uncompress a cited reference locally (just this one occasion), such that instead of ...needs citation [1-5]
, I have something like ...needs citation [1,2-5]
. Notice that ref. 1 is now separated from the main 'group' of references. See the MWE below.
MWE and attempt
Consider the following MWE (slightly modified from the one in the above link, and one of the solution from that link is applied below):
\documentclass{article}
\usepackage{cite}
\usepackage{hyperref,cleveref} % I am using these packages as well
\usepackage{filecontents}
% References
\begin{filecontents}{samplebib.bib}
@article{testref1,
title = {Test title},
journal = {Test Journal},
author = {Test authors and others},
volume = {1},
year = {2016}
}
@article{testref2,
title = {Test title},
journal = {Test Journal},
author = {Test authors and others},
volume = {1},
year = {2016}
}
@article{testref3,
title = {Test title},
journal = {Test Journal},
author = {Test authors and others},
volume = {1},
year = {2016}
}
@article{testref4,
title = {Test title},
journal = {Test Journal},
author = {Test authors and others},
volume = {1},
year = {2016}
}
@article{testref5,
title = {Test title},
journal = {Test Journal},
author = {Test authors and others},
volume = {1},
year = {2016}
}
\end{filecontents}
\makeatletter % Cite references to be in square brackets, superscript
\renewcommand{\@cite}[1]{\textsuperscript{[#1]}}
\makeatother
% The accepted solution from the original question - Credit to Steven B. Segletes
% \newcommand\mcite[1]{\expandafter\mcitehelp\noexpand#1&\relax} % (Old)
\newcommand\mcite[1]{\mcitehelp#1&\relax} % (Updated Code)
\def\mcitehelp#1\relax{\cite{#1}\ifx\relax#2\relax\else$^,$\mcitehelp#2\relax\fi}
\begin{document}
This is some text that requires citation
\mcite{testref1&testref2, testref3, testref4, testref5}.
But this is unsatisfactory because I'd prefer it to look like:
This is some text that requires citation \textsuperscript{[1,\,2--5]}.
\bibliographystyle{plain}
\bibliography{samplebib}
\end{document}
I left the \hyperref
and \cleveref
packages in the MWE because hopefully your answer will not interfere with my use of these packages.
I am aware that \cite
has the option \uncompress
but that is unsatisfactory because:
- That applies throughout the document. I only need this once.
- It lists all the references singularly
([1],[2],[3],[4],[5])
, which I don't want. I only want one reference to be isolated from the group. The rest should stay grouped.
Question
So I guess my question is, can I get some help with modifying the code so that I can achieve the desired output? I'm still rather new to programming with LaTeX. Thank you!
TL;DR:
I want an uncompressed cited reference, just like how the cleveref
package allows with \cref{label1, ,label2,label3,label4}
for normal labels, which will give me an output like the one in the picture (bottom one).
\newcommand\mcite[1]{\mcitehelp#1&\relax}
is now defined more simply. – Steven B. Segletes Jan 5 '17 at 11:48