Skip to content

Instantly share code, notes, and snippets.

@moewew
Created June 1, 2021 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moewew/291c65df0d6db091bd1c29322765f2f0 to your computer and use it in GitHub Desktop.
Save moewew/291c65df0d6db091bd1c29322765f2f0 to your computer and use it in GitHub Desktop.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,style=numeric]{biblatex}
\makeatletter
\def\nhblx@bibfile@name{\jobname -nhblx.bib}
\newwrite\nhblx@bibfile
\immediate\openout\nhblx@bibfile=\nhblx@bibfile@name
\immediate\write\nhblx@bibfile{%
@comment{Auto-generated file}\blx@nl}
\newcounter{nhblx@name}
\setcounter{nhblx@name}{0}
\newcommand*{\nhblx@writenametobib}[1]{%
\stepcounter{nhblx@name}%
\edef\nhblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\noexpand\nhblx@getmethehash{nhblx@name@\the\value{nhblx@name}}}}%
}%
\nhblx@tmp@nocite
\immediate\write\nhblx@bibfile{%
@misc{nhblx@name@\the\value{nhblx@name}, author = {\unexpanded{#1}}, %
options = {dataonly=true},}%
}%
}
\AtEndDocument{%
\closeout\nhblx@bibfile}
\addbibresource{\nhblx@bibfile@name}
\newcommand*{\nhblx@boldhashes}{}
\DeclareNameFormat{nhblx@hashextract}{%
\xifinlist{\thefield{hash}}{\nhblx@boldhashes}
{}
{\listxadd{\nhblx@boldhashes}{\thefield{hash}}}}
\DeclareCiteCommand{\nhblx@getmethehash}
{}
{\printnames[nhblx@hashextract][1-999]{author}}
{}
{}
\newcommand*{\addboldnames}{\forcsvlist\nhblx@writenametobib}
\newcommand*{\resetboldnames}{\def\nhblx@boldhashes{}}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\nhblx@boldhashes}
{\mkbibbold{#1}}
{#1}}
\makeatother
\DeclareNameWrapperFormat{boldifhashinlist}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{boldifhashinlist}
\addboldnames{{My Family Name, MyForname},{My Family Name, M.}}
\begin{filecontents}{\jobname.bib}
@inproceedings{identifier1,
title = {Some Awesome Title},
author = {My Family Name, MyForname and Author, Another},
booktitle = {Some Book about the Future},
year = {2042},
pages = {1--43},
}
@inproceedings{identifier2,
title = {Some So-So Title},
author = {Author, Another and My Family Name, M.},
booktitle = {An okay Booktitle},
year = {2000},
pages = {1--100},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\fullcite{identifier1}
\fullcite{identifier2}
\fullcite{knuth:ct:a}
\fullcite{vizedom:related}
\resetboldnames\addboldnames{Donald E. Knuth}
\fullcite{knuth:ct:a}
\resetboldnames\addboldnames{Philipp Jaff{\'e}}
\fullcite{jaffe}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment