我想打印自己的出版物,并通过突出显示自己的名字来表明我是作者。由于有些出版物有 100 多名作者,我不想打印所有作者(有些出版物有 5-10 位作者,但整页名字看起来很难看)。总的来说,我找到了一个解决方案,但目前有一个空格,如果我跳过一些名字,我希望去掉它(目前是:“第一作者,...,我,等。”;应该是:“第一作者,...,我,等。”)。
还有一些可以改进的地方,但对我来说并不重要(1. 我的名字是否也在常规参考书目中突出显示,而不仅仅是在我的 fullciteNEW 命令中;2. 目前几个字段如卷、doi 等以静态方式包含在内;3. 如果作者数量低于 10 人,那么全部显示出来就可以了。)
这是表示状态的当前代码:
%----------------------------------------------------------------------------------------
% An example bib file
%----------------------------------------------------------------------------------------
\begin{filecontents}{test.bib}
@article{Source1,
author = {Me, Its and Author, another and Else, Someone},
journal = {The journal},
title = {{A fancy title}},
issn = {12345},
year = {2019},
pages = {1-2},
volume = {49},
number = {2},
doi = {TheDoiIsHelpful},
}
@article{Source2,
author = {Author, First and Me, I. and Author, Third and Author, Fourth},
title = {{This is my sedondauthorship}},
journal = {The real journal},
issn = {12345},
year = {2022},
pages = {1-2},
volume = {49},
number = {2},
doi = {TheDoiIsHelpful}
}
@article{Source3,
author = {Author, First and Author, Second and Me, I. and Author, Third and Author, Fourth},
title = {{This is another paper}},
journal = {The real journal},
issn = {12345},
year = {2022},
pages = {1-2},
volume = {49},
number = {2},
doi = {TheDoiIsHelpful}
}
@article{Source5,
author = {Author, First and Author, Second and Author, Third and Author, Fourth and Me, I.},
title = {{This is my last authorship}},
journal = {The real journal},
issn = {12345},
year = {2022},
pages = {1-2},
volume = {49},
doi = {TheDoiIsHelpful},
}
\end{filecontents}
% END bib file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{scrreprt}
\usepackage{csquotes}
\PassOptionsToPackage{%
language=auto,%
style=numeric-comp,%
sorting=nyt, % name, year, title
maxbibnames=10, % default: 3, et al.
minbibnames=5,%\minnames, %names before et. al
natbib=true % natbib compatibility mode (\citep and \citet still work)
}{biblatex}
\usepackage{biblatex}
%----------------------------------------------------------------------------------------
% HIGHLIGHTED SELF CITATIONS
%----------------------------------------------------------------------------------------
%\usepackage{biblatex}
\usepackage{xpatch}% or use http://tex.stackexchange.com/a/40705
\makeatletter
\newbibmacro*{name:bold}[2]{%
\edef\blx@tmp@name{\expandonce#1, \expandonce#2}%
\def\do##1{\ifdefstring{\blx@tmp@name}{##1}{\large\scshape\listbreak}}%bfseries
\dolistloop{\boldnames}}
\newcommand*{\boldnames}{}
\makeatother
\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\normalsize}{}{}
\xapptobibmacro{name:family}{\endgroup}{}{}
\xapptobibmacro{name:given-family}{\endgroup}{}{}
\xapptobibmacro{name:family-given}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}
\makeatletter
\DeclareNameFormat{given-family:noetal}{
\ifgiveninits
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}
,
}
\usepackage{ifthen}
\DeclareCiteCommand*{\fullciteNEW}
{\defcounter{maxnames}{10}%
}
{
{}
{}
\ifthenelse{\equal{\thefield{postnote}}{1}}{\printnames[given-family][1-1]{author}}{
\ifthenelse{\equal{\thefield{postnote}}{2}}{\printnames[given-family][1-2]{author}}{
\printnames[given-family:noetal][1-1]{author}
..., \printnames[given-family][\thefield{postnote}-\thefield{postnote}]{author}
}
}
\printfield{title}\printtext{ In:}
\printfield{journaltitle}
\printfield{volume}.\printfield{number}
(\printfield{year}),
\printfield{pages}.
\printfield{issn}.
\printfield{doi}}
{\multicitedelim}
{}
\addbibresource{test.bib} % The file housing your bibliography
\forcsvlist{\listadd\boldnames}
{{Me, Its}, {Me, I.}}
\begin{document}
\noindent\fullciteNEW*[1]{Source1}\\
\noindent\fullciteNEW*[2]{Source2}\\
\noindent\fullciteNEW*[3]{Source3}\\
\noindent\fullciteNEW*[5]{Source5}\\
\end{document}
(抱歉,这个最小示例不是最佳的,这是我的第一次尝试)