Overleaf/Latex. How do I add APA 6th edition citation style? - latex

[EDIT]
I am having issues changing the citation style to my document. I am currently working with this preamble. There are a lot of packages, but I need them to organise the entire file. The current code works ok, but the citation style is not correct. I need to change it to apa 6th edition.
Preamble:
\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{helvet}
\usepackage{xspace}
\usepackage{subcaption}
\usepackage{placeins}
\usepackage{wrapfig}
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{adjustbox}
\usepackage{booktabs,caption}
\usepackage[flushleft]{threeparttable}
\usepackage{ragged2e}
\usepackage{floatrow}
\usepackage{graphicx,wrapfig,lipsum}
\graphicspath{{../figs/}}
\usepackage{pdfcomment}
\usepackage{geometry}
\newgeometry{left=2.5cm,right=2.5cm,bottom=2.5cm}
\usepackage[english]{babel}
\usepackage{CJKutf8}
\pagestyle{headings}
\usepackage{blindtext}
\usepackage{csquotes}
\setcounter{secnumdepth}{4}
\usepackage{titlesec}
\usepackage[T1]{fontenc}
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index]
\usepackage{array}
\usepackage{tikzpagenodes}
\usepackage[format=plain, labelfont={bf,it}, textfont=it]{caption}
\usepackage{fancyhdr}
\usepackage[toc,nopostdot, nonumberlist,style=long,automake,acronym]{glossaries}
\usepackage{subfiles}
\usepackage{nicematrix}
\usepackage{amsmath,mathabx}
\usepackage{hyperref}
\usepackage{lscape}
\newcommand{\sectionbreak}{\phantomsection}
\hypersetup{
colorlinks=true,
linkcolor=black,
filecolor=black,
urlcolor=black,
citecolor=olive,
pdftitle={PhD Dissertation},
pdfpagemode=FullScreen,
}
\urlstyle{same}
%\bibliographystyle{abbrvnat}
%\usepackage[authoryear]{natbib}%/bibliography apa
%\setcitestyle{authoryear,open={(},close={)}} %Citation-related commands
The bibliography file called bib.bib
Example:
#article{henriquez_alternative_2017,
title = {An alternative objective microscopic method for the identification of linear enamel hypoplasia ({LEH}) in the absence of visible perikymata},
volume = {14},
doi = {10.1016/j.jasrep.2017.05.040},
journal = {Journal of Archaeological Science: Reports},
author = {Henriquez, Alejandra Cares and Oxenham, Marc F.},
year = {2017},
pages = {76--84},
file = {Full Text:C\:\\Users\\xello\\Zotero\\storage\\MV7QMSWQ\\Henriquez and Oxenham - 2017 - An alternative objective microscopic method for th.pdf:application/pdf},
}
Example of text citing something
\begin{document}
\begin{CJK*}{UTF8}{min}
\citep{henriquez_alternative_2017}, \citet{henriquez_alternative_2017}.
\end{CJK*}
\end{document}
I need to change the citation style to apa6: https://www.ctan.org/pkg/apa6. When Io tried to add this package. It entered into conflict with other packages like titlesec and amsmath, mathabx.
I get errors like
...ex/titlesec/titlesec.sty, 1642. Argument of \subparagraph has an
extra }. or Runaway argument?
or
eric/mathabx/mathabx.sty, 67. Latex Error: Too many symbol fonts
declared.
respectively.
I am not sure how to add this citation style to my current project. Maybe there is an alternative way? I need the packages I am using (like titlesec) to order my document.
Any help will be welcomed.
Thank you,

