I am writing my PhD dissertation, and I am trying to cite a reference as part of the sentence in such a way that the last name of author is followed by the year in parenthesis:
for single author
Author (year)
or for two authors
Author1 and Author2 (year)
or for more than two authors
Author et al. (year)
I tried to use \citet
and it does not work with even using natbib. I get the following error
Package etoolbox Error: Boolean '\ifcbx:np' undefined.
I am using the package biblatex with natbib as follows:
\usepackage[
style=authoryear,
natbib=true,
backend=biber,
dashed=false,
isbn = false,
doi = false,
url = false,
language=auto,
sorting=nyt,
maxbibnames=99,
maxcitenames=2,
uniquelist=false,
uniquename=false]{biblatex}
The following are the packages I am using
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{etoolbox}
\usepackage{booktabs}
\usepackage{bm}
\usepackage{float}
\usepackage{subfig}
\usepackage{setspace}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[hyperfootnotes=false,english,colorlinks]{hyperref}
\usepackage{url}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{array}
\usepackage[normalem]{ulem}
An example I have now
For the former, \cite{basu2017} invoked the notion of a metric..
Output:
Basu et al., 2017
Desired Output:
Basu et al. (2017)
I figured the error was coming from using this macro to link both author and year
% long syntax to link both author & year in in-text citation
\makeatletter
\newbibmacro{cite:plabelyear+extradate}{%
\iffieldundef{labelyear}{}
{\clearfield{labelmonth}% don't want months in citations
\clearfield{labelday}% don't want days in citations
\clearfield{labelendmonth}% don't want months in citations
\clearfield{labelendday}% don't want days in citations
\iffieldsequal{labelyear}{labelendyear}% Don't want no-op year ranges
{\clearfield{labelendyear}}
{}%
\iffieldundef{origyear}
{}
{\printorigdate%
\setunit*{\addslash}}%
\iffieldundef{related}
{}
{\iffieldequalstr{relatedtype}{reprintfrom}
{\entrydata*{\thefield{related}}{\printlabeldateextra}%
\setunit*{\addslash}}
{}}%
\printlabeldateextra}}
\renewbibmacro*{cite}{%
\iffieldequals{fullhash}{\cbx@lasthash}
{\setunit{\compcitedelim}%
\printtext[bibhyperref]{%
\usebibmacro{cite:plabelyear+extradate}}}%
{\printtext[bibhyperref]{%
\ifnameundef{labelname}
{\usebibmacro{cite:noname}%
\setunit{\printdelim{nameyeardelim}}%
\usebibmacro{cite:plabelyear+extradate}%
\savefield{fullhash}{\cbx@lasthash}}
{\ifnameundef{shortauthor}
{\printnames{labelname}}%
{\cbx@apa@ifnamesaved
{\printnames{shortauthor}}
{\ifnameundef{groupauthor}
{\printnames[labelname]{author}}
{\printnames[labelname]{groupauthor}}%
\addspace\printnames[sabrackets]{shortauthor}}}%
\setunit{\printdelim{nameyeardelim}}%
\usebibmacro{cite:plabelyear+extradate}%
\savefield{fullhash}{\cbx@lasthash}}}}%
\setunit{\multicitedelim}}
\renewbibmacro*{textcite}{%
\iffieldequals{fullhash}{\cbx@lasthash}
{\setunit{\compcitedelim}%
\printtext[bibhyperref]{%
\usebibmacro{cite:plabelyear+extradate}}}
{%
\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\setunit{\compcitedelim}%
\ifnameundef{labelname}
{\iffieldundef{shorthand}%
{\printtext[bibhyperref]{%
\usebibmacro{cite:noname}}%
\setunit{\ifbool{cbx:np}%
{\printdelim{nameyeardelim}}%
{\global\booltrue{cbx:parens}\addspace\bibopenparen}}%
\printtext[bibhyperref]{%
\usebibmacro{cite:plabelyear+extradate}}}
{\printtext[bibhyperref]{%
\usebibmacro{cite:shorthand}}}}
{\printtext[bibhyperref]{%
\ifnameundef{shortauthor}%
{\printnames{labelname}}
{\cbx@apa@ifnamesaved
{\printnames{shortauthor}}
{\ifnameundef{groupauthor}
{\printnames[labelname]{author}}
{\printnames[labelname]{groupauthor}}}}}%
\setunit{\ifbool{cbx:np}
{\printdelim{nameyeardelim}}
{\global\booltrue{cbx:parens}\addspace\bibopenparen}}%
\printtext[bibhyperref]{%
\ifnameundef{shortauthor}
{}
{\cbx@apa@ifnamesaved
{}
{\printnames{shortauthor}\setunit{\printdelim{nameyeardelim}}}}%
\usebibmacro{cite:plabelyear+extradate}}%
\savefield{fullhash}{\cbx@lasthash}}}}
\makeatother
How should I modify the above to make \citet work? (\citep works)