3

I am doing my thesis and trying to set up biblatex with APA on overleaf. In my references.bib file I have:

@misc{ramstedt2014andt,
  title={ANDT-bruket och dess negativa konsekvenser i den svenska befolkningen 2013},
 author={Ramstedt, Mats and Sundin, Erica and Landberg, Jonas and Raninen, Jonas},
 year={2014},
 publisher={Rapport}
}

@book{andersson2009alcohol,
title={Alcohol Use and Stress in University Freshmen-A Comparative Intervention Study of Two Universities},
author={Andersson, Claes},
volume={2009},
number={41},
year={2009},
publisher={Clinical Alcohol Research, Department of Health Sciences, Lund    University}
}

In my main file I have:

 \documentclass[bachelor,lith,english]{liuthesis}
  %% Settings go in settings.tex
  \include{settings}

Now this comes in the settings file

\usepackage[backend=biber,hyperref, style=apa]{biblatex}
\DeclareLanguageMapping{british}{british-apa}


\ExecuteBibliographyOptions{maxnames=99}

\addbibresource{references.bib}

However when I cite like this:

Today approximately 446 000 people suffer from alcohol addiction in Sweden \cite{ramstedt2014andt}.

I get:

Today approximately 446 000 people suffer from alcohol addiction in Sweden . ramstedt2014andt 

EDIT:

The style I am expecting is classic APA such as:

(Ramstedt et al, 2014)
(Ramstedt, 2014)
 Ramstedt (2014)

The warnings I have is:

./demo_student_thesis.tex:
Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                demo_student_thesis
(biblatex)                and rerun LaTeX afterwards.


./intro.tex:37:
LaTeX Warning: Citation 'ramstedt2014andt' on page 1 undefined on input line 37
.

./demo_student_thesis.tex:79:
LaTeX Warning: Empty bibliography on input line 79.

EDIT II

Some progress here. I managed to compile after adding "backref=true".

\usepackage[backend=biber,hyperref,backref=true style=apa]{biblatex}

What this did was adding a numbered reference as such 1 for the ramstedt2014andt reference. I compared my settings with this overleaf template.

EDIT III By remowing \printbibliography from the main file I got this result: Ramstedt, Sundin, Landberg and Raninen, 2014. I could just write "and others" in the reference.bib file however the parenthesis does not seem to be included still.

Parenthesis could be solved by using \parencite{}. However is there a way to automatically set et al instead of adding "and others" in the bib.file?