[EDIT] Solved it. I used Biblatex (https://ctan.org/pkg/biblatex-apa6?lang=en) which also has an apa6 option. Solved additional errors. Works well.

Related

No control sequence/no counter subfigure#save defined

I am new to overleaf. I am getting first 'No control sequence' on \subfloat. Then I included \usepackage{subfig} which is causing this new error 'no counter subfigure#save defined' on the same line. Along with that after including this package I am also getting 'Undefined control sequence' on \begin{document}. Any idea how can I tackle this? I want to insert multiple figures and I read that \subfigures is outdated and I should include subfloat instead. I would really really appreciate any possible help. Thank you
screenshoot of error
These are the packages that are included :
\documentclass[a4paper, 12pt, oneside]{Thesis} % Use the "Thesis" style, based on the ECS Thesis style by Steve Gunn
\usepackage{subfig}
\usepackage{graphicx}
%\usepackage[dvipsnames]{xcolor}
\graphicspath{ {images/} }
\usepackage{amsmath}
% Include any extra LaTeX packages required
\usepackage[square, numbers, comma, sort&compress]{natbib} % Use the "Natbib" style for the references in the Bibliography
\usepackage{verbatim} % Needed for the "comment" environment to make LaTeX comments
\usepackage{vector} % Allows "\bvec{}" and "\buvec{}" for "blackboard" style bold vectors in maths
\hypersetup{urlcolor=red, colorlinks=false} % Colours hyperlinks in blue, but this can be distracting if there are many links.
\usepackage{longtable}
\usepackage[table]{xcolor}
\usepackage[textsize=tiny]{todonotes}
\newcommand{\dara}{\textsf{da\textbar ra}}
\usepackage{csquotes}
\usepackage{ctable}
\usepackage{titlesec}
\usepackage[most]{tcolorbox}
\usepackage{tikz-er2}
\usepackage{url}
\usepackage{paralist}
\usepackage{pifont}
\usepackage{adjustbox}
\usepackage[T1]{fontenc}
\usepackage[scaled=0.85]{beramono}
\usepackage{listings}
\usepackage{tikz}
\usepackage{3dplot}
\usepackage{framed}
\usepackage{tabularx}
\usepackage{hyperref}
\usepackage{todonotes}
\usepackage{comment}
\usepackage{pifont}
\usepackage{amssymb}
\setcounter{tocdepth}{3}
\usepackage{multirow}
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algorithmic}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepackage{eurosym} %<-- For EURO symbol
\usepackage{filecontents}
\usepackage{minted}
\usemintedstyle{monokai}
\usepackage{array}
% \usepackage{forest}
\usepackage[table]{xcolor}

Why is hyperref package causing an issue with \footnotemark?

I had recently posted a question seeking help for linking a glossary in a specific way and it was resolved, thanks to #samcarter_is_at_topanswers.xyz for helping me out. url to the post
Now, going ahead with the suggestions, I make use of \hyperref package in my project and that is causing an issue with the use of \footnotemark[]. I have attached the screenshots below along with a MWE.
Screenshots :
With the hyperref package I get the error :
Without the hyperref package I get the output with no errors :
MWE :
\documentclass{article}
\usepackage[utf8]{inputenc} % Input encoding (this file): 8 bit unicode. Default by most text editors
\usepackage[T1]{fontenc} % Output encoding (pdf file)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Packages used in the example
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx} % Included graphics and some resizable boxes
\usepackage{url} % nice urls with line breaks
\usepackage{lipsum} % nonsense text blocks
\usepackage{float}
\usepackage{subcaption}
\usepackage{multicol}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{biblatex}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[nonumberlist,acronym,
entrycounter=true
]{glossaries}
\makeglossaries
\newglossaryentry{vp}
{
name= Verification Plan,
description={A verification plan is a list of the procedures and methods to be used for verification}
}
\newacronym{ml}{ML}{Machine Learning}
%%UNCOMMENT THIS AND THERE IS AN ERROR WITH GLOSSARY
%\usepackage{hyperref}
%\hypersetup{
% citecolor=black,
% colorlinks=false, %set true if you want colored links
% linktoc=all, %set to all if you want both sections and subsections linked
% linkcolor=black, %choose some color if you want links to stand out
%}
\begin{document}
%\glsaddall
\setglossarystyle{altlist}
\printglossary
\printglossary[type=\acronymtype]
------
\textbf{Develop}: The develop phase includes \gls{vp}\footnotemark[\glsrefentry{vp}], creating verification environment, testbench and test case development. \acrfull{ml}
\end{document}
So in short, I want to have my glossary hyperlinked along with referencing it by using \footnotemark[\glsrefentry....].
Any solution/advice would be greatly appreciated! Thanks in advance!
With hyperref, the \glsrefentry{...} macro is a link to your list of acronyms, which conflicts with using it as a footnotemark. You can use e.g. \textsuperscript{...} as a workaround:
\documentclass{article}
\usepackage[utf8]{inputenc} % Input encoding (this file): 8 bit unicode. Default by most text editors
\usepackage[T1]{fontenc} % Output encoding (pdf file)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Packages used in the example
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx} % Included graphics and some resizable boxes
\usepackage{url} % nice urls with line breaks
\usepackage{lipsum} % nonsense text blocks
\usepackage{float}
\usepackage{subcaption}
\usepackage{multicol}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{biblatex}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[nonumberlist,acronym,
entrycounter=true
]{glossaries}
\makeglossaries
\newglossaryentry{vp}
{
name= Verification Plan,
description={A verification plan is a list of the procedures and methods to be used for verification}
}
\newacronym{ml}{ML}{Machine Learning}
%UNCOMMENT THIS AND THERE IS AN ERROR WITH GLOSSARY
\usepackage{hyperref}
\hypersetup{
citecolor=black,
colorlinks=false, %set true if you want colored links
linktoc=all, %set to all if you want both sections and subsections linked
linkcolor=black, %choose some color if you want links to stand out
}
\begin{document}
\glsaddall
\setglossarystyle{altlist}
\printglossary
\printglossary[type=\acronymtype]
------
\textbf{Develop}: The develop phase includes \gls{vp}\textsuperscript{\glsrefentry{vp}}, creating verification environment, testbench and test case development. \acrfull{ml}
\end{document}

