我想将特定的作者设为粗体,无论其放在哪里(即,第一位、第二位都无所谓),但只在文本区域引用时除外(即,在参考部分不应设为粗体)。
对于文本/正常部分的完整引用,我使用了描述的方法这里。为了将其改为粗体,我发现这个答案可能有用,但不知道如何将其合并到\printpublication
命令中。
梅威瑟:
\documentclass{article}
\usepackage[backend=biber,natbib=true,style=ieee,
citestyle=numeric-comp,sorting=none,doi=false,isbn=false,url=true,]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\cite.bib}
@misc{A01,
author = {Author, Arik and Author, Jaz and Author, Ricky},
year = {2100},
title = {An unnecessary long title},
}
@book{A02,
author = {Author, Jaz and Author, Arik and Author, Ricky},
year = {2100},
title = {An unnecessary long title},
}
\end{filecontents}
\addbibresource{\cite.bib}
\newcommand{\printpublication}[1]{\AtNextCite{\defcounter{maxnames}{3}\defcounter{minnames}{1}}\fullcite{#1}}
\begin{document}
\printpublication{A01}
\printpublication{A02}
\printbibliography
\end{document}
答案1
构建于我的答案到使用 biblatex 将特定作者设为粗体,其具有稍微更方便的粗体名称用户界面,我们可以定义新的命令\printpublication
。
链接的答案解释了加粗名称代码的具体工作原理:要点是我们将名称写入外部.bib
,然后可以自动从.bbl
文件中提取哈希值。有了哈希值,我们就可以继续突出显示名称,感兴趣的哈希值存储在列表中。
该命令\mkboldifhashinlist
会准确突出显示哈希值位于感兴趣列表中的那些名称。\DeclareNameWrapperFormat{given-family:hash:bold}
如果需要,可以使用此宏中的定义来应用完整名称。
\printpublication
是 的副本,其中\fullcite
带有\defcounter
s 以及直接放入 预编码中的新粗体名称格式\usedriver
。
\documentclass{article}
\usepackage[backend=biber, natbib=true, style=ieee, sorting=none,
doi=false, isbn=false, url=true]{biblatex}
\makeatletter
% auxiliary bibfile
\def\hlblx@bibfile@name{\jobname -boldnames.bib}
\newwrite\hlblx@bibfile
\immediate\openout\hlblx@bibfile=\hlblx@bibfile@name
\newcounter{hlblx@name}
\setcounter{hlblx@name}{0}
\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}
\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}}
{}
{}
% user-level macros
\newcommand*{\addboldnames}{\forcsvlist\hlblx@writenametobib}
\newcommand*{\resetboldnames}{\def\hlbxl@boldhashes{}}
\newcommand*{\mkboldifhashinlist}[1]{%
\xifinlist{\thefield{hash}}{\hlbxl@boldhashes}
{\mkbibbold{#1}}
{#1}}
\makeatother
\DeclareNameWrapperFormat{given-family:hash:bold}{%
\renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}%
#1}
\DeclareCiteCommand{\printpublication}
{\usebibmacro{prenote}}
{\usedriver
{\DeclareNameAlias{sortname}{default}%
\DeclareNameWrapperAlias{default}{given-family:hash:bold}%
\defcounter{maxnames}{3}%
\defcounter{minnames}{1}}
{\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}}
\addboldnames{{Author, Arik}}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, Arik and Author, Jaz and Author, Ricky},
year = {2100},
title = {An unnecessary long title},
}
@book{A02,
author = {Author, Jaz and Author, Arik and Author, Ricky},
year = {2100},
title = {An unnecessary long title},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\printpublication{A01}
\printpublication{A02}
\printbibliography
\end{document}
編輯使用更优雅的版本来格式化完整名称。\DeclareNameWrapperFormat
和\mkbibcompletename
仅分别在 v3.12 (2018-10-30) 和 v3.13 (2019-08-17) 中可用biblatex
。如果您使用的是旧版本的,请参阅编辑历史biblatex
。