imnothere
  • 14,215
  • 1
    What style do you expected?(in text) Please add a full MWE https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-example-what-is-that . As example bib entries you can use in the MWE http://tex.stackexchange.com/questions/141957/the-most-basic-biblatex-example . – Bobyandbob Mar 29 '17 at 16:41
  • 1
    Welcome to TeX.SX! This sounds like it might be Question mark or bold citation key instead of citation number but if you're using Overleaf I think they normally automate the necessary biber run for you. Possibly there's a typo somewhere so the references.bib entry is not exactly the same as that of the \cite{} command but the example looks ok, could you add a minimal (non-)working example with bibliography (MWEB) to the question? – Dai Bowen Mar 29 '17 at 16:47
  • I hope the new info is enough as a MWEB. – sockevalley Mar 29 '17 at 17:12
  • Please post a full MWE (ideally that would be one document that we can just copy and run on our machines without further changes - you have only shown code snippets so far). Since you are using Overleaf, Biber should be run for you automatically. So the problem is probably directly related to your actual .bib entries or the way you us it. Please check the .log file for errors (you should be able to have a look at the top right.) – moewe Mar 29 '17 at 17:13
  • If you don't get the expected output you should see something like 'warning' or 'error' in the top right of the output window. Click on it and click 'recompile from scratch'. If the problem persist, get the .log and .blg files. – moewe Mar 29 '17 at 17:16
  • You may have to download the .blg manually via https://www.overleaf.com/help/207-how-do-i-download-the-automatically-generated-files-e-dot-g-bbl-aux-ind-gls-for-my-project-my-publisher-asked-me-to-include-them-in-my-submission – moewe Mar 29 '17 at 17:17
  • This is by no means a sufficient MWE since we can't just copy, paste and then compile it. Even if we put all of the code together we will probably fall short of what you have. I realise that it is quite hard to break down your code that much, even more so since you are using an online editor. Maybe you should focus on getting us that .blg file. – moewe Mar 29 '17 at 17:27
  • I know, it's quite hard when I am working with more than 10 connected files in Overleaf. What does this warning usually mean? LaTeX Warning: Citation 'ramstedt2014andt' on page 1 undefined on input line 37 – sockevalley Mar 29 '17 at 17:30
  • 2
    It means exactly that the citation cannot be found. It could just be that you misspelled it, but that is quite unlikely from what I see here. Normally you get an error as this because Biber failed to run properly (for more info on what Biber does see https://tex.stackexchange.com/q/63852/106162 as linked to by Dai Bowen). In order to find out why Biber failed to process your citations properly, we need to see the .blg file – moewe Mar 29 '17 at 17:32
  • The .log just confirms that it is very important we get to see that .blg file. It shows that LaTeX fails to find the .bbl file, which heavily suggests that Biber either failed to run or bailed out when trying to compile your .bib file. – moewe Mar 29 '17 at 17:44
  • I don't think you can genereate a .blg file in overleaf. From what I've seen it's only possible to generate a .log file. – sockevalley Mar 29 '17 at 18:13
  • @sockevalley -- A .blg file is a necessary consequence of using biblatex/Biber. Overleaf cannot overcome that. – jon Mar 29 '17 at 18:48
  • Alright, however my issue is almost finished. Parenthesis could be solved by using \parencite{}. However is there a way to automatically set et al instead of adding "and others" in the bib.file? – sockevalley Mar 29 '17 at 18:52
  • Please note that backref=true style=apa is wrong. You are missing a comma between true and apa. That is why you get the default numeric style. This is most certainly not an answer to your question. As you can see in the answers there are several issues with your document. The template is not a particularly good one and some of your settings don't match. – moewe Mar 30 '17 at 06:56
  • Note that a successfully Biber run must produce a .blg. I didn't find a way to directly download the .blg file on Overleaf as you can do for the .log. You can download all files in a .zip (amongst them hopefully the .blg) with this manual solution I linked to earlier: https://www.overleaf.com/help/207-how-do-i-download-the-automatically-generated-files-e-dot-g-bbl-aux-ind-gls-for-my-project-my-publisher-asked-me-to-include-them-in-my-submission – moewe Mar 30 '17 at 06:58
  • Regarding the 'et al.' thingy: It is standard behaviour in APA style to cite all authors (well, up to five or six) on a first citation and then use 'et al.' on subsequent cites. You should not manually add and others to your .bib file. – moewe Mar 30 '17 at 06:59

2 Answers2

2

Use \input instead of \include in the preamble.

\include can only be used after the \begin{document}.

For an explanation why and what the difference between those two is see the answer from "Martin Scharrer" at When should I use \input vs. \include?

Georg
  • 1,566
  • 1
    @moewe I also thought that \include shouldn't be to blame here but it does seem to make a difference (I guess through the use of a different aux file), with `\begin{filecontents}{settings.tex} \usepackage{biblatex} \addbibresource{biblatex-examples.bib} \end{filecontents}

    \documentclass{article} \include{settings.tex} \begin{document} Foo~\cite{bertram} \end{document}I get the citation rendering as[?]with\includesuggestingbiblatexis not loading (haven't checked this with the latestbiblatex` yet though).

    – Dai Bowen Mar 29 '17 at 18:20
  • ... And, regardless of whether you can or cannot use \include in the bibliography, it is almost always better to use \usepackage{settings} (with a file called settings.sty rather than settings.tex). (And if you don't know why that is, you are 99.9% of the time better off using \usepackage rather than \include or \input for your preamble settings.) – jon Mar 29 '17 at 18:46
  • 1
    @DaiBowen Ah yes indeed, you can't load biblatex in an \include. I didn't see that the package was loaded in setings.tex (strange place to load a package ...). – moewe Mar 30 '17 at 06:54
2

I believe the problem may be (anyway a problem is) that you have set your language to english (probably! that at any rate is an option passed to your class) but your \DeclareLanguageMapping specifies british. biblatex is picky, about these things. If I set babel to english and then map only british, using article class, I get (as one would expect) undefined control sequence errors as a result of not having apa specific code loaded. It may be that Overleaf is struggling on and hiding these from you ... I don't know since I don't use it. But I do know that you must match your language mapping to your language definition.

Separately, the form of the citation: as you have worked out, use \parencite or \autocite. That is by design.

(The include is wrong too of course, but not the source of the problem here. Biblatex doesn't care about the .aux file.)

Paul Stanley
  • 18,151
  • Cool thanks, another issue that have arrived is that I cannot use the \printbibliography for some reason. – sockevalley Mar 29 '17 at 22:29
  • That is very odd. It's really hard to diagnose these problems with snippets and odd classes and templates behind them. I suggest you start by stripping things down to a minimum, in a single file, using a standard class (= "template") such as \usedocument{book}. Get it working there first so you thoroughly understand the simple case first. – Paul Stanley Mar 29 '17 at 23:12
  • @PaulStanley -- "... such as \documentclass{book}." (I know you know this, but just case others think there's a command \usedocument....) – jon Mar 29 '17 at 23:53
  • @jon Crikey! They would be forgiven for thinking so. ... When we get a question on that, you can blame me. – Paul Stanley Mar 30 '17 at 00:00