Abreviar autores exibidos + ano no biblatex para não exceder 1 linha

Abreviar autores exibidos + ano no biblatex para não exceder 1 linha

Estou montando meu biblatexpara minha tese e estou ciente de simplesmente limitar os autores exibidos a um determinado valor na bibliografia (por exemplo, \maxbibnames=5& \minbibnames=5). No entanto, quero garantir que a linha de autores incluindo (ano) seja limitada a número = X (digamos apenas 5 autores exibidos), MAS também não exceda a primeira linha. Portanto, se "autores incl. (ano)" exigir mais de 1 linha no documento, biblatex simplesmente corta mais bibnames do que originalmente definido com \maxbibnames/ \minbibnames(Mas é claro, apenas para esta entrada).

Exemplo agora:

Einstein, A., Tesla, N., Jones, I., Jefferson, T. e Hood, R.

e outros. (1980).Um papel muito bom.Natureza 1: 100-150.

Exemplo abreviado como novo:

Einstein, A., Tesla, N., Jones, I. e Jefferson, T. et al. (1980).

Um papel muito bom.Natureza 1: 100-150.

Responder1

O código a seguir simplesmente faz uma contagem regressiva do número de nomes e verifica se eles cabem em uma linha.

As definições originais das macros são retiradas de authoryear.bbx, adicionamos apenas um wrapper fino que faz a contagem regressiva e mede o comprimento da saída.

\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}

insira a descrição da imagem aqui

informação relacionada