对于某些(愚蠢的)报告,我必须将一些作者用粗体标出,将一些作者用下划线标出参考书目。
感谢这里的一些帖子/回答,我成功地将一个特定的加粗了。但是,这里测试的所有其他使其他下划线的技巧都失败了(要么编译失败,要么没有生成任何内容)。
这是粗体的 MWE。假设我想为 Billy Bob 和 Jane Doe 加下划线。
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage{ulem}
\usepackage[style=alphabetic, maxnames=99, sorting=ydnt, backend=bibtex]{biblatex}
\begin{filecontents}{\jobname.bib}
@article{article1,
author={Smith, John and Doe, Jane and Foo, Bar},
title={Title},
journal={Journal}
}
@article{article2,
author={Smith, John and Billy, Bob},
title={Title2},
journal={Journal2}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DeclareBibliographyDriver{article}{%
\printfield{title} %
\par
\newblock%
\printnames{author}%
\par%
\newblock%
{%
\footnotesize\itshape%
\usebibmacro{journal}%
}
\par\vspace{0.3\baselineskip}
}
\newcommand*{\boldname}[3]{%
\def\lastname{#1}%
\def\firstname{#2}%
\def\firstinit{#3}}
\renewcommand{\mkbibnamegiven}[1]{%
\ifboolexpr{ ( test {\ifdefequal{\firstname}{\namepartgiven}} or test {\ifdefequal{\firstinit}{\namepartgiven}} ) and test {\ifdefequal{\lastname}{\namepartfamily}} }
{\mkbibbold{#1}}{#1}%
}
\renewcommand{\mkbibnamefamily}[1]{%
\ifboolexpr{ ( test {\ifdefequal{\firstname}{\namepartgiven}} or test {\ifdefequal{\firstinit}{\namepartgiven}} ) and test {\ifdefequal{\lastname}{\namepartfamily}} }
{\mkbibbold{#1}}{#1}%
}
\boldname{Smith}{John}{}
\begin{document}
\nocite{*}
\printbibliography[type={article}]
\end{document}
答案1
您可以使用以下方法用粗体标出某些作者,用匕首标出其他作者,参数化我的答案到使用 biblatex 将特定作者设为粗体。
这种方法需要 Biber 而不是 BibTeX。请注意,可拆分下划线非常在 LaTeX 中很棘手。我知道的最好的下划线解决方案是马塞尔·克鲁格的lua-ul
包裹(参见例如在保留字距调整的同时为单词的一部分添加下划线),这需要 LuaLaTeX。
\documentclass{article}
\usepackage{lua-ul}
\usepackage[style=alphabetic, maxnames=99, sorting=ydnt, backend=biber]{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}[2]{%
\ifcsundef{nhblx@#1list}
{\csdef{nhblx@#1list}{}}
{}%
\stepcounter{nhblx@name}%
\edef\nhblx@tmp@nocite{%
\noexpand\AfterPreamble{%
\noexpand\setbox0\noexpand\vbox{%
\noexpand\def\noexpand\nhblx@listname{nhblx@#1list}%
\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{#2}}, %
options = {dataonly=true},}%
}%
}
\AtEndDocument{%
\closeout\nhblx@bibfile}
\addbibresource{\nhblx@bibfile@name}
\DeclareNameFormat{nhblx@hashextract}{%
\xifinlistcs{\thefield{hash}}{\nhblx@listname}
{}
{\listcsxadd{\nhblx@listname}{\thefield{hash}}}}
\DeclareCiteCommand{\nhblx@getmethehash}
{}
{\typeout{\nhblx@listname}\printnames[nhblx@hashextract][1-999]{author}}
{}
{}
\newcommand*{\markname}[1]{\forcsvlist{\nhblx@writenametobib{#1}}}
\newcommand*{\resetmark}[1]{\csdef{nhblx@#1list}{}}
\newcommand*{\ifnamemarked}[1]{%
\xifinlistcs{\thefield{hash}}{nhblx@#1list}}
\makeatother
\newcommand*{\nameformatter}[1]{%
\ifnamemarked{bold}
{\mkbibbold{#1}}
{\ifnamemarked{underline}
{\underLine{#1}}
{#1}}}
\DeclareNameWrapperFormat{nameformatter}{%
\renewcommand*{\mkbibcompletename}{\nameformatter}%
#1}
\DeclareNameWrapperAlias{sortname}{default}
\DeclareNameWrapperAlias{default}{nameformatter}
\markname{bold}{John Smith}
\markname{underline}{Jane Doe}
\begin{filecontents}{\jobname.bib}
@article{article1,
author = {Smith, John and Doe, Jane and Foo, Bar},
title = {Title},
journal = {Journal},
}
@article{article2,
author = {Smith, John and Billy, Bob},
title = {Title2},
journal = {Journal2},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}