1

I found some difficulties using the template MasterDoctoralThesis of LaTeX so I'm starting creating a new document. I would like to insert APA style citations here. At first i'm not able to print bibliography with this code. LaTeX says "citation undefined". Anybody can help me to solve the error and add a line to specify also APA style references? Thanks in advance! I'm pretty nervous about that.

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {Figures/} }


\usepackage{biblatex}
\addbibresource{references.bib}

\usepackage{float}
\usepackage{lipsum}
\usepackage{subfig}
\usepackage{adjustbox}
\usepackage{tabularx,booktabs}
\usepackage{mathtools}
\usepackage{array}
\usepackage{dcolumn}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%\newcolumntype{P}{>{\raggedright\arraybackslash}X}
\setlength\tabcolsep{2pt}
\captionsetup{
    justification = centering
}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage{xurl}
\usepackage{hyperref}
\DeclareMathOperator{\Pa}{Pa}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\setlength\tabcolsep{2pt}
%

\title{
    {Thesis Title}\\
    {\large Institution Name}\\
    {\includegraphics{university.jpg}}
}
\author{Author Name}
\date{Day Month Year}



\begin{document}


\chapter*{Abstract}
Blabla


\chapter*{Dedication}
Dedicated to my family and to my soulmate Davide.


\chapter*{Declaration}
\begin{itemize} 
    \item This work was done wholly or mainly while in candidature for a research degree at this University.
    \item Where any part of this thesis has previously been submitted for a degree or any other qualification at this University or any other institution, this has been clearly stated.
    \item Where I have consulted the published work of others, this is always clearly attributed.
    \item Where I have quoted from the work of others, the source is always given. With the exception of such quotations, this thesis is entirely my own work.
    \item I have acknowledged all main sources of help.
    \item Where the thesis is based on work done by myself jointly with others, I have made clear exactly what was done by others and what I have contributed myself.\\
\end{itemize}

%\chapter*{Acknowledgements}
%I want to thank...

\tableofcontents

i'm trying to cite here but it doesn't works for me \cite{hoek1992modified}

\printbibliography    

\end{document}

This is an example of my .bib file (called references.bib).

