[Tex/LaTex] Multibib fails to show a second bibliography in the appendix

bibliographiesmultibib

I am using multibib and natbib together to get two different bibliographies (one for the main text and one for the appendix). Here is an example code

\documentclass[12pt]{article}
\usepackage{natbib}
\usepackage{multibib} 
\newcites{apndx}{References}
\begin{document}

First paper to cite: \cite{X1}
\bibliographystyle{ecca}
\bibliography{XXX}

\appendix

Cite a paper in the appendix \citeapndx{X2}

\bibliographystyleapndx{ecca} 
\bibliographyapndx{XXX}


\end{document}

However, the second bibliography does not show up, and the citation in the appendix only gives a "?". I looked up in the multibib manual and in other similar questions, but I do not get where the error is.

UPDATE 1
This happens even though I run the bibtex file twice. Here is the log file:

Process started: /Library/TeX/texbin/bibtex "prova".aux

This is BibTeX, Version 0.99d (TeX Live 2016)
The top-level auxiliary file: prova.aux
The style file: plain.bst
Database file #1: myrefs.bib

Process exited normally 

Process started: /Library/TeX/texbin/bibtex "prova".aux

This is BibTeX, Version 0.99d (TeX Live 2016)
The top-level auxiliary file: prova.aux
The style file: plain.bst
Database file #1: myrefs.bib

Process exited normally

UPDATE 2:
I think the problem is that my TexStudio does not run the sec.aux file which generates the link to the second bibliography. I followed the steps of this link https://sourceforge.net/p/texstudio/wiki/Tips%20and%20Tricks/ and created a .cwl and added it to TexStudio Completion but it still does not work.

Best Answer

Using multibib results after the first compile run of file mwe.tex with pdflatex (or in your case compiling with TeXStudio) in two new files mwe.aux and apndx.aux. Both .aux files needs to be run with bibtex. TeXStudio does the run with bibtex for file mwe.aux, for apndx.aux you need to do it by your own. Just run the command bibtex apndx in a windows terminal. After that you can compile two times with TeXStudio to get the resulting PDF.

To get command \citeapndx be run in a caption of a figure (your question in the comments) you need to use command \protect like (same for a \section):

  \caption{In figure caption \protect\citeapndx{Johnson2000}}
 %                           ^^^^^^^^

So with the following file mwe.tex (package filecontents is only used to have both bib files and the tex code in one compiling MWE):

% needs:  bibtex apndx
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inproceedings{Creighton2006,
  author    = {Creighton, Oliver and Ott, Martin and Bruegge, Bernd},
  booktitle = {Requirements Engineering, 14th IEEE International Conference},
  isbn      = {0769525555},
  pages     = {109--118},
  publisher = {IEEE},
  title     = {{Software cinema-video-based requirements engineering}},
  url       = {http://ieeexplore.ieee.org/xpls/abs{\_}all.jsp?arnumber=1704054},
  year      = {2006},
}
\end{filecontents}
\begin{filecontents}{apndx.bib}
@article{Johnson2000,
  author  = {Johnson, W Lewis and Rickel, Jeff W and Lester, James C},
  journal = {International Journal of Artificial Intelligence in Education},
  number  = {11},
  pages   = {47--78},
  title   = {{Animated pedagogical agents: face-to-face interaction in 
              interactive learning environments}},
  volume  = {Internatio},
  year    = {2000},
}
\end{filecontents}


\documentclass[12pt]{article}

\usepackage{natbib}
\usepackage{multibib} 
\usepackage{graphicx}

\newcites{apndx}{References in Appendix}


\begin{document}

First paper to cite: \cite{Creighton2006}
\bibliographystyle{ecca}
\bibliography{\jobname}

\appendix

Cite a paper in the appendix \citeapndx{Johnson2000}

%\section{In the appendix \protect\citeapndx{Johnson2000}} % <===========
\begin{figure}
  \centering
    \includegraphics[width=5cm]{example-image-a}
  \caption{In figure caption \protect\citeapndx{Johnson2000}} % <=======
  \label{fig:example-image-a}
\end{figure}

\bibliographystyleapndx{ecca} 
\bibliographyapndx{apndx}

\end{document}

and the compiling chain (independent from TeXStudio):

  • open a terminal window in Windows with pressing windows start key and R, then type cmd, press enter
  • move to the directory where you have your tex code and the bib file(s) with cd <directory path>
  • run command pdflatex mwe (resulting in two needed .aux files)
  • run command bibtex mwe (compiles mwe.aux)
  • run command bibtex apndx (compiles apndx.aux)
  • run command pdflatex mwe (resulting in files *.bbl and *.blg)
  • run command pdflatex mwe (resulting in pdf file with bibliography)

If you are using an editor (TeXStudio, TeXnicCenter, ...) the editor can run pdflatex mwe and bibtex mwe for you, but not bibtex apndx. So run this command after the first compile run with TeXStudio in a windows terminal ...

After running the compile chain you get the following resulting pdf:

enter image description here

Related Question