![类似 \textcite 的新命令,但可自由配置作者数量](https://linux22.com/image/455010/%E7%B1%BB%E4%BC%BC%20%5Ctextcite%20%E7%9A%84%E6%96%B0%E5%91%BD%E4%BB%A4%EF%BC%8C%E4%BD%86%E5%8F%AF%E8%87%AA%E7%94%B1%E9%85%8D%E7%BD%AE%E4%BD%9C%E8%80%85%E6%95%B0%E9%87%8F.png)
我正在使用 biblatex,并希望定义一个类似的新命令\textcite
,但可以自由配置打印的作者数量。在文档的其余部分,我仍然想使用全局配置,例如全局的maxcitenames
。
以下是一个小例子:
\documentclass{article}
\usepackage[citestyle=numeric-comp,bibstyle=numeric,backend=biber,maxcitenames=1,maxbibnames=10]{biblatex}
\begin{filecontents}{ref.bib}
@BOOK{test1,
AUTHOR = {Author, A. and Buthor, B. and Cuthor, C. and Duthor, D.},
TITLE = {Test},
YEAR = {2000},
}
\end{filecontents}
\addbibresource{ref.bib}
\newcommand{\textcitenew}[1]{\AtNextCite{\defcounter{maxnames}{#1}}\textcite}
\begin{document}
Reference to \textcite{test1} and \textcitenew{3}{test1}.
\printbibliography
\end{document}
期望的输出是 Reference to Author et al. [1] and Author, Buthor, Cuthor et al. [1].
实际输出是Reference to Author et al. [1] and Author et al. [1].
我认为,一个好的解决方案是进行局部改变maxcitenames
,但不幸的是,这并不能在示例中产生预期的结果。
澄清:我希望打印的作者数量完全等于新命令的参数(不截断)。
答案1
改编
- 定义的命令
\setmincitenames
和\setmaxcitenames
(参见这个答案针对这个问题BibLatex:本地更改最大作者数量) - 使用参数
\textcitenew
在本地设置 mincitenames 和 maxcitenames
结果
代码
\documentclass{article}
\usepackage[citestyle=numeric-comp,bibstyle=numeric,backend=biber,maxcitenames=1,maxbibnames=10]{biblatex}
\begin{filecontents}{ref.bib}
@BOOK{test1,
AUTHOR = {Author, A. and Buthor, B. and Cuthor, C. and Duthor, D.},
TITLE = {Test},
YEAR = {2000},
}
\end{filecontents}
\addbibresource{ref.bib}
\makeatletter
\newrobustcmd*{\setmincitenames}{\numdef\blx@mincitenames}
\newrobustcmd*{\setmaxcitenames}{\numdef\blx@maxcitenames}
\makeatother
\newcommand{\textcitenew}[2]{{\setmincitenames{#1}\setmaxcitenames{#1}\textcite{#2}}}
\begin{document}
\textcite{test1}
2: \textcitenew{2}{test1}
3: \textcitenew{3}{test1}
4: \textcitenew{4}{test1}
\printbibliography
\end{document}