@inproceedings{hoek1992modified,
    title={A modified Hoek--Brown failure criterion for jointed rock masses},
    author={Hoek, E and Wood, D and Shah, S},
    booktitle={Rock Characterization: ISRM Symposium, Eurock'92, Chester, UK, 14--17 September 1992},
    pages={209--214},
    year={1992},
    organization={Thomas Telford Publishing}

enter image description here

Elisa m
  • 359
  • 1
    Did you run the normal cycle: pdflatex->biber->pdflatex (twice)? – Bernard Aug 30 '19 at 09:19
  • @Bernard i'm new in latex, i'm sorry i don't know what you mean :( – Elisa m Aug 30 '19 at 09:23
  • LaTeX by itself cannot produce a bibliography from a .bib file. It only produces an auxiliary file, that a bibliography engine (biber or bibtex) can compile to produce another auxiliary file that latex will use for the final layout of the bibliography. B.t.w., what is your latex editor? – Bernard Aug 30 '19 at 09:28
  • @Bernard i'm using MikText 2.9 – Elisa m Aug 30 '19 at 09:39
  • That's the distribution. But the editor? – Bernard Aug 30 '19 at 09:40
  • TexStudio you mean? @Bernard – Elisa m Aug 30 '19 at 09:43
  • Yes. You have shortcuts to compile and launch the bibliography engine. If not already done, you have to configure TeX Studio so that the default bibliography engine is biber (Options menu-> Configure TeX Studio -> Production). – Bernard Aug 30 '19 at 09:53
  • @Bernard done. It doesn't work.. should i have to download manually any package? i really don't know how to fix it – Elisa m Aug 30 '19 at 10:05
  • What doesn't work exactly? – Bernard Aug 30 '19 at 10:08
  • @Bernard it doesn't produce the Bibliography. It says: citation undefined – Elisa m Aug 30 '19 at 10:16
  • Is the bib file in the same directory as your main file? – Bernard Aug 30 '19 at 10:23
  • Please open an console/terminal and change to the directory where your tex code mwe.tex is. Now type pdflatex mwe and press enter. Then type biber mwe and press enter. Now pdflatex mwe two times. result? If there are problems please open file mwe.log and copy-paste the first error message to your question ... – Mensch Aug 30 '19 at 10:25
  • Thank you @Mensch this is the log file: https://pastebin.com/KGzREx0M – Elisa m Aug 30 '19 at 10:29
  • Well, Did you open the terminal and run pdflatex mwe, biber mwe and twice pdflatex mwe? Please follow the hints we gave you, only then we can together solve your issue ... – Mensch Aug 30 '19 at 10:47
  • @Mensch i tried every your suggestion, i tried also to copy your code and run it, but the problem persist. I edited my question and i added a picture illustrating an incompatibility of versions. Maybe the problem is related to that. What should i do? re-install everything? – Elisa m Aug 30 '19 at 13:16
  • The screenshot shows that your biblatex and Biber versions are out of sync. You need to update your TeX distribution. Run and Update with the MikTeX Console once in Admin and once in User mode. See https://tex.stackexchange.com/q/55437/35864 for more guidance with pictures. – moewe Aug 30 '19 at 13:29
  • How did you get version 3.5 of biblatex? Did you manualy update it? Never do that! If possible, delete the manual updated version and start an update of MiKTeX with the MiKTeX Console. If you have an admin installation do the update in user and admin mode! – Mensch Aug 30 '19 at 13:29
  • i don't how i got it, not manually for sure! now i solved the problem updating everything using the console. but... now i see the citations only in the main file, and not in the chapters. Why? @Mensch – Elisa m Aug 30 '19 at 13:54
  • Well, at last your question here is solved. Your last comment is a completly new question, so please copy my mwe in my answer, prepare it to show at last one chapter (how did you include it? If you use a separate file add this file shortened to your new question!) and how you cite there. Copy this changed mwe to a new question and describe your issue as excact as you can. perhaps you can add an screenshot of your result. And please check the files mwe.log and mwe.blg for error messages. If you get some copy and paste them to your new question too! – Mensch Aug 30 '19 at 14:04
  • 1
    @Mensch i created a new question, it's simpler. thanks a lot a lot for your help, you are so kind!!!! – Elisa m Aug 30 '19 at 14:25

1 Answers1

2

Well, let us say your tex code is named mwe.tex. Then we get after running pdflatex mwe and biber mwe based on your given codes in your question the following bibliography log file mwe.blg:

[0] Config.pm:304> INFO - This is Biber 2.12
[0] Config.pm:307> INFO - Logfile is 'mwe.blg'
[35] biber-MSWIN64:315> INFO - === 
[66] Biber.pm:371> INFO - Reading 'mwe.bcf'
[171] Biber.pm:889> INFO - Found 1 citekeys in bib section 0
[188] Biber.pm:4093> INFO - Processing section 0
[207] Biber.pm:4254> INFO - Looking for bibtex format file 'mwe.bib' for section 0
[209] bibtex.pm:1523> INFO - LaTeX decoding ...
[213] bibtex.pm:1340> INFO - Found BibTeX data source 'mwe.bib'
[222] Utils.pm:209> ERROR - BibTeX subsystem: C:\Users\User\AppData\Local\Temp\43isMu1M0d\mwe.bib_4296.utf8, line 8, syntax error: at end of input, expected one of: name (entry type, key, field, or macro name) or end of entry ("}" or ")")
[222] Biber.pm:114> INFO - ERRORS: 1

As you can see there is an error in your given bib file. To say it clear the closing } for bib entry hoek1992modified is missing ...

So after adding that missing bracket we get the following corrected and minimalized MWE (package filecontents is only used to get one MWE containing TeX and bib code; you need not to use it for your work!):

\begin{filecontents}{\jobname.bib}
@inproceedings{hoek1992modified,
  title        = {A modified Hoek--Brown failure criterion for jointed rock masses},
  author       = {Hoek, E and Wood, D and Shah, S},
  booktitle    = {Rock Characterization: ISRM Symposium, Eurock'92, Chester, UK, 14--17 September 1992},
  pages        = {209--214},
  year         = {1992},
  organization = {Thomas Telford Publishing},
}
\end{filecontents}


\documentclass[12pt]{report}

\usepackage[utf8]{inputenc}

\usepackage{geometry}

\usepackage{biblatex}
\addbibresource{\jobname.bib}

\usepackage{xurl}
\usepackage{hyperref}


\begin{document}

i'm trying to cite here but it doesn't works for me \cite{hoek1992modified} 

\printbibliography

\end{document}

and its resulting bibliography:

resulting bibliography

So please have a look for file *.blg for your document and check there if there are errors mentioned (I guess, there are more than one errors). Now correct all mentioned errors in your bib file ...

Please see that extention blg is a special one for windows, so open the file with for example calling notepad++ mwe.blg, if you have installed the editor notepad++ ...

To get apa style with biblatex you can add style=apa as option to biblatex. Please see the following MWE (I used class article to have citing and bibliography on one page only):

\begin{filecontents}{\jobname.bib}
@inproceedings{hoek1992modified,
  title        = {A modified Hoek--Brown failure criterion for jointed rock masses},
  author       = {Hoek, E and Wood, D and Shah, S},
  booktitle    = {Rock Characterization: ISRM Symposium, Eurock'92, Chester, UK, 14--17 September 1992},
  pages        = {209--214},
  year         = {1992},
  organization = {Thomas Telford Publishing},
}
\end{filecontents}


\documentclass[12pt]{article}% report

\usepackage[utf8]{inputenc}

\usepackage{geometry}

\usepackage[%
  style=apa, % <========================================================
  backend=biber
]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{xurl}
\usepackage{hyperref}


\begin{document}

i'm trying to cite here but it doesn't works for me \cite{hoek1992modified} 

\printbibliography

\end{document}

and its result:

resulting bibliography

Mensch
  • 65,388