3

I am very new to LaTeX as you will see from my crude MWE. I have spent a lot of time tweaking biblatex to how I need it to look. I have one final problem, I can not find a work around and can't find a solution on the site.

I would like to show an "and" for my \textcite when there are multiple authors, which it currently does. Although I would like to have "&" for my \parencite with multiple authors. I would also like to have my bibliography showing "&".

Please find MWE and any help would be appreciated.

\documentclass[12pt, twoside]{report}
\usepackage{filecontents}
\usepackage[%
    backend=biber,
    style=authoryear,
    uniquename=init,giveninits,giveninits=true, terseinits=true,hyperref]{biblatex}
\usepackage{xpatch}

\DeclareNameAlias{sortname}{last-first}%Surname first

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 %\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  %\addspace\&\space}

\newcommand{\biband}{\ifcurrentname{labelname}{\bibstring{and}}{\&}}

\renewcommand*{\finalnamedelim}{%
   \ifnumgreater{\value{liststop}}{4}{\finalandcomma}{}%
   \addspace\biband\space}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\renewcommand{\labelnamepunct}{\addcomma\addspace}%Sets comma
\renewcommand*{\newunitpunct}{\addcomma\space}%Sets commas


\setlength{\bibhang}{0em}%remove indent
\setlength\bibitemsep{\baselineskip}% add vertical space

\begin{filecontents}{\jobname.bib}
@article{test,
 author = "Family, Given and Second, A and Given, Two",
 title = "title",
 journal = "Journal",
 year = "2012"}

 @Article{leis2016,
  Title                    = {A Temperature Compensation Technique for Near-Infrared Methane Gas Threshold Detection},
  Author                   = {J. Leis and D. Buttsworth},
  Journal                  = {{IEEE} Trans. Ind. Electron.},
  Year                     = {2016},
  Month                    = mar,
  Number                   = {3},
  Pages                    = {1813--1821},
  Volume                   = {63},
  File                     = {ieeetie-2016.pdf:PDF},
}

\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}


I would like to use {\bfseries ``\&''} within the {\bfseries bibliography}. \\
I would like to use {\bfseries ``and''} in {\bfseries textcite} \textcite{leis2016} \\ 
I would like to use {\bfseries ``\&''} within {\bfseries parencite} \parencite{leis2016}.\\

Example of three authors would be the same as above \textcite{test} using {\bfseries ``and''} within {\bfseries textcite}. \\

Although using {\bfseries parencite} to be {\bfseries ``\&''} \parencite{test}. 

\renewcommand{\bibname}{REFERENCES}

\xpatchbibmacro{date+extrayear}{%
  \printtext[parens]%
}{}{}

\printbibliography

\end{document}

enter image description here

1
  • I have just realised my MWE is not as a code. I will try to rectify this.
    – Tahn
    Mar 20, 2017 at 14:16

2 Answers 2

6

Change of the final name delimiter between \parencite and \textcite from "&" to "and" as in

(Sigfridsson & Ryde, 1998) and Sigfridsson and Ryde (1998)

is a feature of APA style. See for example https://blog.apastyle.org/apastyle/2011/01/writing-in-text-citations-in-apa-style.html and https://blog.apastyle.org/apastyle/2011/02/changes-parentheses-bring.html.

If you are looking for a complete implementation of APA style with biblatex, you may be interested in biblatex-apa, which when loaded as

\usepackage[backend=biber, style=apa]{biblatex}

should produce a bibliography and citations according to APA guidelines.

The answer below shows how to change the final name delimiter in the standard styles.

With the new context sensitive delimiter interface that should be as easy as redefining finalnamdelim in global scope to give an ampersand and to give "and" for textcite.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}


\addbibresource{biblatex-examples.bib}

\DeclareDelimFormat{finalnamedelim}{\addspace\&\space}
\DeclareDelimFormat[textcite]{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}

\begin{document}
\cite{sigfridsson,companion}

\parencite{sigfridsson,companion}

\textcite{sigfridsson,companion}

\printbibliography
\end{document}

Sigfridsson & Ryde 1998; Goossens, Mittelbach & Samarin 1994\(Sigfridsson & Ryde 1998; Goossens, Mittelbach & Samarin 1994)\Sigfridsson and Ryde (1998) and Goossens, Mittelbach and Samarin (1994)\Goossens, Michel, Frank Mittelbach & Alexander Samarin (1994).\Sigfridsson, Emma & Ulf Ryde (1998).

Edited to use the context sensitive delimiter interface. See the edit history for older versions of biblatex.

