使用moewe
的答案这里Biblatex
我可以将示例数字和范围添加到cite 命令的后记中。
moewe
的代码是完美的,因为它\mknormrange
直接使用,这是人们在与各种包选项的兼容性方面所能梦想的。
如何编写一个变体\mknormrangewithand
来添加和在最后两页或示例范围之间?
简单示例(仅带页面):
\cite[17-20,24-27,38-40]{ref}
将输出:
author (year: pp. 17-20,24-27 **and** 38-40)
。
\documentclass{article}
\usepackage[backend=biber, style=ext-authoryear-comp,]{biblatex}
\NewBibliographyString{example}
\NewBibliographyString{examples}
\DefineBibliographyStrings{english}{
example = {ex\adddot},
examples = {ex\adddot},
}
\DeclareDelimFormat{postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{\ppexformat{#1}}
\makeatletter
\ExplSyntaxOn
\seq_new:N \l_vk_ppex_chunks
\NewDocumentCommand\ppexformat{m}{\vk_ppex_chunk:n{#1}}
\cs_new_protected_nopar:Npn \vk_ppex_chunk:n #1
{
\seq_set_split:Nnn \l_vk_ppex_chunks ; {#1}
\seq_map_indexed_inline:Nn \l_vk_ppex_chunks
{
\int_compare:nNnT {##1} > {1}
{\addsemicolon\space}
\ppexformat@splitchunk {##2}
}
}
\ExplSyntaxOff
\NewDocumentCommand\ppexformat@splitchunk{>{\SplitArgument{1}{:}}m}{%
\ppexformat@ppex #1}
\NewDocumentCommand\ppexformat@ppex{mm}{%
\mkpageprefix[pagination][\mknormrange]{#1}%
\IfNoValueF{#2}
{\addcomma\space
\exformat{#2}}}
\newrobustcmd*{\exformat}[1]{%
\begingroup
\def\abx@field@pagination{example}%
\mkpageprefix[pagination][\mknormrange]{#1}%
\endgroup
}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
\textcite[54]{sigfridsson}
\textcite[54:32]{sigfridsson}
\textcite[45-52,63-65:3-6;57-68:21-23;72-74]{sigfridsson} % I want "and" between "45-52" and "63-65".
\end{document}