0

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.

enter image description here

Here is what I get with my current code :

enter image description here

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
  • 2
    The unwanted spaces comes again from forgotten %s you need \DeclareBibliographyDriver{collection}{% and \DeclareBibliographyDriver{incollection}{% (i.e. you have to add a % after the {). – moewe May 5 '18 at 15:14
  • 2
    \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}. – moewe May 5 '18 at 15:35
  • 2
    The "(edit.)" is missing because you coded your own editors macro. You can just use the standard macro editor (i.e. use \usebibmacro{editor} instead of \usebibmacro{editors} everywhere). – moewe May 5 '18 at 15:38
  • 2
    If you want all editors for all entry types in normal (non-small-caps) font, you only need \DeclareNameAlias{editor}{given-family:plain} without any type-specific argument. – moewe May 5 '18 at 15:52
  • 2
    For the title you want \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. – moewe May 5 '18 at 15:56
0

Summary of my changes :

Issue 1a. - Various editor format

Formatting of editors is off, the \DeclareNameAlias[collection, incollection]{editor}{given-family:plain} has no effect.

moewe comments was that "\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}."

Change made

Replace the lines

\DeclareNameAlias[collection]{author}{given-family:plain}
\DeclareNameAlias[collection, incollection]{editor}{given-family:plain}

by

\DeclareNameAlias[collection]{author}{given-family:plain}
\DeclareNameAlias[collection]{editor}{given-family:plain}
\DeclareNameAlias[incollection]{editor}{given-family:plain}

Issue 1b. - Formatting title

formatting of the title in the incollection is also off.

moewe comments was that "[f]or the title you want \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"

Change made

Replace the line

\DeclareFieldFormat*{title}{\mkbibemph{#1}}

by

\DeclareFieldFormat*{title}{\mkbibemph{#1}}
\DeclareFieldFormat[incollection]{title}{#1}

Issue 1c. - Correction of spacing (missing some %)

There are some funny spacing in front of the collection/incollection entries

moewe comments was that "[t]he unwanted spaces comes again from forgotten %s you need \DeclareBibliographyDriver{collection}{% and \DeclareBibliographyDriver{incollection}{% (i.e. you have to add a % after the {)"

Change made

Replace the line

\DeclareBibliographyDriver{collection}{

by

\DeclareBibliographyDriver{collection}{%

and

Replace the line

\DeclareBibliographyDriver{incollection}{

by

\DeclareBibliographyDriver{incollection}{%

Issue 1d. - Formating of (edit.)

The label "(edit.)" is missing

This issue was caused by two sources : (1) The current ShareLatex version is 3.7. Biblatex v3.8 offers more cutomization (2) My lbx was wrongly formatted and missing some field redefinition. Hence the change

Change made

  1. Setting the format in .bbx file.

this code was then inserted in the bbx file.

% set delimiter of editor-type to a space (instead of ", ")
\DeclareDelimFormat{editortypedelim}{\addspace}
% add parenthesis around the label of editortype
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
  1. Workaround for v3.7 code (not needed in recent version)

The spacing was not working, but this is due to my version biblatex being outdated. Hence, I've simply copied the latest version of the code.

% Workaround, due to v3.7, solved in v3.8+ %
% Need to copy the current biblatex 3.11 macro %
\renewbibmacro*{editor}{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\printnames{editor}%
     \setunit{\printdelim{editortypedelim}}%
     \usebibmacro{editorstrg}%
     \clearname{editor}}
    {}}
  1. Changing the lbx code with the custom "edit"

in order to work, my lbx code needs a better formatting, as per Moewe comments. The code hereafter change the default "editor(s)" entry type with my updated version.

\DeclareBibliographyStrings{%
inherit = {french},
editor = {{\'editeur}{\'edit\adddot}},
editors = {{\'editeurs}{\'edit\adddot}},
}
  • Note that the change from starred \DeclareFieldFormat*{title}{\mkbibemph{#1}} to unstarred \DeclareFieldFormat{title}{\mkbibemph{#1}} also changes the formatting of, say, @article entries. That may or may not be intended. – moewe May 6 '18 at 9:47
  • Oups, my bad, typo errors. I meant to use the * one to change all of the title and then the [incollection] one to reset the incollection on. However, I noticed that my example had a "book entry", which was also in "italics". But this may come from the authortitle-terse default, I'd really to test and understand the star vs no-star ! – XaWin May 6 '18 at 10:06
  • The standard definitions are github.com/plk/biblatex/blob/…. So some types are italic (actually \emph) by default, while others are in quotation marks and a few exceptions plain. If you use the unstarred version, you only change the format for entry types that don't have a type-specific definition (e.g. @book, @collection, those are \mkbibemph). The starred version overwrites all type-specifics and would also apply to @inbook for example. – moewe May 6 '18 at 10:10

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.