![双重书目和粗体作者:1)部分书目,作者加粗 2)完整书目,无粗体作者](https://linux22.com/image/383343/%E5%8F%8C%E9%87%8D%E4%B9%A6%E7%9B%AE%E5%92%8C%E7%B2%97%E4%BD%93%E4%BD%9C%E8%80%85%EF%BC%9A1%EF%BC%89%E9%83%A8%E5%88%86%E4%B9%A6%E7%9B%AE%EF%BC%8C%E4%BD%9C%E8%80%85%E5%8A%A0%E7%B2%97%202%EF%BC%89%E5%AE%8C%E6%95%B4%E4%B9%A6%E7%9B%AE%EF%BC%8C%E6%97%A0%E7%B2%97%E4%BD%93%E4%BD%9C%E8%80%85.png)
在撰写我的博士论文时,我希望 LaTeX 生成如下两个参考书目:
在最初的概述章节中,我想制作一个书目,其中只包含我自己创作的作品,并以粗体显示我的名字。更确切地说,我想打印所有带有给定关键字的作品(来自 .bib 文件),然后打印所有带有第二个给定关键字的作品(来自 .bib 文件)。
我希望在我的论文结尾出现所有的参考文献,包括我自己的,但不会出现任何粗体的名字。
到目前为止,我的主要问题是两个参考书目都以粗体显示我的名字。我使用 bib latex 和 biber 以及 xpatch 将我的名字变为粗体。以下是此问题的快照,我用<insertheremyhash>
biber 与我的名字关联的哈希值替换了它。
多谢!
\usepackage[backend=biber,natbib=true,style=alphabetic,sorting=nyt,giveninits=true, defernumbers=false,citetracker=true,maxnames=99,doi=false,isbn=false,url=false, noerroretextools=true]{biblatex}
\addbibresource{biblio_thesis_2.bib}
\usepackage{xpatch}
\newbibmacro*{name:bold}[2]{%
\def\do##1{\iffieldequalstr{hash}{##1}{\bfseries\listbreak}{}}%
\dolistloop{\boldnames}%
}
\newcommand*{\boldnames}{}
\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\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}{{<insertheremyhash>}}
编辑:添加 MWE
\documentclass[12pt, a4paper, titlepage, headsepline, twoside]{book}
\usepackage{filecontents}
%
\begin{filecontents}{biblatextest1.bib}
@BOOK{BookMe1,
author = {Me Me},
title = {Paper for first part},
publisher = {Some Publisher},
year = 2003,
Keywords = {minepart1}
}
@BOOK{BookMe2,
author = {Me Me},
title = {Paper for second part},
publisher = {Some Publisher},
year = 2002,
Keywords = {minepart2}
}
@BOOK{Bookothers1,
author = {Someone else},
title = {Someone else work},
publisher = {Some Publisher},
year = 2002,
}
\end{filecontents}
% == Bibliography ================================================
\usepackage[backend=biber,natbib=true,style=alphabetic,sorting=nyt,giveninits=true, defernumbers=false,citetracker=true,maxnames=99,doi=false,isbn=false,url=false, noerroretextools=true]{biblatex}
\addbibresource{biblatextest1.bib}
% GETTING Me Me to appear in bold
\usepackage{xpatch}
\newbibmacro*{name:bold}[2]{%
\def\do##1{\iffieldequalstr{hash}{##1}{\bfseries\listbreak}{}}%
\dolistloop{\boldnames}%
}
\newcommand*{\boldnames}{}
\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{}
\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}
{{0e4113c11a30770aa5d2e0f481425c95}}
\begin{document}
% OVERVIEW CHAPTER
\section*{Overview}
\nocite{BookMe1,BookMe2,Bookothers1}
Part I of this thesis is based on the following works.
% print partial biblio relative to part 1 + bold
\begin{refcontext}[sorting=ydnt]
\defbibfilter{filt_minepart1}{ keyword=minepart1 }
\printbibliography[filter=filt_minepart1,heading=none,title=none]
\end{refcontext}
Part II of this thesis is based on the following works.
% print partial biblio relative to part 2 + bold
\begin{refcontext}[sorting=ydnt]
\defbibfilter{filt_minepart2}{ keyword=minepart2 }
\printbibliography[filter=filt_minepart2,heading=none,title=none]
\end{refcontext}
% print full biblio, no bold!
%backmatter
%\addcontentsline{toc}{part}{Bibliography}
\printbibliography
\end{document}
答案1
所有涉及的命令都可以在本地使用,因为它们不需要全局分配。这意味着我们可以将负责加粗作者姓名的命令打包成一个宏(\makenamesbold
下面调用),然后每当我们想让特定书目以加粗形式显示您的姓名时,都可以使用该宏。
在 MWE 中,只需在 中发出命令就足够了,refcontext
因为这提供了必要的分组,但您也可以使用\AtNextBibliography
。
\documentclass[12pt, a4paper, titlepage, twoside]{book}
\usepackage[backend=biber, natbib=true, style=alphabetic,
sorting=nyt, giveninits=true, defernumbers=false,
citetracker=true, maxnames=99, doi=false, isbn=false, url=false]{biblatex}
\usepackage{xpatch}
\newcommand*{\boldnamedo}[1]{%
\iffieldequalstr{hash}{#1}
{\bfseries\listbreak}
{}}
\newbibmacro*{name:bold}{%
\forlistloop{\boldnamedo}{\boldnames}}
\newcommand*{\boldnames}{}
\forcsvlist{\listadd\boldnames}
{{0e4113c11a30770aa5d2e0f481425c95}}
\newcommand*{\makenamesbold}{%
\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}{}{}%
}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{BookMe1,
author = {Me Me},
title = {Paper for first part},
publisher = {Some Publisher},
year = 2003,
Keywords = {minepart1}
}
@BOOK{BookMe2,
author = {Me Me},
title = {Paper for second part},
publisher = {Some Publisher},
year = 2002,
Keywords = {minepart2}
}
@BOOK{Bookothers1,
author = {Someone else},
title = {Someone else work},
publisher = {Some Publisher},
year = 2002,
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\section*{Overview}
\nocite{BookMe1,BookMe2,Bookothers1}
Part I of this thesis is based on the following works.
% print partial biblio relative to part 1 + bold
\begin{refcontext}[sorting=ydnt]
\makenamesbold
\defbibfilter{filt_minepart1}{ keyword=minepart1 }
\printbibliography[filter=filt_minepart1,heading=none,title=none]
\end{refcontext}
Part II of this thesis is based on the following works.
% print partial biblio relative to part 2 + bold
\begin{refcontext}[sorting=ydnt]
\makenamesbold
\defbibfilter{filt_minepart2}{ keyword=minepart2 }
\printbibliography[filter=filt_minepart2,heading=none,title=none]
\end{refcontext}
\printbibliography
\end{document}