[Tex/LaTex] \citeauthor and \citeyear not working correct with multibib and natbib

bibliographiescitingmultibibnatbib

I have this minimal document (doc.tex):

\documentclass[10pt]{scrreprt}

\usepackage{natbib}
\usepackage{multibib}
\newcites{book}{References}
\bibpunct[; ]{(}{)}{;}{a}{,}{,~}

\begin{document}

Some senseless text with citation \citepbook{book}.
And another text with citation (\citeauthor{book}, \citeyear{book} and \citeauthor{book2}, \citeyear{book2}).


\bibliographystylebook{apalike2}
\bibliographybook{sourcesBook}

\end{document}

And this .bib file:

@Misc{book,
  author= {{Book}},
  year={2017},
}

@Misc{book2,
  author= {{Book 2}},
  year={2016}
}

When I generate the document now, I will get a failure for the second entry of the bib file. The log says:

Package natbib Warning: Citation `book2' on page 1 undefined on input
line 13.

The output of the PDF looks like this:

enter image description here

Anyone an idea what is wrong here? I need the multibib because I have to generate a bibliography for books and online sources.

Best Answer

As you have already noted in a comment to your own answer, you have to use one of the multibib variants of the usual cite commands before you can use \citeyear and \citeauthor, for which there is no multibib variant, unfortunately.

However, there is a multibib variant for the \nocite command, which technically causes a citation but is invisible. Thus, if \citealpbook is not an option, you can avoid adding additional useless citations and do this instead:

Some senseless text with citation \citepbook{book}. 
And another text with citation (\citeauthor{book}, \citeyear{book}
and \nocitebook{book2}\citeauthor{book2}, \citeyear{book2}).
Related Question