suchow / Dissertate

Beautiful LaTeX dissertation templates.
GNU Affero General Public License v3.0
714 stars 164 forks source link

Apa style citation #62

Open JuanLinaresLanzman opened 7 years ago

JuanLinaresLanzman commented 7 years ago

I'm looking for the command to use "apa style" citation instead of the citation based on numbers with hiperlinks.

Thanks in advance

aminmkhan commented 7 years ago

Ask on http://tex.stackexchange.com/. I switched to using BibLaTeX, for example.

fredcallaway commented 2 years ago

In Dissertate.cls, simply replace \RequirePackage[super,comma,numbers]{natbib} with \RequirePackage{natbib}. You may want to adjust the color of the citations (search for citecolor=). Finally, if you want a single link for each citation (rather than separate links on author and year) you can use this hack: https://tex.stackexchange.com/a/27235

Specifically, paste this at the bottom of Dissertate.cls

\usepackage{etoolbox}
\makeatletter

\pretocmd{\NAT@citex}{%
  \let\NAT@hyper@\NAT@hyper@citex
  \def\NAT@postnote{#2}%
  \setcounter{NAT@total@cites}{0}%
  \setcounter{NAT@count@cites}{0}%
  \forcsvlist{\stepcounter{NAT@total@cites}\@gobble}{#3}}{}{}
\newcounter{NAT@total@cites}
\newcounter{NAT@count@cites}
\def\NAT@postnote{}

% include postnote and \citet closing bracket in hyperlink
\def\NAT@hyper@citex#1{%
  \stepcounter{NAT@count@cites}%
  \hyper@natlinkstart{\@citeb\@extra@b@citeb}#1%
  \ifnumequal{\value{NAT@count@cites}}{\value{NAT@total@cites}}
    {\ifNAT@swa\else\if*\NAT@postnote*\else%
     \NAT@cmt\NAT@postnote\global\def\NAT@postnote{}\fi\fi}{}%
  \ifNAT@swa\else\if\relax\NAT@date\relax
  \else\NAT@@close\global\let\NAT@nm\@empty\fi\fi% avoid compact citations
  \hyper@natlinkend}
\renewcommand\hyper@natlinkbreak[2]{#1}

% avoid extraneous postnotes, closing brackets
\patchcmd{\NAT@citex}
  {\ifNAT@swa\else\if*#2*\else\NAT@cmt#2\fi
   \if\relax\NAT@date\relax\else\NAT@@close\fi\fi}{}{}{}
\patchcmd{\NAT@citex}
  {\if\relax\NAT@date\relax\NAT@def@citea\else\NAT@def@citea@close\fi}
  {\if\relax\NAT@date\relax\NAT@def@citea\else\NAT@def@citea@space\fi}{}{}

\makeatother
philip-ndikum commented 1 year ago

Can anyone else help here? Switching citation styles, \citeauthor or cite title do not work for me.

fredcallaway commented 1 year ago

Not sure if this will help, but my dissertation has APA citations (I think): https://github.com/fredcallaway/dissertation

I did notice that I have \bibliographystyle{apalike2} in my dissertation.tex. And as I said above I removed options to natbib in DIssertate.cls so it's just \RequirePackage{natbib}