2

For my thesis I am required to cite the authors as :

 Some text form Author (2013) says that etc

However when citing more than one source the format should be

Some statement dictates such and such [Author I (2012), Author 2 et al. (2005)] 

I am using biblatex to generate my Bibliography.

The biblatex configuration is

\usepackage[
        natbib=true,
        citestyle=authoryear-comp,
        bibstyle=authoryear,
        hyperref=false,
        backend=biber,
        maxbibnames=99,
        uniquename=false,
        maxcitenames=1,
        dashed=false,
        url=false,
        doi=false,
        isbn=false,
        eprint=false,
            ]{biblatex}

\renewcommand{\cite}{\textcite} 

\DeclareFieldFormat[article]{volume}{\textbf{#1}\addcolon\space}

% remove "in:" from articles. 
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{%
  \printtext{\bibstring{in}\intitlepunct}}}

So my obvious question is how to achieve the brackets when citing multiple sources?

lockstep
  • 250,273
wierts
  • 887
  • Would adding \newcommand{cite2}[2]{[\cite{#1}, \cite{#2}]} to your .tex work? It seems right, but I can't test it right now to be sure. – SnoringFrog Nov 07 '13 at 15:02
  • @SnoringFrog For the moment this does not seem to do the trick, I kind of was hoping for a bit more robust solution. One where i did not have to manually change the cite command since i allready have about 100 pages of text..... – wierts Nov 07 '13 at 15:28
  • @SnoringFrog, it seems to me that would work for exactly 2 citations, but for the general case you could need many more – Chris H Nov 07 '13 at 15:28

1 Answers1

3

In biblatex multiple citations can be made in two ways: 1) with traditional commands like \textcite{key1,key2,...} and 2) with 'multicite' commands like \textcites{key1}{key2}... (I'm omitting pre- and postnotes since they are probably not useful in textcite-like commands; but you can use them, see the biblatex manual). So we need to adjust these commands. But the point is that \textcite(s) --- unlike \cite(s),\parencite(s) etc. --- are designed so that it's difficult (or impossible?) to redefine them directly. But we can change some internals.

First we need to define a wrapper to avoid brackets when there is only one entrykey:

\newcommand*{\mywrapper}[1]{%
  \ifthenelse{\value{textcitetotal}>1}
    {\mkbibbrackets{#1}}
    {#1}}

Then, for the first case we do:

\makeatletter
\DeclareCiteCommand{\cbx@textcite}[\mywrapper]
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite:postnote}}
\makeatother

And for the second (which is more preferable, I believe):

\makeatletter
\DeclareMultiCiteCommand{\cbx@textcites}[\mywrapper]{\cbx@textcite}{} 
\makeatother

To change the delimiter (if you need this):

\renewcommand*{\textcitedelim}{\addcomma\space}

A short MWE:

\documentclass{article}

\usepackage[
        natbib=true,
        citestyle=authoryear-comp,
        bibstyle=authoryear,
        hyperref=false,
        backend=biber,
        maxbibnames=99,
        uniquename=false,
        maxcitenames=1,
        dashed=false,
        url=false,
        doi=false,
        isbn=false,
        eprint=false,
]{biblatex}
\bibliography{biblatex-examples.bib}

\renewcommand*{\textcitedelim}{\addcomma\space}% if you want another delimiter

\newcommand*{\mywrapper}[1]{%
    \ifthenelse{\value{textcitetotal}>1}
    {\mkbibbrackets{#1}}
    {#1}}

\makeatletter
\DeclareMultiCiteCommand{\cbx@textcites}[\mywrapper]{\cbx@textcite}{} 

\DeclareCiteCommand{\cbx@textcite}[\mywrapper]
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite:postnote}}

\makeatother

\begin{document}
\textcites{knuth:ct}
\par\textcites{stdmodel}{knuth:ct}{doody}
\par\textcite{knuth:ct}
\par\textcite{stdmodel,knuth:ct,doody}
\end{document} 
Oleg Domanov
  • 1,496
  • I was not aware of the difference between \textcite and \textcites. I always used the first. However elegant you proposal is, there is one thing that is not going as i am required to. When having a singe \textcite the in text citation should not have the brackets. When i try yours it does.... – wierts Nov 08 '13 at 09:26
  • Ah, yes, my fault... And now? Is it still elegant enough? (I edited the answer) – Oleg Domanov Nov 08 '13 at 10:17
  • Brilliant, works like a charm! – wierts Nov 11 '13 at 11:45
  • Glad to hear))) – Oleg Domanov Nov 11 '13 at 16:20