[Tex/LaTex] Using APA style referencing in elsarticle class document

apa-stylebibtexluatexlyx

Ive just had my paper sent back to me by the editor of a journal I submitted to and was instructed to change the referencing system of my paper to APA ver. 6 style.

Text: Citations in the text should follow the referencing style used
by the American Psychological Association. You are referred to the
Publication Manual of the American Psychological Association, Sixth
Edition, ISBN 978-1-4338-0561-5. APA's in-text citations require the
author's last name and the year of publication. You should cite
publications in the text, for example, (Smith, 2016). However, you
should not use [Smith, 2016].

I'm using LyX and tried adding \usepackage{apacite} but it gave way too many errors. I tried searching for a solution and came across this question: apacite not working in tex

Based on the answer there I added authoryear in the document class and added the line \usepackage{apalike} and \bibliographystyle{apalike}.

This time the document compiled without errors but the referencing within text ins not APA. I should be getting

(Smith, 2016)

however all my within text references are:

Smith (2016)

Would appreciate some help here.

MWE below:

\documentclass[12pt,5p,times,twocolumn,authoryear]{elsarticle}
\usepackage[latin9]{inputenc}
\usepackage{array}
\usepackage{verbatim}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}

\makeatletter
\usepackage{apalike}
\@ifundefined{showcaptionsetup}{}{%
 \PassOptionsToPackage{caption=false}{subfig}}
\usepackage{subfig}
\makeatother

and

\bibliographystyle{apalike}

and a reference from my bib file:

 % This file was created with JabRef 2.11.
% Encoding: Cp1252


@InProceedings{Xiong2015,
  Title                    = {Text-independent writer identification using SIFT descriptor and contour-directional feature},
  Author                   = {Xiong, Yu-Jie and Wen, Ying and Wang, Patrick SP and Lu, Yue},
  Booktitle                = {Document Analysis and Recognition (ICDAR), 2015 13th International Conference on},
  Year                     = {2015},
  Pages                    = {91--95},
  Publisher                = {IEEE}
}

Best Answer

I managed to get the desired result. In LyX click on the reference within the text and change the way its displayed in "formatting".

In LaTeX, this can be achieved by using \citep instead of cite