style=ieee
我在 中使用了biblatex
;但是,当涉及到多个引用时,我想模拟style=numeric
。biblatex
考虑 MWE:
% rebuild command - bash:
% (shopt -s extglob; rm test.!(tex)) && pdflatex test.tex && biber test && pdflatex test.tex && pdflatex test.tex
\documentclass{book}
\usepackage[colorlinks=true,citecolor=blue]{hyperref}
\usepackage[%
style=ieee,
% style=numeric,
isbn=true,
doi=false,
sorting=none,
url=true,
defernumbers=true,
bibencoding=utf8,
backend=biber
]{biblatex}
\addbibresource{biblatex-examples.bib}
% https://tex.stackexchange.com/questions/74296/to-have-no-pagebreak-before-bibliography
\defbibheading{secbib}[\bibname]{%
\section*{#1}%
\markboth{#1}{#1}}
\begin{document}
\noindent
Style is: \makeatletter \texttt{\blx@bbxfile} \makeatother
Testing single \verb!\cite!: \cite{aristotle:poetics}, \cite{augustine}, \cite{aksin}, \cite{angenendt};
Testing multiple \verb!\cite!: \cite{augustine, angenendt, aristotle:poetics, aksin}
Testing \verb!\cites!: \cites{aksin}{augustine}{aristotle:poetics}
\printbibliography[heading=secbib]
\end{document}
ieee
vs样式的结果numeric
如下:
如您所见,在 中ieee
,像 这样的单个命令中多个引用的输出\cite{citA,citB...}
被压缩为[1]-[2]
,而biblatex
\cites{citA}{citB}...
输出带有方括号且中间有逗号的完整引用:[1], [2], ...
。
相比之下,对于这两个命令,numeric
样式打开一对方括号,并在其中包含引文索引,用逗号分隔[1, 2, ...]
(并且保留引文的顺序,相关Biblatex,数字样式,多引用:参考文献顺序)——这正是我想要通过这种ieee
风格实现的效果。
有什么方法可以实现这一点?我不介意为此使用自定义引用命令(我只是不知道从哪里开始),所以我可以保持和的默认行为\cite
不变\cites
-ieee
但最终,任何修复建议都是受欢迎的:)
答案1
使用 biblatex 可以组合不同“风格”的参考书目,特别是,您可以组合风格ieee
来控制参考书目的打印方式,并numeric-comp
控制 cite 命令的输出:
你需要的是:
\usepackage[%
bibstyle=ieee,
citestyle=numeric,
isbn=true,
doi=false,
sorting=none,
url=true,
defernumbers=true,
bibencoding=utf8,
backend=biber
]{biblatex}
产生以下输出(使用提供的 MWE)
答案2
我有点好奇,如果我想保留所有 cite 命令ieee
,并简单地添加一个在此环境中表现相同的新 cite 命令,我该怎么做numeric
\cite
;所以我将在此处发布示例。这有点像 hack,但引入了一个新命令\nmcite
,它表现出以下行为:
... 以及代码(带有相关注释),这里:
% rebuild command - bash:
% (shopt -s extglob; rm test.!(tex)) && pdflatex test.tex && biber test && pdflatex test.tex && pdflatex test.tex
\documentclass{book}
\usepackage[colorlinks=true,citecolor=blue]{hyperref}
% \usepackage{trace}
\usepackage[%
style=ieee,
% style=numeric,
isbn=true,
doi=false,
%sorting=none, % ieee.cbx does sorting=none
url=true,
defernumbers=true,
bibencoding=utf8,
backend=biber
]{biblatex}
\addbibresource{biblatex-examples.bib}
% http://tex.stackexchange.com/questions/74296/to-have-no-pagebreak-before-bibliography
\defbibheading{secbib}[\bibname]{%
\section*{#1}%
\markboth{#1}{#1}}
% defernumbers=true: "... numeric labels (i. e., the labelnumber field discussed in § 4.2.4) are assigned the first time an entry is printed in any bibliography. ... requires two LaTeX runs ..."
%
% ieee.cbx: \RequireCitationStyle{numeric-comp}
% numeric-comp; "A compact variant of the numeric style which prints a list of more than two consecutive numbers as a range. This style is similar to the cite package and the sort&compress option of the natbib package in numerical mode. For example, instead of “[8, 3, 1, 7, 2]” this style would print “[1–3, 7, 8]”."
% numeric-comp.cbx: \ExecuteBibliographyOptions{labelnumber,sortcites,autocite=inline}
% numeric.cbx: \ExecuteBibliographyOptions{labelnumber,autocite=inline}
%
% \DeclareBibliographyOption{sortcites}[true]{%
% {\let\blx@thecitesort\blx@citesort % \blx@citenosort
%
% > \blx@thecitesort=macro: ->\ifnum \blx@tempcnta >\@ne \blx@filtercitesort %% which loops through list: \ifinlistcs {##1}{#2} {\listadd #1{##1}\advance ...
%
% \protected\def\blx@citeloop#1{% uses \blx@thecitesort !
%
% so: {\makeatletter \let\blx@thecitesort\blx@citenosort \makeatother \nmcite{} } works to suppress cite sorting; if \nmcite is just direct copy from numeric.cbx
% BUT - it can also be localised if \let..\blx@citenosort is right before the \mkbibbrackets option (it doesn't interfere then with rest of code; ieee \cite works as usual = probably that runs inside local scope grouping)
%
% these are otherwise just renamed copies from biblatex/cbx/numeric.cbx:
\newbibmacro*{nmcite}{%
\printtext[bibhyperref]{%
\printfield{prefixnumber}%
\printfield{labelnumber}%
\ifbool{bbx:subentry}
{\printfield{entrysetcount}}
{}}}
\makeatletter
\DeclareCiteCommand{\nmcite}[%
\let\blx@thecitesort\blx@citenosort%
\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{nmcite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\makeatother
\begin{document}
\noindent
Style is: \makeatletter \texttt{\blx@bbxfile};
% \show\blx@filtercitesort
\makeatother
Testing single \verb!\cite!: \cite{aristotle:poetics}, \cite{augustine}, \cite{aksin}, \cite{angenendt};
Testing multiple \verb!\cite!: \cite{augustine, angenendt, aristotle:poetics, aksin}
Testing \verb!\cites!: \cites{aksin}{augustine}{aristotle:poetics}
% \traceon
% {
% \makeatletter
% \let\blx@thecitesort\blx@citenosort \makeatother
Testing \verb!\nmcite!: \nmcite{augustine, angenendt, aristotle:poetics, aksin}
% }
% \traceoff
Testing \verb!\nmcite!: \nmcite{angenendt, aristotle:poetics, aksin}
Testing multiple \verb!\cite!: \cite{angenendt, aristotle:poetics, aksin}
Testing multiple \verb!\cite!: \cite{augustine, angenendt, aristotle:poetics, aksin}
\printbibliography[heading=secbib]
\end{document}