我正在為我的論文設定我的biblatex
論文,並意識到簡單地將顯示的作者限制為參考書目中的某個值(例如\maxbibnames=5
& \minbibnames=5
)。然而,我希望實現包括(年份)在內的作者行限制為 number=X (假設 5 個顯示的作者),但也不超過第一行。因此,如果「authors incl.(year)」在文件中需要超過 1 行,biblatex 會簡單地剪切比最初用\maxbibnames
/定義的更多的書目名\minbibnames
(但當然僅適用於這個條目)。
現在的例子:
愛因斯坦,A.、特斯拉,N.、瓊斯,I.、傑佛遜,T. 和胡德,R.
等人。 (1980)。一篇非常好的論文。自然 1:100-150。
新縮寫範例:
愛因斯坦,A.,特斯拉,N.,瓊斯,I. 和傑斐遜,T. 等人。 (1980)。
一篇非常好的論文。自然 1:100-150。
答案1
以下程式碼只是計算名稱數量並檢查它們是否適合一行。
巨集的原始定義取自authoryear.bbx
,我們只添加一個薄包裝器來倒數計時並測量輸出長度。
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=authoryear, maxbibnames=999, dashed=false]{biblatex}
\usepackage{hyperref}
\addbibresource{biblatex-examples.bib}
\makeatletter
\newcounter{namecountdown}
\newlength{\bbx@namelength}
\newbibmacro*{bbx:measure:outer}[2]{%
\settowidth{\bbx@namelength}{\usebibmacro*{#1}{#2}}%
\ifboolexpr{test {\ifdimgreater{\bbx@namelength}{\linewidth}}
and test {\ifnumgreater{\value{namecountdown}}{1}}}
{\advance\c@namecountdown\m@ne
\usebibmacro{bbx:measure:outer}{#1}{#2}}
{\usebibmacro*{#1}{#2}}}
\renewbibmacro{author}{%
\ifnumless{\value{maxnames}}{\value{author}}
{\c@namecountdown\c@maxnames}
{\c@namecountdown\c@author}%
\usebibmacro{bbx:measure:outer}{bbx:measure:author:inner}{}}
\newbibmacro*{bbx:measure:author:inner}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\usebibmacro{bbx:savehash}%
\printnames[][1-\the\value{namecountdown}]{author}%
\iffieldundef{authortype}
{\setunit{\printdelim{nameyeardelim}}}
{\setunit{\printdelim{authortypedelim}}}}%
\iffieldundef{authortype}
{}
{\usebibmacro{authorstrg}%
\setunit{\printdelim{nameyeardelim}}}}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\setunit*{\printdelim{nonameyeardelim}}}%
\usebibmacro{date+extradate}}
\renewbibmacro*{bbx:editor}[1]{%
\ifnumless{\value{maxnames}}{\value{editor}}
{\c@namecountdown\c@maxnames}
{\c@namecountdown\c@editor}%
\usebibmacro{bbx:measure:outer}{bbx:measure:editor:inner}{#1}}
\newbibmacro*{bbx:measure:editor:inner}[1]{%
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\printnames[][1-\the\value{namecountdown}]{editor}%
\setunit{\printdelim{editortypedelim}}%
\usebibmacro{bbx:savehash}}%
\usebibmacro{#1}%
\clearname{editor}%
\setunit{\printdelim{nameyeardelim}}}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\setunit*{\printdelim{nonameyeardelim}}}%
\usebibmacro{date+extradate}}
\renewbibmacro*{bbx:translator}[1]{%
\ifnumless{\value{maxnames}}{\value{translator}}
{\c@namecountdown\c@maxnames}
{\c@namecountdown\c@translator}%
\usebibmacro{bbx:measure:outer}{bbx:measure:translator:inner}{#1}}
\newbibmacro*{bbx:measure:translator:inner}[1]{%
\ifboolexpr{
test \ifusetranslator
and
not test {\ifnameundef{translator}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\printnames[][1-\the\value{namecountdown}]{translator}%
\setunit{\printdelim{translatortypedelim}}%
\usebibmacro{bbx:savehash}}%
\usebibmacro{#1}%
\clearname{translator}%
\setunit{\printdelim{nameyeardelim}}}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\setunit*{\printdelim{nonameyeardelim}}}%
\usebibmacro{date+extradate}}
\makeatother
\begin{document}
\cite{companion,aksin,herrmann,sigfridsson,jaffe}
\printbibliography
\end{document}