im trying to get apa citations to work with my current latex project using apacite and natbib. Its not working however since this is what i currently get when i use \cite:enter image description here. I am using a template project and do not have very good knowledge of latex so I have not been able to figure out yet what is causing the apacite to fail. Here's the code from my preamble:

\title{Manual for thesis}

%%% overview of this file in order:
% most packages which don't need options
% geometry package
% header/footer settings
% theorem styles
% enable/disable parindents
% reference and bibliography settings
% front/main/back-matter


        %layout,        % Allow visualisation of all the margins
        subfiles,       % For seperate main and sub documents
        graphicx,       % For image modifications and the figure enviroment
        amsmath,        % For the AMS math styles
        amssymb,        % The extended AMS math symbol list
        amsthm,         % For use of theorems (works together with thmtools)
        fancyhdr,       % For fancy headers and footers on pages
        %gensymb,       % For easy generic symbols (uniform use in math and text mode)
        %sidecap,       % For use of captions next to a float (figure, table, etc)
        %subcaption,    % For easy subfigures in a plot (with nice captions)
        tikz,           % Difficult drawing of awesome vector plots
        %listings,      % For listing pieces of code in a nice and neat way
        multicol,       % For easy local multicolumn use
        color,          % For handy color deafinitions (used cause of styling)
        %calc,          % To calculate stuff for the back-end
        %mdwlist,       % For customizing lists
        thmtools,       % Lets you define your own theorem style (used for all the fancy theorems, definitions etc.)
        etoolbox,       % Allows adjustment of commands (used to reset the claim counter at the end of a proof).
        xspace,         % Makes latex not eat spaces after commands
        hyperref,       % Makes links, references, the Table of Contents, etc. clickable.


        %\sepackage[margin=2.5cm]{geometry}     % Change the shape of a page (custom margins etc.)
        %paper=a4paper slightly changes the style through the whole document.
             %%%% We set the margins for whole document here, except the titlepage. The titlepage uses special margins; see titlepage.tex.


%%% This is about changing the headers and footers (i.e. Top and bottom of the page)

\pagestyle{fancy}% use fancyheaders with the bar on the top
\fancyhf{} % Clear the normal style
\fancyhead[L]{\bfseries\leftmark} %this places the section number and name in the top left
\fancyhead[R]{\bfseries\thepage}% this places the pagenumber in the top right

%%%%        Theorem style

% The set-up is as follows, first you give the 'style' of your theorem. This determines whether it for instance is plain, or italic. Secondly you can give an option for the symbol on the end, normally it is nothing. But you could add some to increase the readability of your text. Finally you can use numberwithin to add the number of your section/theorem before your equations. This is useful if you want to keep the numbers of your equation in check (In this thesis there where over a 100) and keeps in order where the equations are.
%Finally you can use sibling to let different 'theorems' count together. Hence you will get Theorem 1 Definition 2 Claim 3, instead of Theorem 1 Definition 1 Claim 1. This is a matter of taste.

% Theorem definitions
\declaretheorem[style=definition,numberwithin=subsection]{definition} %If you want your theorems to be counted per section instead of subsection, then just remove the sub from the numberwithin
\declaretheorem[style=definition,qed=$\triangle$,sibling=definition]{example}% sibling says with what type of theorems you wan the numbering to count with.


\AtEndEnvironment{proof}{\setcounter{claim}{0}} % Sets the claim number to 0 after ending a proof

% these environments are very nice and all, but it is a bit much to type every time, so for normal theorem-proof cases you can make your own commands like these. 

\newcommand{\thm}[2]{\begin{theorem} #1 \begin{proof} #2 \end{proof} \end{theorem}}
\newcommand{\lm}[2]{\begin{lemma} #1 \begin{proof} #2 \end{proof} \end{lemma}}
\newcommand{\df}[1]{\begin{definition} #1 \end{definition}}
\newcommand{\clm}[1]{\begin{claim} #1 \end{claim}}


% Comment/uncomment the following to disable/enable parindents:

%%%% Add the bibliography with some settings:
% package:

% choose brackets:  default: round (), square [], curly {}, angle <>
% choose separation between multiple citations (\cite{a,b}):
%% default: colon ;, comma ,
% choose citation style:
%% default: authoryear Johnson (2017), numbers (25) or super ^[25]
% option: choose sort (\cite{13,5} gives [5,13]) or sort&compress
%% in authoryear mode, sort&compress changes Johnson[2016] Johnson[2017] to
%% Johnson[2016,2017].
% option: longnamesfirst (author names will be shortened (et al.) after the first time
% option: nonamebreak (can solve hyperref bugs, but will instead cause hbox problems)
% https://en.wikibooks.org/wiki/LaTeX/Bibliography_Management#Natbib

% bibliography sort style:
\bibliographystyle{apacite} %references in order of call
%more options: default: plainnat, apsrev, unsrtnat, abbrvnat, rmpaps (different sortings and abbreviation settings, no idea which is which)


%%%%% frontmatter/mainmatter/backmatter:
    \pagenumbering{roman}} %small Roman numbers

    \pagenumbering{arabic}} %normal numbers

    \cleardoublepage %% double page style
    %\clearpage %% single page style
    \pagenumbering{Roman}} %capital Roman numbers

\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\else % if luatex or xelatex
% use upquote if available, for straight quotes in verbatim environments
% use microtype if available
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
\urlstyle{same}  % don't use monospace font for urls
% Add ',fontsize=\small' for more characters per line
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
}{% else
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
% Redefines (sub)paragraphs to behave more like sections

%%% Use protect on footnotes to avoid problems with footnotes in titles

%%% Change title format to be more compact

\newcommand*{\addFileDependency}[1]{% argument=file name and extension
  \typeout{(#1)}% latexmk will find this if $recorder=0 (however, in that case, it will ignore #1 if it is a .aux or .pdf file etc and it exists! if it doesn't exist, it will appear in the list of dependents regardless)
  \IfFileExists{#1}{}{\typeout{No file #1.}}% latexmk will find this message if #1 doesn't exist (yet)


I hope you guys can see what is causing this! Thanks in advance for the help.

  • Please turn this into a Minimal Working Example; this is far too much for most people here to want to wade through. See tex.meta.stackexchange.com/q/228/107497 – Teepeemm Jun 18 at 15:47
  • The apacite and natbib packages are incompatible with each other. Use one or the other, but not both simultaneously. For the case at hand, don’t load natbib. – Mico Jun 18 at 17:42
  • At first glance "Ruder (2018)" appears to be a valid citation according to APA style. Note, however, that the command \cite should ideally not be used when you load natbib, use \citet or \citep instead. While you should (probably) not load natbib and apacite together, you can load apacite with the option natbibapa (i.e. \usepackage[natbibapa]{apacite}, that is one reason why I would advise against one \usepackage to load all packages at once), which allows you to use \citet and \citep instead of apacite's own macro names. – moewe Jun 18 at 18:34
  • Your preamble loads quite a lot of packages and defines quite a lot of commands. Do you need all of them? As a general rule it is much safer to load only packages you need (ideally you would also know roughly what each package does and why you load it). Note also that hyperref should usually be loaded last (there are a few documented exceptions). – moewe Jun 18 at 18:39
  • A nice overview over APA style citations and bibliographies can be found at tex.stackexchange.com/q/263793/35864 – moewe Jun 18 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.