![Alterar "et al" na bibliografia caso contenha um autor específico](https://rvso.com/image/392335/Alterar%20%22et%20al%22%20na%20bibliografia%20caso%20contenha%20um%20autor%20espec%C3%ADfico.png)
Estou tentando mudar o et ~ al. que aparece na bibliografia no caso de dentro dos autores extras (et~al) existir um autor que estou tentando colocar em negrito na bibliografia usando a resposta de @LawrenceCrosbyaqui
Meu código é:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{MyBibliography.bib}
@article{cite1,
author={Konstantinos Leledakis},
title={An Article},
year={2019},
journal={Some Journal}
}
@article{cite2,
author={Another Author and Konstantinos Leledakis},
title={A Book},
year={2017},
journal={A publisher}
}
@book{cite3,
author={Another SomeAuthor and One AnotherAuthor and SomeOther UnKnownAuthor and Konstantinos Leledakis},
title={A Book},
year={1988},
publisher={Someone}
}
@book{cite4,
author={Another Author and An UnknownAuthor and SomeOther UnKnownAuthor},
title={A Book},
year={2015},
publisher={A publisher}
}
\end{filecontents}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear-comp,maxnames=2, minnames=2]{biblatex}
\usepackage{etoolbox}
\DefineBibliographyStrings{english}{andothers={\ifthenelse{\boolean{bold}}{et~al(including Leledakis, K.)}{et~al}\adddot}}
\newboolean{bold}
\newcommand{\makeauthorbold}[1]{%
\setboolean{bold}{false}
\DeclareNameFormat{author}{%
\ifthenelse{\value{listcount}=1}
{%
{\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\setboolean{bold}{true}\mkbibbold{\namepartfamily\addcomma\addspace \namepartgiveni}}{\namepartfamily\addcomma\addspace \namepartgiveni}}
%
}{\ifnumless{\value{listcount}}{\value{liststop}}
{\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\setboolean{bold}{true}\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni}}
{\expandafter\ifstrequal\expandafter{\namepartfamily}{#1}{\setboolean{bold}{true}\mkbibbold{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}{\addcomma\addspace \namepartfamily\addcomma\addspace \namepartgiveni\addcomma\isdot}}%
}
\ifthenelse{\value{listcount}<\value{liststop}}
{\addcomma\space}
}
}
%\makeauthorbold{Leledakis}
\DefineBibliographyStrings{english}{andothers={et~al}} % To translate "et al."
\ExecuteBibliographyOptions{firstinits=true, uniquename=init}
\addbibresource{MyBibliography.bib}
\renewcommand*{\nameyeardelim}{\addcomma\addspace} % Should add the comma, but somehow doesn't work
\begin{document}
\nocite{*}
\printbibliography
\end{document}
Isso tem dois problemas:
- Se eu comentar (quero dizer ativar) o comando comentado
%\makeauthorbold{Leledakis}
e ativá-lo. O resultado de:
(que contém alguns et~al).torna-se:
Onde o nome já está destacado mas o et~al. parte está faltando.
PS: Testei o código sem minhas alterações também, mas ainda falta o et. al. papel.
Responder1
É \DeclareNameFormat{author}
uma modificação do formato do nome original que deixa algumas coisas a desejar.
- Não pode lidar com peças “von” e “Jr.” peças.
- Não é possível lidar com "et al.", porque falta uma chamada para o padrão
\usebibmacro{name:andothers}
. - Em uma
biblatex
versão moderna, até produzirá um erro devido a um erro de sintaxe. (O último\ifthenelse
está faltando umfalsofilial. Veja tambémhttps://github.com/plk/biblatex/issues/874.)
Sugiro que você use uma das versões mais robustas para deixar seu nome em negrito sugerido emColoque um autor específico em negrito usando biblatex. Até onde posso ver, nenhuma das soluções coloca em negrito o "et al." se "contiver" o nome relevante pronto para uso, mas podemos adicioná-lo.
Como base estou usandominha respostaque usa hashes, mas permite uma interface conveniente para recuperá-los. O complicado é verificar se o "et al." também contém um nome a ser destacado. Fazemos isso repetindo todos os nomes restantes em um arquivo \indexnames
que, de outra forma, não imprime nada.
\documentclass{article}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear-comp,
maxnames=2, minnames=2,
giveninits=true, uniquename=init]{biblatex}
\makeatletter
% setup for auxiliary bib file
\def\hlblx@bibfile@name{\jobname -boldnames.bib}
\newwrite\hlblx@bibfile
\immediate\openout\hlblx@bibfile=\hlblx@bibfile@name
\newcounter{hlblx@name}
\setcounter{hlblx@name}{0}
% write names to auxiliary bib file and push hash to bold list
\newcommand*{\hlblx@writenametobib}[1]{%
\stepcounter{hlblx@name}%
\edef\hlblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\noexpand\hlblx@getmethehash{hlblx@name@\the\value{hlblx@name}}}}%
}%
\hlblx@tmp@nocite
\immediate\write\hlblx@bibfile{%
@misc{hlblx@name@\the\value{hlblx@name}, author = {\unexpanded{#1}}, %
options = {dataonly=true},}%
}%
}
\AtEndDocument{%
\closeout\hlblx@bibfile}
\addbibresource{\hlblx@bibfile@name}
% extract hashes from bib file
\newcommand*{\hlbxl@boldhashes}{}
\DeclareNameFormat{hlblx@hashextract}{%
\xifinlist{\thefield{hash}}{\hlbxl@boldhashes}
{}
{\listxadd{\hlbxl@boldhashes}{\thefield{fullhash}}}}
\DeclareCiteCommand{\hlblx@getmethehash}
{}
{\printnames[hlblx@hashextract][1-999]{author}}
{}
{}
% add and reset list of bold names
\newcommand*{\addboldnames}{\forcsvlist\hlblx@writenametobib}
\newcommand*{\resetboldnames}{\def\hlbxl@boldhashes{}}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\hlbxl@boldhashes}
{\mkbibbold{#1}}
{#1}}
\newtoggle{boldnameincluded}
\newbibmacro*{name:flagbold}{%
\def\do##1{\iffieldequalstr{hash}{##1}{\global\toggletrue{boldnameincluded}\listbreak}{}}%
\dolistloop{\hlbxl@boldhashes}%
}
\DeclareNameWrapperFormat{boldifhashinlist}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{boldifhashinlist}
\DeclareIndexNameFormat{flagbold}{%
\usebibmacro{name:flagbold}}
\newcounter{boldflagcount}
\newcommand*{\mkbibboldandothers}[2]{%
\iftoggle{boldnameincluded}
{\mkbibbold{#2#1}}
{#2}}
\renewbibmacro*{name:andothers}{%
\ifboolexpr{
test {\ifnumequal{\value{listcount}}{\value{liststop}}}
and
test \ifmorenames
}
{\ifnumgreater{\value{liststop}}{1}
{\finalandcomma}
{}%
\global\togglefalse{boldnameincluded}%
\ifnumgreater{\value{listtotal}}{\value{listcount}}
{\defcounter{boldflagcount}{\value{listcount}+1}%
\expandafter\def\expandafter\hlblx@currname\expandafter{\currentname}%
\indexnames[flagbold][\the\value{boldflagcount}-\the\value{listtotal}]{\hlblx@currname}}%
{}%
\printdelim{andothersdelim}%
\bibstring[\mkbibboldandothers{ (incuding K.~Leledakis)}]{andothers}}
{}}
\makeatother
\addboldnames{Konstantinos Leledakis}
\begin{filecontents}{\jobname.bib}
@article{cite1,
author = {Konstantinos Leledakis},
title = {An Article},
year = {2019},
journal = {Some Journal},
}
@article{cite2,
author = {Another Author and Konstantinos Leledakis},
title = {A Book},
year = {2017},
journal = {A publisher},
}
@book{cite3,
author = {Another SomeAuthor and One AnotherAuthor
and SomeOther UnKnownAuthor and Konstantinos Leledakis},
title = {A Book},
year = {1988},
publisher = {Someone},
}
@book{cite4,
author = {Another Author and An UnknownAuthor
and SomeOther UnKnownAuthor},
title = {A Book},
year = {2015},
publisher = {A publisher},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
Se você deseja formatar uma lista de publicações para o seu currículo, você pode dar uma olhada embiblatex-publist
.
editadousar uma versão mais elegante para formatar nomes completos. \DeclareNameWrapperFormat
e \mkbibcompletename
estão disponíveis apenas em biblatex
v3.12 (30/10/2018) e v3.13 (17/08/2019), respectivamente. Consulte o histórico de edições se você estiver usando uma versão mais antiga do biblatex
.