I am trying to find out whether two references have the same author with natbib
. But I seem to be unable to get basic string comparisons working. Without a deeper understanding, I have tried everything I could find (xstring
, \detokenize
, \expandafter\relax
, ...). Nothing really works. I would be so glad if someone could fix my Test
function.
\documentclass{article}
\usepackage{natbib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{ArticleX, author = "AuthorA", year = "2000"}
@article{ArticleY, author = "AuthorA", year = "2010"}
@article{ArticleZ, author = "AuthorB", year = "2010"}
\end{filecontents}
\newcommand{\Test}[2]{
\ifx\citeauthor{#1}\citeauthor{#2}
Yes!
\else
No!
\fi
}
\begin{document}
Oh, \cite{ArticleX} and \cite{ArticleZ} don't have the same author? \Test{ArticleX}{ArticleZ} Ok!
But \cite{ArticleX} and \cite{ArticleY} surely have! \Test{ArticleX}{ArticleY} No, either??
\bibliographystyle{unsrtnat}
\bibliography{\jobname}
\end{document}