![特定の著者が 1 人含まれている場合は、参考文献の「et al」を変更します。](https://rvso.com/image/392335/%E7%89%B9%E5%AE%9A%E3%81%AE%E8%91%97%E8%80%85%E3%81%8C%201%20%E4%BA%BA%E5%90%AB%E3%81%BE%E3%82%8C%E3%81%A6%E3%81%84%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AF%E3%80%81%E5%8F%82%E8%80%83%E6%96%87%E7%8C%AE%E3%81%AE%E3%80%8Cet%20al%E3%80%8D%E3%82%92%E5%A4%89%E6%9B%B4%E3%81%97%E3%81%BE%E3%81%99%E3%80%82.png)
@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 つの問題があります。
- コメントアウトされたコマンドをコメントイン(つまり有効にする)して
%\makeauthorbold{Leledakis}
有効にすると、次の結果になります。
(et~al を含む) は次のようになります。
名前はすでに強調表示されていますが、et~al. の部分がまったく欠落しています。
PS: 変更を加えずにコードをテストしましたが、それでも et. al. の部分が欠落しています。
答え1
これは\DeclareNameFormat{author}
元の名前形式を変更したもので、いくつか改善すべき点があります。
- 「von」部分と「Jr.」部分は対応できません。
- 標準への呼び出しが欠落しているため、「et al.」を処理できません
\usebibmacro{name:andothers}
。 - 最新
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}
履歴書の出版物リストのフォーマットを検討している場合は、以下をご覧ください。biblatex-publist
。
編集済み完全な名前をフォーマットするために、よりエレガントなバージョンを使用します。\DeclareNameWrapperFormat
および は、それぞれ v3.12 (2018-10-30) および v3.13 (2019-08-17)\mkbibcompletename
でのみ利用可能ですbiblatex
。 の古いバージョンを使用している場合は、編集履歴を参照してくださいbiblatex
。