[Tex/LaTex] change authoryear biblatex citation style

biblatexciting

I'd like to change the authoryear citations using \parencite, so that authors appear as:

(AUTHOR, year) and/or (AUTHOR, year, p.) (one page) (AUTHOR, year, pp.) (multiple pages)

So far I managed to change last names to uppercase (not my choice, but I'm trying to implements this) in citations and in the bibliography using:

\renewcommand{\mkbibnamefirst}[1]{\MakeUppercase{#1}}
\renewcommand{\mkbibnamelast}[1]{\MakeUppercase{#1}}
\renewcommand{\mkbibnameprefix}[1]{\MakeUppercase{#1}}
\renewcommand{\mkbibnameaffix}[1]{\MakeUppercase{#1}}


\DeclareNameFormat{author}{%
\ifthenelse{\value{listcount}=1}
{\MakeUppercase{#1}%
\ifblank{#3}{}{\addcomma\space #3}}
{\ifblank{#3}{}{#3\space}%
\MakeUppercase{#1}}%
\ifthenelse{\value{listcount}<\value{liststop}}
{\addcomma\space}
{}}

I have also tried to change multi-author delimiters in-text \parencite citations using

\renewcommand*{\finalnamedelim}{;\space}
\renewcommand*{\multicitedelim}{;\space}

So that references look like:

(AUTHOR1; AUTHOR2; AUTHOR3, year).

But it didn't work.

I would also like to set all multi-author names as last-first in the references list, separated by semicolons, but the following didn't work either:

\DeclareNameAlias{sortname}{last-first}

I'm using the following in my preamble:

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{EB Garamond}
\setsansfont{Candara}
\setmonofont{Consolas}
\usepackage{polyglossia}
\setmainlanguage{brazil}
\usepackage{csquotes}
\usepackage[style=historian,doi=false,citestyle=authoryear]{biblatex}

\DefineBibliographyStrings{brazil}{namedash={---},volumeof={de},url={Disponível em: }}

\renewcommand{\mkbibnamefirst}[1]{\MakeUppercase{#1}}
\renewcommand{\mkbibnamelast}[1]{\MakeUppercase{#1}}
\renewcommand{\mkbibnameprefix}[1]{\MakeUppercase{#1}}
\renewcommand{\mkbibnameaffix}[1]{\MakeUppercase{#1}}


\DeclareNameFormat{author}{%
\ifthenelse{\value{listcount}=1}
{\MakeUppercase{#1}%
\ifblank{#3}{}{\addcomma\space #3}}
{\ifblank{#3}{}{#3\space}%
\MakeUppercase{#1}}%
\ifthenelse{\value{listcount}<\value{liststop}}
{\addcomma\space}
{}}

Best Answer

I do not know what the historian style is (it's not a standard one), but I see you use citestyle=authoryear anyway, so this should be the same.

The example below does what you want, I believe. It uses the biblatex example bibliography. Note that some years have letters after them, this happens when the same author has several works in the same year.

\documentclass{article}
\usepackage[style=authoryear, backend=biber]{biblatex}
% \renewcommand{\mkbibnamefirst}[1]{\MakeUppercase{#1}}
% \renewcommand{\mkbibnamelast}[1]{\MakeUppercase{#1}}
% \renewcommand{\mkbibnameprefix}[1]{\MakeUppercase{#1}}
% \renewcommand{\mkbibnameaffix}[1]{\MakeUppercase{#1}}
\renewcommand*{\nameyeardelim}{\addcomma\addspace}


\newbibmacro*{cite_p}{%adapted from authoryear.cbx
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}%
       {\usebibmacro{cite:label}%
        \setunit{\addspace}}%
       {\printnames[labelname_p]{labelname}%
        \setunit{\nameyeardelim}}%
     \usebibmacro{cite:labelyear+extrayear}%
     \iffieldundef{pages}%
         {}%
         {\addcomma\addspace\printfield{pages}}%
   }
   {\usebibmacro{cite:shorthand}}}

\DeclareCiteCommand{\parencite}[\mkbibparens]%adapted from authoryear.cbx
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite_p}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareNameFormat{labelname_p}{%from biblatex.def
  \ifcase\value{uniquename}%
    \usebibmacro{name:last}{\MakeUppercase{#1}}{#3}{#5}{#7}%
  \or
    \ifuseprefix
      {\usebibmacro{name:first-last}{\MakeUppercase{#1}}{#4}{#5}{#8}}
      {\usebibmacro{name:first-last}{\MakeUppercase{#1}}{#4}{#6}{#8}}%
  \or
    \usebibmacro{name:first-last}{\MakeUppercase{#1}}{#3}{#5}{#7}%
  \fi
  \usebibmacro{name:andothers}}

\addbibresource{biblatex-examples.bib}
\addbibresource{test.bib}


\begin{document}

\begin{itemize}
\item Year and pages \parencite{nietzsche:historie}.
\item Two inbook with year and pages \parencite{nietzsche:historie, brandt} 
\item A book with no pages \parencite{massa}
\item textcite on a book with no pages \textcite{massa}.
\item Several books \parencite{murray, augustine, cotton, bertram, massa}.
\item Article with single page \parencite{art1}
\item textciting  \textcite{nietzsche:historie, brandt}
\end{itemize}

\nocite{*}
\printbibliography

\end{document}

enter image description here


Explanation

If you want to know the nitty gritty, compare what I have here with what's in authoryear.cbx, you should see what I changed. However, in short:

  1. \renewcommand*{\nameyeardelim}{\addcomma\addspace} to make sure name and year are separated by a space and a comma
  2. Made new citation macro cite_p, basically a copy of cite, but added the pages bit at the end
  3. Redefine parencite to use our custom cite_p.
  4. 3+4 ensure that other citation commands are unchanged.

Update

Fixed some bugs, as per comments below

enter image description here

Related Question