Why Figure is not displayed in the latex file and text is shown instead of it

I am newbie in latex and trying to add figure into the latex file as follows:
\documentclass{bmcart}
%%% Load packages
\usepackage{amsthm,amsmath}
\usepackage[utf8]{inputenc} %unicode support
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{graphicx}
\def\includegraphic{}
\def\includegraphics{}
\startlocaldefs
\endlocaldefs
\begin{document}
\begin{figure}[h!]
\includegraphics{figures/GBMfigure3.jpg}
\caption{show the results of the different settings for the parameters of the penalty model for solving the problem \ref{q11}.}
\end{figure}
\end{document}
But, the figure is not displayed and the text itself is displayed instead of the figure, for example the resulted file is as below:
So, what's the solution of that issue please.
With \def\includegraphics{} you redefine the command to do nothing. If you want it to include your image, don't do such a redefinition.
\documentclass{bmcart}
%%% Load packages
\usepackage{amsthm,amsmath}
\usepackage[utf8]{inputenc} %unicode support
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{graphicx}
%\def\includegraphic{}
%\def\includegraphics{}
\startlocaldefs
\endlocaldefs
\begin{document}
\begin{figure}[h!]
\includegraphics{example-image-duck}
\caption{show the results of the different settings for the parameters of the penalty model for solving the problem \ref{q11}.}
\end{figure}
\end{document}

Citation not getting displayed - instead the alias is getting displayed in the pdf