2
  • Worked a charm!
    – Tahn
    Mar 20, 2017 at 14:43
  • I did try to upvote, unfortunately I don't have enough reputation for it to show.
    – Tahn
    Mar 20, 2017 at 15:40
2

Biblatex supports context-sensitive delimiters; i.e. depending on the citation command used (\textcite, \parencite, etc), you can tell biblatex to use a different delimiter, for certain delimiter types. See §3.10.2 of the biblatex manual for more details.

\finalnamedelim is the delimiter used to separate (the last) two names in a citation or bibliography entry. Unfortunately, \finalnamedelim is not context sensitive by default, but we can easily change that:

% Modify name:delim to use a context-sensitive version of finalnamedelim
\xpatchbibmacro{name:delim}
  {\lbx@finalnamedelim{#1}}
  {\printdelim{finalnamedelim}}
  {}{}

% Set the global context to use an ampersand
\DeclareDelimFormat{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}

% Set the textcite context specifically to use the "and" string
\DeclareDelimFormat[textcite]{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}

How this works

According to the biblatex documentation, \finalnamedelim is:

The delimiter printed instead of \multinamedelim before the final name in a name list. The default is the localised term ‘and’, separated by interword spaces.

It is defined in biblatex.def as:

\newcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}

Note that the implementation is different in Spanish.

In all the standard styles, it is called via the name:delim bibmacro, which also defined in biblatex.def:

\newcommand*{\lbx@finalnamedelim}[1]{\finalnamedelim}
\newbibmacro*{name:delim}[1]{%
  \ifnumgreater{\value{listcount}}{\value{liststart}}
    {\ifboolexpr{
       test {\ifnumless{\value{listcount}}{\value{liststop}}}
       or
       test \ifmorenames
     }
       {\multinamedelim}
       {\lbx@finalnamedelim{#1}}}
    {}}

So, to make name:delim use a context sensitive version of \finalnamedelim, we need to use \printdelim{finalnamedelim} instead of \lbx@finalnamedelim{#1}. You could make a complete copy of name:delim and change only that line, or you can use the xpatch package to selectively replace only the part you care about:

\xpatchbibmacro{name:delim}
  {\lbx@finalnamedelim{#1}}
  {\printdelim{finalnamedelim}}
  {}{}

The final step is to now declare the delimiter format for each context using DeclareDelimFormat[<context>]{<name>}{<code>}.

If you don't specify a context, then the format will apply globally (i.e. to any context that doesn't have a specific format set). Hence, the following will force an ampersand to be used for all contexts unless otherwise specified:

\DeclareDelimFormat{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}

And now we override the \textcite context:

\DeclareDelimFormat[textcite]{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}

\bibstring{and} keeps this language sensitive, and also allows you to override it with:

\DefineBibliographyStrings{english}{%
  and = {as well as}%
}

Note:

The format definition for the \textcite context is just the original definition of \finalnamedelim. You might therefore be tempted to try to simply it:

\DeclareDelimFormat[textcite]{finalnamedelim}{\finalnamedelim}

What this actually does is use our format definition for the global context, and so you will get an ampersand, not \bibstring{and}. Incidentally, that is why you can't do this:

\DeclareDelimFormat{finalnamedelim}{\finalnamedelim}

This will send the compiler into an infinite recursion, and it will eventually crash.

5
  • Very nice solution and explanation. Indeed there are quite some delimiters that don't use the new \printdelim features yet. Maybe some more should do so by default.
    – moewe
    Apr 19, 2017 at 8:16
  • Thanks! Yes, I'm not sure why the standard list of context-sensitive options is so limited; it concerned me that maybe there was a good reason that I had overlooked, given the apparent simplicity of making it work... Hopefully it's only because no one has had time yet to expand support for it.
    – TULC
    Apr 20, 2017 at 11:16
  • When the feature was developed (not very long ago) it was for quite a specific reason (biblatex issue #373). It was then expanded to the bibliography (github.com/plk/biblatex/commit/… and github.com/plk/biblatex/commit/…). But then we didn't go any further. The system is quite sophisticated, but changes to code that has been there for quite a long time is always risky. Any suggestions and requests for new delimiters to be added are welcome...
    – moewe
    Apr 20, 2017 at 12:51
  • ... just drop by github.com/plk/biblatex/issues. Or if you already have an idea, submit a pull request.
    – moewe
    Apr 20, 2017 at 12:52
  • Thanks again! I'm still fairly new to biblatex (latex in general, really), but I'll certainly have a look at that.
    – TULC
    Apr 20, 2017 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .