Uncompress cite references locally
Here is a workaround, by using separate \cite
macros, in the form of \cite{testref1}$^,$\cite{testref2,testref3,testref4}
. I have encapsulated this in \mcite
using the following syntax with &
separator:
\mcite{testref1&testref2,testref3,testref4&testref5,testref6,testref7}
Note that I added a references 4-7, since citing reference 2 and 3 together will show as 2,3
and not 2-3
. Also, one has to manually deal with punctuation placement.
\documentclass{article}
\usepackage[super]{cite}
\usepackage{filecontents}
\def\ce#1{#1}
\begin{filecontents*}{samplebib.bib}
@article{testref1,
title = {Multiple phase transitions in rare earth tetraborides at low temperature},
journal = {Solid State Commun.},
author = {Fisk, Z. and Maple, M. B. and others},
volume = {39},
pages = {1189--1192},
year = {1981},
doi = {10.1016/0038-1098(81)91111-X}
}
@article{testref2,
title = {Magnetic Structure and Phase Diagram of \ce{TmB4}},
author = {{Gab{\'a}ni}, S. and {Ma{\v t}a{\v s}}, S. and others},
journal = {Acta Phys. Pol., A},
volume = {113},
pages = {227--230},
year = {2008},
doi = {10.12693/APhysPolA.113.227}
}
@article{testref3,
title = {Classical and quantum routes to linear magnetoresistance},
author = {Hu, J. and Rosenbaum, T. F.},
journal = {Nat. Mat.},
volume = {7},
pages = {697--700},
year = {2008},
doi = {10.1038/nmat2259}
}
@article{testref4,
title = {Classical and quantum routes to linear magnetoresistance},
author = {Hu, J. and Rosenbaum, T. F.},
journal = {Nat. Mat.},
volume = {7},
pages = {697--700},
year = {2008},
doi = {10.1038/nmat2259}
}
@article{testref5,
title = {Classical and quantum routes to linear magnetoresistance},
author = {Hu, J. and Rosenbaum, T. F.},
journal = {Nat. Mat.},
volume = {7},
pages = {697--700},
year = {2008},
doi = {10.1038/nmat2259}
}
@article{testref6,
title = {Classical and quantum routes to linear magnetoresistance},
author = {Hu, J. and Rosenbaum, T. F.},
journal = {Nat. Mat.},
volume = {7},
pages = {697--700},
year = {2008},
doi = {10.1038/nmat2259}
}
@article{testref7,
title = {Classical and quantum routes to linear magnetoresistance},
author = {Hu, J. and Rosenbaum, T. F.},
journal = {Nat. Mat.},
volume = {7},
pages = {697--700},
year = {2008},
doi = {10.1038/nmat2259}
}
\end{filecontents*}
\newcommand\mcite[1]{\mcitehelp#1&\relax}
\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,testref6,testref7}
\bibliographystyle{plain}
\bibliography{samplebib}
\end{document}
You could define a custom macro that processes the list of cites mantaining the commas like:
\newcommand*\citeuncomp[1]{%
\textsuperscript{%
\@for\thereference:=#1\do{\originalcite\thereference},}%
}
while \let\originalcite\cite
. To get rid of the trailing comma you could define \def\processcomma{\def\processcomma{,}}
and then say:
\newcommand*\citeuncomp[1]{%
\textsuperscript{%
\@for\thereference:=#1\do{\processcomma\originalcite\thereference}}%
}
Then you define switchtes that you use inside your text:
\newcommand*\citesuncompressed{\let\cite\citeuncomp\renewcommand*\@citess[1]{##1}}
\newcommand*\citescompressed{\let\cite\originalcite\renewcommand\@citess[1]{\textsuperscript{##1}}}
You could then use the solution like
...
\begin{document}
\citesuncompressed
This is some text that requires citation\cite{testref1,testref2,testref3}.
\citescompressed
This is some text that requires citation\cite{testref1,testref2,testref3}.
\bibliographystyle{plain}
\bibliography{samplebib}
\end{document}
which yelds the following output.
Complete Code
\RequirePackage{filecontents}
\begin{filecontents*}{samplebib.bib}
@article{testref1,
title = {Multiple phase transitions in rare earth tetraborides at low temperature},
journal = {Solid State Commun.},
author = {Fisk, Z. and Maple, M. B. and others},
volume = {39},
pages = {1189--1192},
year = {1981},
doi = {10.1016/0038-1098(81)91111-X}
}
@article{testref2,
title = {Magnetic Structure and Phase Diagram of \ce{TmB4}},
author = {{Gab{\'a}ni}, S. and {Ma{\v t}a{\v s}}, S. and others},
journal = {Acta Phys. Pol., A},
volume = {113},
pages = {227--230},
year = {2008},
doi = {10.12693/APhysPolA.113.227}
}
@article{testref3,
title = {Classical and quantum routes to linear magnetoresistance},
author = {Hu, J. and Rosenbaum, T. F.},
journal = {Nat. Mat.},
volume = {7},
pages = {697--700},
year = {2008},
doi = {10.1038/nmat2259}
}
\end{filecontents*}
\documentclass{article}
\usepackage[super]{cite}
\providecommand*\ce[1]{#1}
\makeatletter
\let\originalcite\cite
\def\processcomma{\def\processcomma{,}}
\newcommand*\citeuncomp[1]{%
\textsuperscript{%
\@for\thereference:=#1\do{\processcomma\originalcite\thereference}}%
}
\newcommand*\citesuncompressed{\let\cite\citeuncomp\renewcommand*\@citess[1]{##1}}
\newcommand*\citescompressed{\let\cite\originalcite\renewcommand\@citess[1]{\textsuperscript{##1}}}
\makeatother
\begin{document}
\citesuncompressed
This is some text that requires citation\cite{testref1,testref2,testref3}.
\citescompressed
This is some text that requires citation\cite{testref1,testref2,testref3}.
\bibliographystyle{plain}
\bibliography{samplebib}
\end{document}
Addendum
If the order of punctuation matters (i.e. having the dot before the citation) you can define as follows.
\newcommand*\citeuncomp[2]{%
\gdef\@tempa{#2}%
\ifx#2.\@tempswatrue\else\@tempswafalse\fi
\citeunc@mp{#1}%
}
\newcommand*\citeunc@mp[1]{%
\if@tempswa.\fi%
\textsuperscript{%
\@for\thereference:=#1\do{\processcomma\originalcite\thereference}}%
\if@tempswa\else\@tempa\fi
}
We can use the code that cite
has internally for the nocompress
option to turn things on and off:
\documentclass{article}
\usepackage[super]{cite}
\usepackage[version=4]{mhchem} % As one of the examples needs it!
\usepackage{filecontents}
\begin{filecontents}{samplebib.bib}
@article{testref1,
title = {Multiple phase transitions in rare earth tetraborides at low temperature},
journal = {Solid State Commun.},
author = {Fisk, Z. and Maple, M. B. and others},
volume = {39},
pages = {1189--1192},
year = {1981},
doi = {10.1016/0038-1098(81)91111-X}
}
@article{testref2,
title = {Magnetic Structure and Phase Diagram of \ce{TmB4}},
author = {{Gab{\'a}ni}, S. and {Ma{\v t}a{\v s}}, S. and others},
journal = {Acta Phys. Pol., A},
volume = {113},
pages = {227--230},
year = {2008},
doi = {10.12693/APhysPolA.113.227}
}
@article{testref3,
title = {Classical and quantum routes to linear magnetoresistance},
author = {Hu, J. and Rosenbaum, T. F.},
journal = {Nat. Mat.},
volume = {7},
pages = {697--700},
year = {2008},
doi = {10.1038/nmat2259}
}
\end{filecontents}
\makeatletter
\let\saved@compress@cite\@compress@cite
\protected\def\ActivateCompress{%
\let\@compress@cite\saved@compress@cite
}
\protected\def\DeactivateCompress{%
% The following is the code for sort + nocompress from cite.sty
\def\@compress@cite##1##2##3{% % This is executed for each number
\@h@ld \@citea \@cite@out{##3}%
\let\@h@ld\@empty \let\@citea\citepunct
}%
}
\makeatother
\begin{document}
\DeactivateCompress
This is some text that requires citation\cite{testref1,testref2,testref3}.
\ActivateCompress
This is some text that requires citation\cite{testref1,testref2,testref3}.
\bibliographystyle{plain}
\bibliography{samplebib}
\end{document}