I am trying to use \cite to cite items from bibliography.bib. However, my citations are not working properly.
The environment, code and output are as below:
\documentclass[12pt]{article}
\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref,booktabs,dcolumn,threeparttable, adjustbox,apacite,dirtytalk,multirow,tabularx,booktabs,longtable,lscape,placeins,tikz}
\usepackage[backend=biber,natlib,style=author-year,citestyle=authoryear]{biblatex}
\usepackage{ulem}
\usepackage{float}
\restylefloat{table}
\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.9}
\usepackage{pst-func}
\psset{unit=2cm}
\usepackage{hyperref}
\hypersetup{colorlinks=true,urlcolor=blue,citecolor=blue,linkcolor=red}
\usepackage[center]{caption}
\usepackage{setspace}
\usepackage{epsfig}
\usepackage{graphics}
\usepackage{lscape}
\usepackage[english]{babel}
\usepackage{color}
\addbibresource{bibfile.bib}
\begin{document}
This is a \cite{sample}.
\end{document}
The cite takes reference from my .bib file, which is in the same folder. Here I have attached a sample citation.
#article{sample,
title={What is the price elasticity of housing demand?},
author={Hanushek, Eric A and Quigley, John M},
journal={The Review of Economics and Statistics},
pages={449--454},
year={1980},
publisher={JSTOR}
}
The output that I am getting looks like
Author Year with year linking to the bibliography section. However, I want it like Author, Year with the entire phrase linking to the bibliography section
Could you please help me with this issue?
Thank You :)
P.S. : I know my environment is not perfect. It has some packages repeated twice. :)
NEVER IGNORE ERROR MESSAGES! After an error, latex only recovers enough to syntax check the rest of the document. There is no point at even looking at what might or might not be valid output while there are still errors!
There are several major problems:
don't load packages multiple times and in particular don't load them multiple times with different options. An error message in the log file will explicitly tell you about the option clash
don't load incompatible package like apacite and biblatex in the same document. An error message in the log file with explicitly tell you that these two packages are not compatible
the biblatex option is called natbib, not natlib. An error message will explicitly tell you that it does not know the option natlib
the biblatex style is called authoryear, not author-year. An explicit error message will tell you that author-year style is not found
... and then there are many other duplicate, unnecessary or obsolete packages. You should clean up your preamble and only load the packages you need. Also hyperref should be loaded after the other packages.
\documentclass[12pt]{article}
\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,
%hyperref,
booktabs,dcolumn,threeparttable, adjustbox,
%apacite,
dirtytalk,multirow,tabularx,booktabs,longtable,
%lscape,
placeins,tikz}
\usepackage[backend=biber,natbib,style=authoryear,citestyle=authoryear]{biblatex}
%\usepackage{ulem}
\usepackage{float}
\restylefloat{table}
\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.9}
\usepackage{pst-func}
\psset{unit=2cm}
%\usepackage{hyperref}
%\usepackage[center]{caption}
%\usepackage{setspace}
%\usepackage{epsfig}
%\usepackage{graphics}
%\usepackage{lscape}
\usepackage[english]{babel}
%\usepackage{color}
\usepackage{hyperref}
\hypersetup{colorlinks=true,urlcolor=blue,citecolor=blue,linkcolor=red}
\begin{filecontents*}[overwrite]{\jobname.bib}
#article{sample,
title={What is the price elasticity of housing demand?},
author={Hanushek, Eric A and Quigley, John M},
journal={The Review of Economics and Statistics},
pages={449--454},
year={1980},
publisher={JSTOR}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
This is a \cite{sample}.
\end{document}

Getting error in latex while creating report

I am writing a report in latex but getting the following error. Following is my code......
\documentclass[a4paper,10pt]{report}
\usepackage{enumerate}
\usepackage{devanagari}
\usepackage{fancyhdr}
\usepackage{fancybox}
\usepackage{tipa}
\usepackage{enumerate}
\usepackage{fancyhdr}
\usepackage{fancybox}
\usepackage{tipa}
\usepackage{framed}
\usepackage[retainorgcmds]{IEEEtrantools}
\usepackage[utf8x]{inputenc}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{subscript}
\usepackage{epsfig}
\usepackage{anysize}
\usepackage{gensymb}
\usepackage{amssymb}
\usepackage[utf8x]{inputenc}
\usepackage{longtable}
\usepackage{url}
\usepackage{plain}
\usepackage{listings}
\usepackage[plainpages=false]{hyperref}
\lhead{}
% Title Page
\title{}
\author{}
\begin{document}
\maketitle
\begin{abstract}
\end{abstract}
\end{document}
But I am getting the following error
If anyone know the answer, please tell me.
The problem is caused by the interaction of the devanagari and hyperref packages. Leave one of them out and it works.
You need to update devangari to at least version 2.15. That should fix it.
BTW, you've included several packages two times in the code above. And you're using both graphics and graphicx; you should choose one. Probably graphicx, since you also want to use epsfig.
In general, questions like these are better suited for tex.stackexchange.com.

Resources