# Variable family name (\mkbibnamefamily) depending on entry type in biblatex

So I'm using the french language with a style derived from authortitle-terse. I've tried to ask an ambitious (too ambitious?) question here, and I'm trying to break down this question in sub-piece.

Now, I'd like to customize the style of the author family name, depending on the type of the entry. From my previous experience and question here, I cannot find how to do it.

In the french.lbx, I read that the \mkbibnamefamily is defined as:

  \protected\def\mkbibnamefamily#1{%
\textsc{\textnohyphenation{#1}}}%


So as far as I know, and based on my first tries here, I could not do something like:

\DeclareFieldFormat[article,book]{\mkbibnamefamily}{#1}


Or even:

\UndefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}
\renewcommand*{\mkbibnamefamily}{\textsc}
\renewcommand[article, book]{\mkbibnamefamily}{\textsc}


Because the last line on article/book breaks the code.

# Questions

1. How can I change the formatting of family names by type of entry?
2. What is the formatting of names so different than the \DeclareFieldFormat for title?
3. What would be the command to format the family name of an editor?

# MWE Code

main.tex

\documentclass{article}

% Needed by Biblatex
\usepackage{polyglossia}
\setmainlanguage{french}
\usepackage{csquotes}
\usepackage[style=authortitle-terse, language=french, bibencoding=UTF8, backend=biber]{biblatex}

\DeclareFieldFormat{author}{#1}% no postnote prefix in "multicite" commands
\UndefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}
\renewcommand*{\mkbibnamefamily}{\textsc}
% \renewcommand[article, book]{\mkbibnamefamily}{\textsc}

\begin{document}
\section{Test de la bibliographie}
\printbibliography
\section{Tests de citation}
book : \cite{book} \\
thesis : \cite{thesis} \\
Article : \cite{article} \\
\end{document}


main.bib

@book{book,
author      = {Other, Nicolas},
title       = {A title for a thesis},
date        = {2017},
location    = {Berne and Bâle and Lugano},
origlocation = {Lausanne}
}

@thesis{thesis,
author      = {Gut, Nicolas},
title       = {Die unbezifferte Forderungsklage nach der Schweizerischen Zivilprozessordnung},
location    = {Bâle},
date        = {2014},
}

@article{article,
author      = {Affolter, Markus},
title       = {Die Durchsetzunh von Informationspflichten im Zivilprozess},
origLocation    = {St. Gall},
date        = {1994},
location    = {Berne and Stuttgart and Vienne},
}

• For name fields, you need to use \DeclareNameFormat – PLK Apr 28 '18 at 20:52
• It's just a typo, but if you have the Affolter citation in your real .bib file you may want to make sure it reads Durchsetzung (with g instead of Durchsetzunh). – moewe Apr 29 '18 at 5:23

1. For type-specific formatting in \mkbibnamefamily you can use \ifentrytype.

\renewcommand*{\mkbibnamefamily}[1]{%
\ifentrytype{article}
{\mkbibemph{#1}}
{\textsc{#1}}}


This issue is complicated by the fact that your document loads the French localisation. french.lbx redefines \mkbibnamefamily to always give small caps. You can tell french.lbx to stop messing about with \mkbibnamefamily with

\DefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}

2. biblatex roughly knows three data types: (1) fields, (2) lists and (3) name lists. Fields are the simplest of the bunch and can be completely customised with \DeclareFieldFormat. Lists are a bit more tricky since a list may contain an arbitrary number of items and you may want to format the entire list as one chunk or the items separately. Additionally, biblatex needs a bit of work to place the delimiters between items of a list. The customisation command for lists is \DeclareListFormat. Names are even more tricky, they are not only lists, but the items of the list are made up of name parts, which warrant special treatment. The command for name lists is \DeclareNameFormat, but there are many helper macros such as \mkbibnamefamily to help you customise name formats without actually using \DeclareNameFormat. All the \Declare...Format commands can be made type-specific with an optional first argument. The helper commands for names are in general not type-specific, but one can work around that (as see above).

3. That depends on the exact context. You could use \ifcurrentname{editor}{<true>}{<false>} just like \ifentrytype{article}{<true>}{<false>} in item 1. You could also define a completely new name format. To understand how that would work, let's walk through biblatex.def's definitions for author (note that the standard definitions of biblatex.def are slightly modified if you use authoryear- or authortitle-like styles, they set \DeclareNameAlias{author}{sortname} instead, but the principle is the same and the code is shorter with the standard \DeclareNameAlias{author}{default}).

The name format for author is defined with

\DeclareNameAlias{author}{default}


we later find

\DeclareNameAlias{default}{given-family}


and then

\DeclareNameFormat{given-family}{%
\ifgiveninits
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}%
\usebibmacro{name:andothers}}


This means that name formats involve calling helper macros. The most important macro here is name:given-family

\newbibmacro*{name:given-family}[4]{%
\usebibmacro{name:delim}{#2#3#1}%
\usebibmacro{name:hook}{#2#3#1}%
\ifdefvoid{#2}{}{\mkbibnamegiven{#2}\isdot\bibnamedelimd}%
\ifdefvoid{#3}{}{%
\mkbibnameprefix{#3}\isdot
\ifprefchar
{}
{\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
\mkbibnamefamily{#1}\isdot
\ifdefvoid{#4}{}{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}


The similar macros name:family and name:family-given are used by other name formats. Commands like \mkbibnamefamily are used here, so that is the level at which your changes are ultimately applied. Since name:family and name:family-given are similar to name:given-family all of them use \mkbibnamefamily.

You could define

\DeclareNameFormat{given-family:bold}{%
\let\mkbibnamefamily\mkbibbold
\ifgiveninits
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}%
\usebibmacro{name:andothers}}


and then

\DeclareNameAlias[article]{author}{given-family:bold}


to affect only authors of @articles.

• I could manage to get this piece of code working for the article. I'm now trying to make it work for my style on different entrytype and to reset the small caps on author/editor. Just a quick question how can I reset to a "plain" mode, i.e. what is the correct "\let\mkbibnamefamily\mkbib<standard>" ? – XaWin May 4 '18 at 14:41
• @XaWi The standard definitions are functionally equivalent to what you get from \renewcommand*{\mkbibnamefamily}[1]{#1}. – moewe May 4 '18 at 14:50
• Sorry I was probably not clear. At the moment, I keep the french default "small caps", so my standard is "small caps". So what should I put in a name format like : \DeclareNameFormat{given-family:plain} ? I would then use the "\DeclareNameAlias[collection]{author}{given-family:plain}" in order to have plain, non-small caps author only for the collection item. Is it possible ? – XaWin May 4 '18 at 15:21
• @XaWi Not sure if I understand you correctly, but try \let\mkbibnamefamily\@firstofone instead of \let\mkbibnamefamily\mkbibbold in the code above. \let\mkbibnamefamily\@firstofone gives the same result as \renewcommand*{\mkbibnamefamily}[1]{#1} for most intents and purposes. – moewe May 4 '18 at 15:39
• Thanks! That solved the formatting issue for the family name, but I'm having other issues. Do you mind if I open a new question on the collection/incollection ? – XaWin May 4 '18 at 16:11