5

I'm interested if there is a way to include (always) author name (my name) in citation even if name is not first or second in article.

% 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}

Right now I have this citation result for my Beamer presentation.

enter image description here

But I'd like to have something like this:

enter image description here

But If name of interest is first or second citation should like this:

enter image description here

4

The first step is to identify the bibtex records where the specific name occurs. Given that the list of name is truncated to 2 we cannot use the implicit loop in the format name directive to discover if it occurs after the second name (the processing is terminated before). Accordingly, for this task we can define a source map, namely:

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

Here we create a special keyword for such entries.

The second step is to create a boolean switch, which is true if the name occurs within the first two author's names and false otherwise.

\newbool{denisov}

and its value is set by the author \DeclareNameFormat command:

\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}}
    {}%
}

Here, we check whether the context is a citation; if the first parameter (i.e., #1) corresponds to the given name, then we set the boolean true. Given that the parsing stops at the value given by maxcitenames this check is performed only for the first n names (where n is less or equal to maxcitenames).

The final step is to use the new boolean and the keyword when a citation is processed.

\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}}
  {; }
  {}

All we have to do is to add a new instructions checking whether we have an entry where the special keyword for the name exists, and then use the boolean to determine if the name has already been printed, and then acting accordingly.

The full MWE is

\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}

and the output is

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.