我有以下 MWE。
\documentclass{article}
\usepackage[super]{cite}
\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 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}
\begin{document}
This is some text that requires citation\cite{testref1,testref2,testref3}.
\bibliographystyle{plain}
\bibliography{samplebib}
\end{document}
输出如下。
问题
是否可以将引用的数字分开,即:
这是一些需要引用的文本 \textsuperscript{1,2-3}
而不是像现在这样自动压缩引用参考文献的范围,如“1-3”。
一些额外的信息
- 在我的实际文件中,我正在使用
.bst
用生成的文件makebst
,并且正在使用scrreprt
文档类,如果有帮助的话。 bibtex
如果 MWE 中还不清楚的话,我会使用。- 我确实希望我的一般文档中的默认“样式”被压缩。只是我有一个实例,我想在其中进行特定的引用明确的,而不是隐藏在压缩的参考列表中。
谢谢!
答案1
这是一个解决方法,使用单独的\cite
宏,形式为\cite{testref1}$^,$\cite{testref2,testref3,testref4}
。我\mcite
使用以下带&
分隔符的语法将其封装在:
\mcite{testref1&testref2,testref3,testref4&testref5,testref6,testref7}
请注意,我添加了参考文献 4-7,因为引用参考文献 2 和 3 时会显示为2,3
而不是2-3
。此外,还必须手动处理标点符号的位置。
\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}
答案2
您可以定义一个自定义宏来处理包含逗号的引用列表,例如:
\newcommand*\citeuncomp[1]{%
\textsuperscript{%
\@for\thereference:=#1\do{\originalcite\thereference},}%
}
\let\originalcite\cite
要去掉结尾的逗号,你可以定义然后\def\processcomma{\def\processcomma{,}}
说:
\newcommand*\citeuncomp[1]{%
\textsuperscript{%
\@for\thereference:=#1\do{\processcomma\originalcite\thereference}}%
}
然后定义在文本中使用的 switchte:
\newcommand*\citesuncompressed{\let\cite\citeuncomp\renewcommand*\@citess[1]{##1}}
\newcommand*\citescompressed{\let\cite\originalcite\renewcommand\@citess[1]{\textsuperscript{##1}}}
然后你可以使用类似的解决方案
...
\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}
其产生以下输出。
完整代码
\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}
附录
如果标点符号的顺序很重要(即在引用之前有点),您可以按如下方式定义。
\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
}
答案3
cite
我们可以使用内部具有nocompress
打开和关闭选项的代码:
\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}