6

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}
{}}
  • To clarify, you want to change bibliography as well or just \parencite ? If you modify mkbibnamefirst and so on, you will also modify the bibliography. Also, a full MWE, i.e. one with \begin{document} etc. would be quite helpful. – ach Jun 2 '13 at 16:03
  • Yes, it's just \parencite. Behavior in the bibliography looks ok. I don't want \textcite to change. – Joseph Jun 2 '13 at 16:39
  • What are you trying to achieve with DeclareNameFormat... ? #3 is the author firstname, what are you trying to do there ? MakeUppercase in that context seems superfluous given the earlier definition. – ach Jun 2 '13 at 17:02
  • DeclareNameFormat was supposed to turn into uppercase last names in bibliography. – Joseph Jun 2 '13 at 17:11
5

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

  • Thanks! This works just fine. However, I needed the textcite command to remain the same, namely: "Author (year)." (author not in uppercase). But that's fine. The "historian" style is used just because it puts years where I want them: as the last part of the bibliography entry, and not like "Surname, Name (2000)." What the historian style does (in the bibliography) is "Surname, Name. Title (italics). Place: Publisher, Year." – Joseph Jun 2 '13 at 21:16
  • I have just found that in the bibliography, last names and first names are in uppercase, so I just commented: %\renewcommand{\mkbibnamefirst}[1]{\MakeUppercase{#1}} %\renewcommand{\mkbibnamelast}[1]{\MakeUppercase{#1}} – Joseph Jun 2 '13 at 21:23
  • @Joseph I edited the code, it should now only uppercase the last name of authors that are \parencited. – ach Jun 2 '13 at 21:42
  • That's great ach! I just commented out the code \printfield{pages} (just want total page range in articles etc. to show in the bibliography, as usual). – Joseph Jun 3 '13 at 0:21
  • Only one caveat: as you can see above, there is a space between the year and the parenthesis in (MASSA, 2004 ). And in all other citations when I remove \addcomma\addspace\printfield{pages}. I couldn't figure out what is causing this space. – Joseph Jun 3 '13 at 0:33
3

Since you're making only small changes to an existing citation command, the \AtNextCite hook comes in handy:

\let\origparencite\parencite
\let\origparencites\parencites

\newrobustcmd*{\parencitehook}{%
  \AtNextCite{%
    \renewcommand*{\nameyeardelim}{\addcomma\addspace}%
    \renewcommand*{\mkbibnamelast}[1]{\MakeUppercase{##1}}}}

\renewrobustcmd*{\parencite}{\parencitehook\origparencite}
\renewrobustcmd*{\parencites}{\parencitehook\origparencites}

The advantage to this approach is that it should work for any of the author-year styles.

  • your solution works nice, too. – Joseph Jun 3 '13 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.