2

I seem to have issues getting citations working in TeXmaker. Code is roughly as follows:

%%% citations
\usepackage{natbib}
\bibliographystyle{plain}
%stuff

\begin{document}
\maketitle
\section{Proposed Work}
\subsection{A subsection}
More text.

\cite{test} \citet{viegas} \citep{asd}

\bibliography{E:/all_lit}
\end{document}

E:/all_lit.bib looks roughly like:

@InProceedings{viegas,
author = {Viegas, Gisela and Urbancic, Ted and Baig, Adam and von Lunen, Eric},
title = {Rupture dynamics and source scaling relations of microseismic hydraulic fractures in shale reservoirs},
booktitle = {Proceedings of the 13th International ISRM Congress 2015},
year = {2015},
}

@Article{test,
author = {poo},
title = {poo1},
journal = {poo2},
year = {2000},
}

@Book{asd,
author = {rr},
ALTauthor = {aa},
ALTeditor = {ss},
title = {ddd},
publisher = {qwe},
year = {2000},
}

I have quick build set to PdfLatex + Bibtex + PdfLatex x2 + View PDF and have set Bibtex to build to bibtex build/% because it was not referencing the correct file before. I get a .bbl file which contains

\begin{thebibliography}{1}

\bibitem{test}
poo.
\newblock poo1.
\newblock {\em poo2}, 2000.

\bibitem{asd}
rr.
\newblock {\em ddd}.
\newblock qwe, 2000.

\bibitem{viegas}
Gisela Viegas, Ted Urbancic, Adam Baig, and Eric von Lunen.
\newblock Rupture dynamics and source scaling relations of microseismic hydraulic fractures in shale reservoirs.
\newblock In {\em Proceedings of the 13th International ISRM Congress 2015},
 2015.

\end{thebibliography}

However I'm still getting the error that Citation 'test' on page 3 is undefined and [?] for citations. This applies to the other citations too. Help would be appreciated.

closed as unclear what you're asking by Johannes_B, Svend Tveskæg, Thorsten, user13907, user31729 Mar 27 '16 at 9:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Resolved by clearing the aux-files and recompiling. The answers aren't useful at all (imho), nobody upvoted yet ... i vote to close as unclear, alltough off-topic would be more to the point. – Johannes_B Mar 27 '16 at 7:26
0

Your mistake is in using plain and not plainnat:

\begin{filecontents*}{\jobname.bib}
@InProceedings{viegas,
author = {Viegas, Gisela and Urbancic, Ted and Baig, Adam and von Lunen, Eric},
title = {Rupture dynamics and source scaling relations of microseismic hydraulic fractures in shale reservoirs},
booktitle = {Proceedings of the 13th International ISRM Congress 2015},
year = {2015},
}

@Article{test,
author = {poo},
title = {poo1},
journal = {poo2},
year = {2000},
}

@Book{asd,
author = {rr},
ALTauthor = {aa},
ALTeditor = {ss},
title = {ddd},
publisher = {qwe},
year = {2000},
}
\end{filecontents*}

\documentclass{article}

\usepackage{natbib}
\bibliographystyle{plainnat}
%stuff

\begin{document}
\section{Proposed Work}
\subsection{A subsection}
More text.

\cite{test} \citet{viegas} \citep{asd}

\bibliography{\jobname}
\end{document}

Note that I used filecontents just not to clobber my files. Use your own file, of course.

enter image description here

  • I tried plainnat both before the \document header and after as suggested by the other user but neither changed anything >.< – Bing Feb 25 '16 at 22:47
  • I also tried copying your code into Texmaker as a new file but it still doesn't work. I tried it with both the second quick build option and manually doing pdftex + bibtex + 2x pdftex. Seems like maybe one of my settings is wrong. – Bing Feb 25 '16 at 22:52
0

Apparently, your mistake is using style file before \begin{document}. This file works fine:

\documentclass[10pt]{amsart}
%% citations
\usepackage{natbib}
%stuff
\begin{document}
    \section{Proposed Work}
    \subsection{A subsection}
    More text.

    \cite{myref1} \citet{myref2}

    \bibliographystyle{plain}    % <- the new place
    \bibliography{mybib}
\end{document}

Second Edit: Here is the exact code I have on my TeX file:

\documentclass[10pt]{amsart}
\usepackage{natbib}
\begin{document}
    \section{Proposed Work}
    \subsection{A subsection}
    More text.

    \cite{aref2009optimal} --- \cite{aref2014ICRA}

    \bibliographystyle{plain}    % <- the new place
    \bibliography{../bib/papers}
\end{document}

and here is the output + the compilers TeXStudio uses for the file; enter image description here I'm still able to generate the same error by moving the style file before \begin{document}.

  • Didn't make it work :( – Bing Feb 25 '16 at 22:47
  • I added the output of the same code to my answer. – Winsoft Feb 25 '16 at 23:43
  • The bibliography shows, but the citations still don't work with your code coped in and the bibliography filepath changed. Would you be able to give me your .bib to try? Also I'm using Texmaker 4.5 so my settings page is different but I think the settings are the same. – Bing Feb 26 '16 at 0:08
  • I modified my code to match your BIB file and I got the same BBL file. Everything seems to be working for me. There might be something else than the code. I don't have time now to update my answer but your BIB file works too on my system. Check also the log files to see if there is any error or warning. – Winsoft Feb 26 '16 at 8:38
  • Thanks for your reply. I fixed it by deleting all build files and re-compiling, was stupid of me not to try that first. Thanks for everything! – Bing Feb 26 '16 at 15:18
0

I deleted all the build files and re-compiled the whole thing and it works now. Thanks everyone for the help!

  • Well, it happens sometime. I'm glad that you are now back to the normal situation :D You might avoid such problem by compiling the Bibliography exasperatedly. In TeXStudio environment, when I'm changing the references, I try to compile by BIB and then by PDFLaTeX. So, recently, I didn't face any issue. Few years ago, I used to go and clear the directory one in a while to avoid such issues as you mentioned. – Winsoft Feb 27 '16 at 13:22

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