特定の著者が 1 人含まれている場合は、参考文献の「et al」を変更します。

特定の著者が 1 人含まれている場合は、参考文献の「et al」を変更します。

@LawrenceCrosby の回答を使用して、参考文献で太字にしようとしている著者が追加の (et~al) 著者の中にいる場合に、参考文献に表示される et~al. を変更しようとしています。ここ

私のコードは次のとおりです:

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

これには 2 つの問題があります。

  1. コメントアウトされたコマンドをコメントイン(つまり有効にする)して%\makeauthorbold{Leledakis}有効にすると、次の結果になります。

ここに画像の説明を入力してください

(et~al を含む) は次のようになります。

ここに画像の説明を入力してください

名前はすでに強調表示されていますが、et~al. の部分がまったく欠落しています。

PS: 変更を加えずにコードをテストしましたが、それでも et. al. の部分が欠落しています。

答え1

これは\DeclareNameFormat{author}元の名前形式を変更したもので、いくつか改善すべき点があります。

  1. 「von」部分と「Jr.」部分は対応できません。
  2. 標準への呼び出しが欠落しているため、「et al.」を処理できません\usebibmacro{name:andothers}
  3. 最新biblatexバージョンでは、構文エラーによるエラーも発生します。(最後\ifthenelse間違いブランチ。参照https://github.com/plk/biblatex/issues/874

名前を太字にするには、より強力なバージョンを使用することをお勧めします。biblatex を使用して特定の著者を太字にする私が見る限り、関連する名前が「含まれている」場合、どのソリューションでも「et al.」を太字にしていませんが、それを追加することはできます。

私が使用している基礎として私の答えハッシュを使用しますが、ハッシュを取得するための便利なインターフェイスが用意されています。難しいのは、「et al.」にも強調表示する名前が含まれているかどうかを確認することです。これは、それ\indexnames以外の場合は何も出力しない 内の残りのすべての名前をループすることで行います。

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

著者、A. および **K. Leledakis** (2017)。「本」。出版社に掲載。//著者、A.、A. 不明著者、その他 (2015)。本。出版社。//**Leledakis、K.** (2019)。「記事」。あるジャーナルに掲載。//ある著者、A.、O. 別の著者、**その他 (K. Leledakis を含む)** (1988)。本。誰か。

履歴書の出版物リストのフォーマットを検討している場合は、以下をご覧ください。biblatex-publist

編集済み完全な名前をフォーマットするために、よりエレガントなバージョンを使用します。\DeclareNameWrapperFormatおよび は、それぞれ v3.12 (2018-10-30) および v3.13 (2019-08-17)\mkbibcompletenameでのみ利用可能ですbiblatex。 の古いバージョンを使用している場合は、編集履歴を参照してくださいbiblatex

関連情報