对作者姓名进行排序并以粗体突出显示

对作者姓名进行排序并以粗体突出显示

我曾经使用下面的代码片段(实际上是我在这里找到的)在我的简历或论文参考书目中用粗体突出显示我的名字。它工作得很好,但在过去 3 周左右的时间里,我遇到了一堆错误,而代码和我的 .bib 文件都没有修改。我知道一些选项已经简化,这会影响代码。有机会获得此功能的更新代码吗?

\documentclass[a4paper,twoside,numbered,fontsize=11pt]{scrartcl} % KOMA-article class
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{amsmath,amsfonts,amsthm}     % Math packages
\usepackage{graphicx}                    % Enable pdflatex
\usepackage[svgnames]{xcolor}            % Colors by their 'svgnames'
\usepackage{geometry}
%\textheight=700px                    % Saving trees ;-)
\usepackage{url}
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
\usepackage{float}
\usepackage{etaremune}
\usepackage{wrapfig}
\usepackage{eurosym}
\usepackage{textcomp}
\usepackage{csquotes}
\usepackage{attachfile}
\usepackage{fancyhdr}
%sorting section
\usepackage[backend=biber,sorting=ddatent,style=phys,isbn=true]{biblatex}

%sorting by date 
\DeclareSortingScheme{ddatent}{
    \sort{
        \field{presort}
    }
    \sort[final]{
        \field{sortkey}
    }
    \sort[direction=descending]{
        \field[strside=left,strwidth=4]{sortyear}
        \field[strside=left,strwidth=4]{year}
        \literal{9999}
    }
    \sort[direction=descending]{
        \field[padside=left,padwidth=2,padchar=0]{month}
        \literal{00}
    }
    \sort[direction=descending]{
        \field[padside=left,padwidth=2,padchar=0]{day}
        \literal{00}
    }
    \sort[direction=descending]{
        \field[padside=left,padwidth=4,padchar=0]{volume}
        \literal{9999}
    }
    \sort{
        \name{sortname}
        \name{author}
        \name{editor}
        \name{translator}
        \field{sorttitle}
        \field{title}
    }
    \sort{
        \field{sorttitle}
        \field{title}
    }
}

\addbibresource{mybiblio2016.bib}


\setlength{\biblabelsep}{0pt}

%Make Bold author name
\newcommand{\makeauthorbold}[1]{%
    \DeclareNameFormat{author}{%
        \ifnumequal{\value{listcount}}{1}
        {\ifnumequal{\value{liststop}}{1}
            {\expandafter\ifstrequal{##1}{#1}{\textbf{##1\addcomma\addspace ##4\addcomma\isdot}}{##1\addcomma\addspace ##4\addcomma\isdot}}
            {\expandafter\ifstrequal{##1}{#1}{\textbf{##1\addcomma\addspace ##4}}{##1\addcomma\addspace ##4}}}
        {\ifnumless{\value{listcount}}{\value{liststop}}
            {\expandafter\ifstrequal{##1}{#1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4}}{\addcomma\addspace ##1\addcomma\addspace ##4}}
            {\expandafter\ifstrequal{##1}{#1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}%
        }%
    }%
}
\makeauthorbold{Myname}


\DeclareFieldFormat{labelnumberwidth}{}


%%% Papers
\newpage
\nocite{*}
\printbibliography[type=article,title={\uppercase{Journal articles}}]
\printbibliography[type=inproceedings,title={\uppercase{Conference papers}}]
\printbibliography[type=book,title={\uppercase{Books chapters}}]
\printbibliography[type=patent,title={\uppercase{Patents}}]
\printbibliography[type=unpublished,title={\uppercase{Presentations}}]
\printbibliography[type=inreference,title={\uppercase{Invited talks}}]
\printbibliography[type=incollection,title={\uppercase{Posters}}]
\printbibliography[type=report,title={\uppercase{Technical notes}}]
\printbibliography[type=thesis,title={\uppercase{Thesis}}]

\end{document}

答案1

我建议你使用使用 biblatex 突出显示参考书目中的作者,并允许使用参考书目样式对其进行格式化这又基于奥黛丽的解决方案使用 biblatex 将特定作者设为粗体,但使用哈希值而不是字符串比较。

由于在biblatex3.3 中一些内部宏被重命名(参见Biblatex 3.3 名称格式) 现在需要重新定义name:familyname:given-familyname:family-given

您可以添加应突出显示的名称的哈希值,如下所示。查看文件即可找到这些哈希值.bbl。更多详细信息在另一个答案中

\forcsvlist{\listadd\boldnames}
  {{5e1df516fe8816ee66169b8616522816}}

MWE(软件包数量略少)

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{csquotes}
\usepackage[backend=biber,sorting=ddatent,style=phys,isbn=true]{biblatex}

\usepackage{xpatch}

\newcommand*{\boldnames}{}

\newcommand*{\doboldnames}[1]{%
  \iffieldequalstr{hash}{#1}
    {\bfseries\listbreak}
    {}}%

\newbibmacro*{name:bold}{%
  \forlistloop{\doboldnames}{\boldnames}}

\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:family}{\endgroup}{}{}
\xapptobibmacro{name:given-family}{\endgroup}{}{}
\xapptobibmacro{name:family-given}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}

\renewcommand*{\boldnames}{}
\forcsvlist{\listadd\boldnames}
  {{5e1df516fe8816ee66169b8616522816}}

%sorting by date 
\DeclareSortingScheme{ddatent}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort[direction=descending]{
    \field[strside=left,strwidth=4]{sortyear}
    \field[strside=left,strwidth=4]{year}
    \literal{9999}
  }
  \sort[direction=descending]{
    \field[padside=left,padwidth=2,padchar=0]{month}
    \literal{00}
  }
  \sort[direction=descending]{
    \field[padside=left,padwidth=2,padchar=0]{day}
        \literal{00}
  }
  \sort[direction=descending]{
    \field[padside=left,padwidth=4,padchar=0]{volume}
    \literal{9999}
  }
  \sort{
    \name{sortname}
    \name{author}
    \name{editor}
    \name{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@incollection{Silva:2014a,
  title={Radio Resource Management for Device-to-Device Communications in Long Term Evolution Networks},
  author={Carlos F. M. Silva and Silva, Jr., Jos\'{e} Mairton B. and Tarcisio F. Maciel},
  booktitle={Resource Allocation and {MIMO} for {4G} and Beyond},
  publisher={Springer Science+Business Media},
  year=2014,
  address={New York, USA},
  editor={Francisco Rodrigo Porto Cavalcanti},
  pages={105-156},
  doi={10.1007/978-1-4614-8057-0_3},
  isbn={978-1-4614-8056-3},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\setlength{\biblabelsep}{0pt}

\begin{document}
\fullcite{Silva:2014a}

\printbibliography
\end{document}

相关内容