使用 BibLaTeX,我想建立一個\textcite
基於 numeric-comp 樣式的命令,該命令不顯示 [1-3, 5],而是顯示參考文獻。 1-3 和 5,而不是顯示 [1-3, 5-7] 給出參考文獻。 1-3和5-7。
我已經能夠透過以下 MWE 實現前者,但不能實現後者:
\documentclass{article}
\usepackage{filecontents}
\usepackage[style=numeric-comp]{biblatex}
% Cite without square brackets - with Ref./Refs.
\NewBibliographyString{refname}
\NewBibliographyString{refsname}
\DefineBibliographyStrings{english}{%
refname = {Ref\adddot},
refsname = {Refs\adddot}
}
\DeclareCiteCommand{\textcite}
{%
\ifnum\thecitetotal=1
\bibstring{refname}%
\else%
\bibstring{refsname}%
\fi%
\addnbspace%
\usebibmacro{cite:init}%
\usebibmacro{prenote}%
\renewcommand*{\multicitedelim}{\iflastcitekey{\addspace\bibstring{and}\addspace}{\addcomma\addspace}}%
}
{\usebibmacro{citeindex}\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}\usebibmacro{postnote}}
\begin{filecontents*}{\jobname.bib}
@book{A,
title = {A Bla},
author = {A Foo}
}
@book{B,
title = {B Bla},
author = {B Foo}
}
@book{C,
title = {C Bla},
author = {C Foo}
}
@book{D,
title = {D Bla},
author = {D Foo}
}
@book{E,
title = {E Bla},
author = {E Foo}
}
@book{F,
title = {F Bla},
author = {F Foo}
}
@book{G,
title = {G Bla},
author = {G Foo}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
Cite commands should stay like this (i.e. no and): \cite{A,B,C,E,F,G}
These textcites work: \textcite{A,C,E,G} ; \textcite{A,B,C,E}
This textcite misses the final and: \textcite{A,C,E,F,G}
This textcite has two ands: \textcite{A,C,D,F}
\printbibliography
\end{document}
MWE 的輸出:
我認為問題在於,當引用被壓縮時,最後一個 citekey 位於壓縮間隔內,因此根本不會列印引用清單分隔符號。是否有一個測試可以用來檢查實際列印的最後一個分隔符,即使它不在最後一個 citekey 之前?另外,請注意,在最後一個示例中,有兩個“與”,我認為問題再次在於它\iflastcitekey
並沒有真正按預期工作。