One more question on the creation of driver for collection and incollection. Some of the book I cite have several section and are part of a collection edited by several editors. In short, the collection have only editor and the incollection may have an author who is either one of the editors or a totally different person.
Now, I must also follow some very strict rules, on the formatting of authors, editors, title as well as add a label "(edit. )" at the end of the editors lists. I've taken the code from standard biblatex and changed it according to the last question I had on book / thesis, to recycle the "cited as" functionnality.
At the moment, I'm getting about 60% of the target, as the cross-ref works fine. But I'm blocking on some of the formatting elements and probably some re-alignment with best-practive on bibmacro.
Here is also what I was given as reference/example. The (1) is the incollection item and the (2) is the collection.
Here is what I get with my current code :
Issues (1)
- Formatting of editors is off, the
\DeclareNameAlias[collection, incollection]{editor}{given-family:plain}
has no effect. - formatting of the title in the incollection is also off.
- The label "(edit.)" is missing
- I'm about sure that the field chosen are not right for booktitle and so on.
- There are some funny spacing in front of the collection/incollection entries
- I'm not sure that the collection will not have never show a "cited as". The collection itself will never appears in the citation, but must appears as an effect of having one the crossref
Issues (2)
Thanks to @moewe comments, I was able to solve most of my issues in part 1. there are still some gap for the "edit" part, hence this addition hereby.
The label "(edit.)" is missing was solved by using the right \DeclareBibliographyStrings{editor = {{\'editeur}{\'edit\adddot}}}
and using the standard {editor}
, whose definition is in biblatex.def. this produce this kind of output :
Chiocchetti, édit., Commentario
I'd need some small changes in the edit to make it be like this :
Chiocchetti (édit.), Commentario
I've tried to copy-paste and edit the standard bibmacro, and change the macro. I now got some error with the spacing. The output is missing a space " " in the format, as this :
Chiocchetti(édit.), Commentario
\renewbibmacro*{editors}{%
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\printnames{editor}%
\setunit{\printdelim{editortypedelim}}%
\printtext[parens]{\usebibmacro{editorstrg}}%
\clearname{editor}}
{}}
So I'm (1) not sure where my mistake is and (2) no sure this is even the right approach.
Issues (3)
Just noted another funny effects in this example, the editors/author are inverted in comparison to others entries. "François Bohnet" instead of "Bohnet François". I don't understand why the \DeclareNameAlias{sortname}{family-given}
do not work in this case ?
MWE
.tex
\documentclass{article}
\usepackage[maxbibnames=99, style=biblatex-xawi, language=french, backend=biber, bibencoding=UTF8, dashed=false]{biblatex}
\addbibresource{Commentaires.bib}
\begin{document}
\printbibliography{}
\nocite{*}
\section{Expectations}
\subsection{Requirements}
Small caps only in the incollection authors, No small caps for editors in the collection or incollection.
Italics for title of the collection entry, in both collection and incollection
Cited-as should appears only if needed in the incollection entry.
\subsection{First example}
\textsc{Bohnet} François, art. 85 CPC, in : Bohnet François /Haldy Jacques /Jeandin Nicolas /Schweizer Philippe /Tappy Denis (édit.), \textit{Code de procédure civile commenté}, Bâle 2011.
Bohnet François / Haldy Jacques / Jeandin Nicolas / Schweizer Philippe / Tappy Denis (édit.), \textit{Code de procédure civile commenté}, Bâle 2011.
\subsection{Second example}
\textsc{Trezzini} Francesco, art. 85 CPC, in : Trezzini Francesco / Fornara Stefano / Cocchi Bruno / Bernasconi Giorgio / Verda Chiocchetti Francesca (édit.), \textit{Commentario pratico al Codice di diritto processuale civile svizzero – Volume I Parte prima: Disposizioni generali (Art. 1-196)}, Pregassona 2017.
Trezzini Francesco / Fornara Stefano / Cocchi Bruno / Bernasconi Giorgio / Verda Chiocchetti Francesca (édit.), \textit{Commentario pratico al Codice di diritto processuale civile svizzero – Volume I Parte prima: Disposizioni generali (Art. 1-196)}, Pregassona 2017.
\end{document}
.bib
@collection{CPC_It,
editor = {Trezzini, Francesco and Fornara, Stefano and Cocchi, Bruno and Bernasconi, Giorgio A. and {Verda Chiocchetti}, Francesca},
booktitle = {Commentario pratico al Codice di diritto processuale civile svizzero},
booksubtitle = {Volume I Parte prima: Disposizioni generali (Art. 1-196) },
location = {Pregassona},
date = {2017},
}
@incollection{IT_CPC85,
author = {Trezzini, Francesco},
title = {art. 85 CPC},
crossref = {CPC_It},
}
@collection{CR_CPC,
editor = {Bohnet, François and Haldy, Jacques and Jeandin, Nicolas and Schweizer, Philippe and Tappy, Denis},
booktitle = {Code de procédure civile commenté},
date = {2011},
location = {Bâle},
}
@incollection{CR_CPC85,
author = {Bohnet, François},
title = {art. 85 CPC},
date = {2011},
location = {Bâle},
label = {Commentaire},
crossref = {CR_CPC},
}
@book{bohnetProc,
author = {Bohnet, François},
title = {Procédure civile},
edition = 2,
date = {2014},
location = {Bâle},
label = {Procédure},
}
.bbx
\ProvidesFile{biblatex-xawi.bbx}[2018/04/13 v1.1 alpha)]
% Dépendances
\RequireBiber[2]
\RequireBibliographyStyle{authortitle}
% Localisation
\DeclareLanguageMapping{french}{biblatex-xawi-french}
% Suppression des commandes de formattage des noms propres
\UndefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}
\renewcommand*{\mkbibnamefamily}{\textsc}
% --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---%
% --- --- Setting default options --- --- %
\ExecuteBibliographyOptions{%
maxbibnames=99, % nombre max. de noms pour les entrées
maxcitenames=4, % nombre max. de noms pour les citations
mincrossrefs=1, % nombre min pour les références croisées
bibwarn=false, % avertissement uniques pour les entrés bibliographiques
dashed=false, % Nom entier même si répétition
singletitle=true,
uniquename=full,
uniquelist=true
}
% --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---%
% --- --- Formatage général des citations & bibliogryphies --- --- %
% Formatage global :
\DeclareNameAlias{sortname}{family-given}
% Dans les citations, pas d'espaces entre les slash (contrairement à la bibliographie)
\renewcommand*{\multinamedelim}{\ifcitation{\slash}{\addnbspace\slash\addspace}}
\renewcommand*{\finalnamedelim}{\multinamedelim}
% BibLatex v2.8+ : Format des séparateurs entre les noms: des slash
% \DeclareDelimFormat{multinamedelim}{\slash}
% \DeclareDelimFormat[bib,biblist]{multinamedelim}{\addnbspace\slash\addspace}
% \DeclareDelimAlias{finalnamedelim}{multinamedelim}%
\renewcommand*{\multilistdelim}{\slash}
%\renewcommand*{\multilistdelim}{\addnbspace\slash\addspace}
\renewcommand*{\finallistdelim}{\multilistdelim}
\renewcommand*{\newunitpunct}{\addcomma\space}
\renewcommand*{\revsdnamepunct}{}
\DeclareFieldFormat*{title}{\mkbibemph{#1}}
% Ponctuation entre le titre et le sous-titre
\renewcommand{\subtitlepunct}{\addnbspace\textendash\addnbspace}
% Remove all possible shorthand
% https://tex.stackexchange.com/questions/244714/how-to-disable-the-use-of-shorthands-in-biblatex
\DeclareFieldInputHandler{shorthand}{\def\NewValue{}}
\DeclareNameFormat{given-family:plain}{%
\let\mkbibnamefamily\@firstofone
\ifgiveninits%
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}%
\usebibmacro{name:andothers}}
\DeclareNameAlias[collection]{author}{given-family:plain}
\DeclareNameAlias[collection, incollection]{editor}{given-family:plain}
% --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---%
% --- --- Pilote de bibliographie pour les livres et autres ouvrages généraux --- --- %
\DeclareBibliographyDriver{book}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{maintitle+title}%
\newunit\newblock
\printfield{edition}%
\newunit\newblock
\usebibmacro{location+date}%
\setunit{\addspace}%
\usebibmacro{citedas}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\usebibmacro{finentry}}
% --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---%
% --- --- Pilote de bibliographie pour les collection / incollections --- --- %
\newbibmacro{editors}{%
\ifnameundef{editor}%
{}%
{\printnames{editor}}%
}%
\DeclareBibliographyDriver{collection}{
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{editors}%
\newunit\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\printfield{edition}%
\newunit\newblock
\usebibmacro{location+date}%
\finentry
}
\DeclareBibliographyDriver{incollection}{
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\usebibmacro{maintitle+title}%
\usebibmacro{in:}%
\usebibmacro{editors}%
\newunit\newblock
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\printfield{edition}%
\setunit{\addspace}%
\usebibmacro{citedas}%
\finentry
}
% --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---%
% --- Formatage de la citation spécifique dans la bibliographie --- %
% format : (cité : Auteur-label)
% Voir aussi partie "CBX" pour la partie "citation"
\newbibmacro{citedas:cite}{%
\begingroup
\delimcontext{cite}%
\DeclareFieldFormat{bibhyperref}{##1}%
\csuse{blx@hook@cite}%
\csuse{blx@hook@citekey}%
\undef\cbx@lasthash
\undef\cbx@lastyear
\citetrackerfalse\pagetrackerfalse\backtrackerfalse
\defcounter{maxnames}{\blx@maxcitenames}%
\usebibmacro{cite}%
\endgroup
}
\newbibmacro{citedas}{%
\ifsingletitle
{}{%
\printtext[parens] {%
\bibstring{citedas}%
\addcolon\space
\usebibmacro{citedas:cite}}}}
\renewbibmacro*{location+date}{%
\printlist{location}%
\setunit*{\addspace}%
\usebibmacro{date}%
\newunit
}
\newbibmacro{thesis:type+institution}{%
\printfield{type}%
\setunit*{\addspace}%
\printlist{institution}%
\newunit
}
\endinput % seulement à la fin
.cbx
% PREAMBULE / REGLES GENERALES
\ProvidesFile{biblatex-xawi.cbx}[2018/04/13 v1.0 alpha]
\RequireCitationStyle{authortitle}
% --- --- Formatage général des citations --- --- %
\DeclareFieldFormat*{citetitle}{#1}
\DeclareDelimFormat{nametitledelim}{\textendash}
% --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---%
% --- Formatage de la citation spécifique dans les citations --- %
% Definition de la partie "Labeltitle"
\DeclareLabeltitle{%
\field{label}
\field{shorttitle}
\field{title}
\field{maintitle}
}
\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifnameundef{labelname}
{\usebibmacro{cite:title}}
{\ifsingletitle
{\printtext[bibhyperref]{\printnames{labelname}}}
{\printnames{labelname}%
\setunit{\printdelim{nametitledelim}}%
\usebibmacro{cite:title}}}}%
{\usebibmacro{cite:shorthand}}}
\renewbibmacro*{textcite}{%
\ifnameundef{labelname}
{\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\iffieldundef{shorthand}
{\usebibmacro{cite:title}}%
{\usebibmacro{cite:shorthand}}}
{\ifthenelse{\ifsingletitle\AND
\(\iffieldundef{prenote}\OR\value{citecount}>1\)}
{\printtext[bibhyperref]{\printnames{labelname}}}
{\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\addspace\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\iffieldundef{shorthand}
{\usebibmacro{cite:title}}%
{\usebibmacro{cite:shorthand}}}}}
\endinput
.lbx
\ProvidesFile{biblatex-xawi-french}[2018/04/25 v0.1 Biblatex Swiss Legal]
\InheritBibliographyExtras{french}
% Nouvelles chaines de caractère pour le style
\NewBibliographyString{
thesis,
habilthesis,
}
\DefineBibliographyStrings{french}{
citedas = {cit\'e},
thesis = {th\`ese},
habilthesis = {th\`ese d'habilitation},
}
\endinput % seulement à la fin
%s
you need\DeclareBibliographyDriver{collection}{%
and\DeclareBibliographyDriver{incollection}{%
(i.e. you have to add a%
after the{
).\DeclareNameAlias
can only accept one value in the optional argument, it doesn't do several comma-separated values. So you need two lines\DeclareNameAlias[collection]{editor}{given-family:plain} \DeclareNameAlias[incollection]{editor}{given-family:plain}
.editors
macro. You can just use the standard macroeditor
(i.e. use\usebibmacro{editor}
instead of\usebibmacro{editors}
everywhere).\DeclareNameAlias{editor}{given-family:plain}
without any type-specific argument.\DeclareFieldFormat[incollection]{title}{#1}
. The starred\DeclareFieldFormat*{title}
turns all titles into italics, a following \DeclareFieldFormat[incollection]{title}` will then change the formatting for@incollection
.