如何始终在引用中包含特定作者姓名?

如何始终在引用中包含特定作者姓名?

我感兴趣的是,是否有一种方法可以在引用中包含(总是)作者姓名(我的名字),即使姓名不是文章中的第一个或第二个。

% arara: lualatex: { shell: yes }
% arara: biber
% arara: lualatex: { shell: yes }
% arara: lualatex: { synctex: true, shell: yes }
\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
    @article{leydet-2013,
        author = {Leydet, Y. and Batat, P. and Jonusauskas, G. and Denisov, S. A. and Lima, J. C. and Parola, A. J. and McClenaghan, N.D. and Pina, F.},
        title = {Impact of Water on the Cis-Trans Photoisomerization of Hydroxychalcones},
        journal = {J. Phys. Chem. A},
        volume = {117},
        number = {20},
        pages = {4167-4173},
        year = {2013}
    }
\end{filecontents}

\usepackage[backend=biber,mincitenames=2]{biblatex}

\addbibresource{\jobname.bib}

\DeclareFieldFormat{pages}{\mkfirstpage{#1}}

\DeclareNameFormat{}{\usebibmacro{name:first-last}{}{#5}{#1}{#7}\usebibmacro{na‌​me:andothers}}

\DeclareCiteCommand{\longcite}{}{%
    \footnotesize   \printnames[author]{author},  \printfield{journaltitle}, \textbf{\printfield{year}}, \textit{\printfield{volume}}, \printfield{pages}}{; }{}%

\begin{document}
A \longcite{leydet-2013}
\end{document}

目前,我的Beamer演讲已获得此引用结果。

在此处输入图片描述

但我想要这样的东西:

在此处输入图片描述

但如果感兴趣的名称是第一次或第二次引用应该是这样的:

在此处输入图片描述

答案1

第一步是确定特定名称出现的 bibtex 记录。鉴于名称列表被截断为 2,我们无法使用格式名称指令中的隐式循环来发现它是否出现在第二个名称之后(处理在此之前终止)。因此,对于此任务,我们可以定义一个源映射,即:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=author, match=\regexp{Denisov},
        fieldset=keywords, fieldvalue={denisov}]
    }
  }
}

在这里,我们为此类条目创建一个特殊的关键字。

第二步是创建一个布尔开关,如果该名字出现在前两个作者的名字中,则为 true,否则为 false。

\newbool{denisov}

其值由以下命令设置author \DeclareNameFormat

\DeclareNameFormat{author}{%
  \ifcitation{\ifstrequal{#1}{Denisov}{\global\booltrue{denisov}}{}}{}%
  \usebibmacro{name:first-last}{#1}{#4}{#5}{#7}
  \ifthenelse{\value{listcount}=\value{liststop}}
    {\ifmorenames{\addcomma\addspace\bibstring{andothers}\adddot}}
    {}%
}

在这里,我们检查上下文是否为引文;如果第一个参数(即#1)对应于给定的名称,则我们将布尔值设置为 true。鉴于解析在给定的值处停止,maxcitenames此检查仅针对前 n 个名称(其中 n 小于或等于maxcitenames)执行。

最后一步是在处理引用时使用新的布尔值和关键字。

\DeclareCiteCommand{\longcite}{}{%
    \footnotesize   
    \printnames[author]{author}  
    \ifkeyword{denisov}{%
      \ifbool{denisov}
        {}
        {\addcomma\addspace
         \mkbibparens{\usebibmacro{name:first-last}{Denisov}{S. A.}{}{}}}
         \adddotspace}%
      {\addcomma\addspace}% 
    \printfield{journaltitle}, 
    \textbf{\printfield{year}}, 
    \textit{\printfield{volume}}, 
    \printfield{pages}}
  {; }
  {}

我们要做的就是添加一条新指令,检查是否存在包含该名称的特殊关键字的条目,然后使用布尔值确定该名称是否已被打印,然后采取相应的行动。

完整的 MWE 是

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
    @article{leydet-2013,
        author = {Leydet, Y. and Batat, P. and Jonusauskas, G. and Denisov, S. A. and Lima, J. C. and Parola, A. J. and McClenaghan, N.D. and Pina, F.},
        title = {Impact of Water on the Cis-Trans Photoisomerization of Hydroxychalcones},
        journal = {J. Phys. Chem. A},
        volume = {117},
        number = {20},
        pages = {4167-4173},
        year = {2013}
    }

    @article{leydet-2014,
        author = {Leydet, Y.  and Denisov, S. A. and Lima, J. C. and Parola, A. J. and McClenaghan, N.D. and Pina, F.},
        title = {Impact of Water on the Cis-Trans Photoisomerization of Hydroxychalcones},
        journal = {J. Phys. Chem. A},
        volume = {117},
        number = {20},
        pages = {4167-4173},
        year = {2014}
    }

    @article{leydet-2015,
        author = {Leydet, Y. and Batat, P. and Jonusauskas, G. and Lima, J. C. and Parola, A. J. and McClenaghan, N.D. and Pina, F.},
        title = {Impact of Water on the Cis-Trans Photoisomerization of Hydroxychalcones},
        journal = {J. Phys. Chem. A},
        volume = {117},
        number = {20},
        pages = {4167-4173},
        year = {2013}
    }

    @article{leydet-2016,
        author = {Leydet, Y. and Batat, P. },
        title = {Impact of Water on the Cis-Trans Photoisomerization of Hydroxychalcones},
        journal = {J. Phys. Chem. A},
        volume = {117},
        number = {20},
        pages = {4167-4173},
        year = {2013}
    }

\end{filecontents}


\usepackage[backend=biber,mincitenames=2]{biblatex}


\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=author, match=\regexp{Denisov},
        fieldset=keywords, fieldvalue={denisov}]
    }
  }
}

\addbibresource{\jobname.bib}

\DeclareFieldFormat{pages}{\mkfirstpage{#1}}

\newbool{denisov}

\DeclareNameFormat{author}{%
  \ifcitation{\ifstrequal{#1}{Denisov}{\global\booltrue{denisov}}{}}{}%
  \usebibmacro{name:first-last}{#1}{#4}{#5}{#7}
  \ifthenelse{\value{listcount}=\value{liststop}}
    {\ifmorenames{\addcomma\addspace\bibstring{andothers}\adddot}}
    {}%
}

\DeclareCiteCommand{\longcite}{}{%
    \footnotesize   
    \printnames[author]{author}  
    \ifkeyword{denisov}{%
      \ifbool{denisov}
        {}
        {\addcomma\addspace
         \mkbibparens{\usebibmacro{name:first-last}{Denisov}{S. A.}{}{}}}
         \adddotspace}%
      {\addcomma\addspace}% 
    \printfield{journaltitle}, 
    \textbf{\printfield{year}}, 
    \textit{\printfield{volume}}, 
    \printfield{pages}}
  {; }
  {}%

\begin{document}
\longcite{leydet-2013}

\longcite{leydet-2014}

\longcite{leydet-2015}

\longcite{leydet-2016}

\printbibliography
\end{document}

输出为

在此处输入图片描述

相关内容