![Ändern Sie „et al“ in der Bibliographie, falls dort ein bestimmter Autor vorkommt.](https://rvso.com/image/392335/%C3%84ndern%20Sie%20%E2%80%9Eet%20al%E2%80%9C%20in%20der%20Bibliographie%2C%20falls%20dort%20ein%20bestimmter%20Autor%20vorkommt..png)
Ich versuche, die et~al. zu ändern, die in der Bibliographie erscheinen, falls sich innerhalb der zusätzlichen (et~al) Autoren ein Autor befindet, den ich mithilfe der Antwort von @LawrenceCrosby in der Bibliographie fett markieren möchte.Hier
Mein Code ist:
\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}
Dies hat zwei Probleme:
- Wenn ich den auskommentierten Befehl auskommentiere (also aktiviere)
%\makeauthorbold{Leledakis}
und aktiviere. Das Ergebnis ist:
(das etwas et~al enthält). wird zu:
Wobei der Name zwar schon hervorgehoben ist, der et~al.-Teil aber komplett fehlt.
PS: Ich habe den Code auch ohne meine Änderungen getestet, aber der et. al.-Teil fehlt immer noch.
Antwort1
Es \DeclareNameFormat{author}
handelt sich um eine Modifikation des ursprünglichen Namensformats, die einige Wünsche offen lässt.
- Es kann nicht mit „von“-Teilen und „Jr.“-Teilen umgehen.
- Mit "et al." kommt es nicht klar, da hier ein Verweis auf den Standard fehlt
\usebibmacro{name:andothers}
. - In einer modernen
biblatex
Version wird es sogar einen Fehler aufgrund eines Syntaxfehlers geben. (Bei letzterem\ifthenelse
fehlt einFALSCHZweig. Siehe auchhttps://github.com/plk/biblatex/issues/874.)
Ich schlage vor, Sie verwenden eine der robusteren Versionen, um Ihren Namen fett zu machen, vorgeschlagen inBestimmten Autor mit Biblatex fett markieren. Soweit ich sehen kann, ist in keiner der Lösungen das „et al.“ standardmäßig fettgedruckt, wenn es den entsprechenden Namen „enthält“, aber wir können das hinzufügen.
Als Grundlage verwende ichmeine Antwortdas Hashes verwendet, aber eine praktische Schnittstelle zum Abrufen dieser Hashes bietet. Der schwierige Teil besteht darin, zu prüfen, ob „et al.“ auch einen hervorzuhebenden Namen enthält. Dies tun wir, indem wir eine Schleife über alle verbleibenden Namen in einer ausführen, \indexnames
die ansonsten nichts ausgibt.
\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}
Wenn Sie eine Liste Ihrer Veröffentlichungen für Ihren Lebenslauf formatieren möchten, können Sie einen Blick auf werfen:biblatex-publist
.
bearbeitetum eine elegantere Version zum Formatieren vollständiger Namen zu verwenden. \DeclareNameWrapperFormat
und \mkbibcompletename
sind nur in biblatex
v3.12 (30.10.2018) bzw. v3.13 (17.08.2019) verfügbar. Bitte beachten Sie den Bearbeitungsverlauf, wenn Sie eine ältere Version von verwenden biblatex
.