[Tex/LaTex] Formatting issue with DeclareBibliographyDriver in the Custom Biblatex Style based

biblatex

Following my initial problems about the creation of a new style as well as my first try which ended in an error with the cite, I've created a new BBX/CBX combo.

So I'm progressing, I chose option 2 from my last post, I took the authortitle-terse as a base and copy-pasted it in my own style, then made some small changes. The code is below.

In short, neither my "book" nor my "thesis" driver definition are working. Here are my issues:

1) Book

  1. Delimiter are completely off
  2. The case for multiple authors is not consistent, it seems the driver do not recognize family and given name
  3. There is an extra "," between family and first name
  4. Moreover, I could not code this requirement : if the label field is set, there should be an extra text after the bibliography which says (cité : all author family names in small caps separated by "/"-field

Example for the first cite :
Druey Jean-Nicolas, Titre au hasard ,2e éd., Berne 2016 (cité : Druey-Titre)

2) Thesis

  1. There are " between the title
  2. The title is not in italic
  3. There is an extra "," between first and family name
  4. The separation for block and unit seems way off from my need…

3) Language not detected

I had to force the recnognition of the language. It was not automatically taken.
This caused some real pain, as I only noticed that the issue after adding the "edition" field, noticing that it was in English.

MWE Code

Main.tex

% MweBiblatex Swiss Legal
\documentclass{article}

% Needed by Biblatex
\usepackage{polyglossia}
\setmainlanguage{french}

\usepackage{csquotes}
\usepackage[style=biblatex-xawi, language=french, backend=biber, bibencoding=UTF8]{biblatex}
% \usepackage[style=authortitle-terse, backend=biber, bibencoding=UTF8]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{DrueyComte,
  author      = {Druey, Jean-Nicolas and Comte, Alfred Leopold},
  title       = {Grundriss des Erbrechts},
  edition     = 6,    
  date        = {2016},
  location    = {Berne},
}   
@book{Druey,
  author      = {Druey, Jean-Nicolas},
  title       = {Titre au hasard},
  date        = {2016},
  edition     = 2,
  location    = {Berne},
  label       = {Druey-Test},
}
@thesis{gut,
  author      = {Gut, Nicolas},
  title       = {Die unbezifferte Forderungsklage nach der Schweizerischen Zivilprozessordnung},
  date        = {2014},
  location    = {Bâle},
  label       = {thèse},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\section{expectation}
My goal as a real citation in the reference table as :\\
\textsc{Druey} Jean-Nicolas/\textsc{Comte} Alfred Leopold, \textit{Grundriss des Erbrechts, 6e ed}, Berne 2016\\
Output of the cite command should be like "\textsc{Druey/Comte}".

\section{test}
En matière de successions, le CC offre aux héritiers plusieurs façons de procéder (test 1) \cite{DrueyComte}, (test 2) \cite{Druey}.

Finalement, on cite la thèse de N. Gut ici : \cite{gut}.
\printbibliography

\end{document}

biblatex-xawi.bbx

% Encoding of this file: UTF-8. Code is ASCII compatible.
\ProvidesFile{biblatex-xawi.bbx}[2018/04/13 v1.1 alpha)]
\RequireBiber[2]
\RequireBibliographyStyle{authortitle}

% Formatage de la table
\setlength{\bibhang}{0pt}
\setlength{\bibitemsep}{1.5\baselineskip}

% NOUVELLES COMMANDES DE BIBLIOGRAPHIE %
% \newcommand{\printpaperbibliography}{\printbibliography[nottype=online, title=Bibliographie]}
% \newcommand{\printonlinebibliography}{\printbibliography[type=online, title=Sources en ligne]}

% Format des séparateurs entre les noms: des slash
\renewcommand*{\multinamedelim}{\ifcitation{\slash}{\addnbspace\slash\addspace}}% Dans les citations, pas d'espaces entre les slash (contrairement à la bibliographie)
\renewcommand*{\finalnamedelim}{\multinamedelim}%
\renewcommand*{\newblockpunct}{,}
% \renewcommand*{\newunitpunct}{}

% NOUVELLES COMMANDES DE BIBLIOGRAPHIE %

\DeclareBibliographyDriver{book}{%
    \printnames{author}%
    \newunit\newblock
    \printfield{title}%
    \newunit\newblock%
    \printfield{edition}%
    \newunit\newblock
    \printlist{location}%
    \setunit{\addspace}%
    \printfield{year}%
    \finentry}
\endinput

\DeclareBibliographyDriver{thesis}{%
    \printnames{author}%
    \newunit\newblock%
    \printfield{title}%
    \newunit\newblock%
    \printfield{label}%
    \newunit\newblock%
    \setunit{\addspace}%
    \printlist{location}%
    \setunit{\addspace}%
    \printfield{year}%
    \finentry}
\endinput

biblatex-xawi.cbx (copy-past of authortitle-terse)

% Encoding of this file: UTF8. Code is ASCII compatible. 

% PREAMBULE / REGLES GENERALES
\ProvidesFile{biblatex-xawi.cbx}[2018/04/13 v1.0 alpha]

\RequireCitationStyle{authortitle}
\ExecuteBibliographyOptions{singletitle,uniquename,uniquelist,autocite=inline}

\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifnameundef{labelname}
       {\usebibmacro{cite:title}}
       {\ifsingletitle
          {\printtext[bibhyperref]{\printnames{labelname}}}
          {\printnames{labelname}%
       \setunit{\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

Best Answer

@book

  1. In general you don't want to change \newblockpunct you need to change \newunitpunct

  2. The parser recognises the names correctly, you want

     \DeclareNameAlias{sortname}{family-given}
    
  3. You need

     \renewcommand*{\revsdnamepunct}{}
    
  4. See below

@thesis

Your main problem was that you had an \endinput after the driver for @book. That line caused biblatex to ignore everything after it, so the @thesis driver was never read.

With

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

you get all titles in italics without quotation marks.

Language not detected

Your MWE detected the French language just fine for me without language=french. If you use really ancient versions of biblatex or polyglossia that could be problematic, but with a fairly modern version, you should be fine.

The citation style

The label field is only added if there are two works by the same authors. And only then you get to see 'cité' in the bibliography.

The styles are already equipped to do that for us, we only need

\DeclareLabeltitle{%
  \field{label}
  \field{shorttitle}
  \field{title}
  \field{maintitle}
}

and two macros to print the 'cité' information in the bibliography

Test document

\listfiles
\documentclass{article}

% Needed by Biblatex
\usepackage{polyglossia}
\setmainlanguage{french}

\usepackage{csquotes}
\usepackage[style=biblatex-xawi, backend=biber, bibencoding=UTF8]{biblatex}
% \usepackage[style=authortitle-terse, backend=biber, bibencoding=UTF8]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{DrueyComte,
  author      = {Druey, Jean-Nicolas and Comte, Alfred Leopold},
  title       = {Grundriss des Erbrechts},
  edition     = 6,    
  date        = {2016},
  location    = {Berne},
}   
@book{Druey,
  author      = {Druey, Jean-Nicolas},
  title       = {Titre au hasard},
  date        = {2016},
  edition     = 2,
  location    = {Berne},
  label       = {Druey-Test},
}
@thesis{gut,
  author      = {Gut, Nicolas},
  title       = {Die unbezifferte Forderungsklage nach der Schweizerischen Zivilprozessordnung},
  date        = {2014},
  location    = {Bâle},
  label       = {thèse},
}
@book{gut2,
  author      = {Gut, Nicolas},
  title       = {Ein Buch},
  date        = {2015},
  location    = {Berne},
  label       = {Buch},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\section{expectation}
My goal as a real citation in the reference table as :\\
\textsc{Druey} Jean-Nicolas/\textsc{Comte} Alfred Leopold, \textit{Grundriss des Erbrechts, 6e ed}, Berne 2016\\
Output of the cite command should be like "\textsc{Druey/Comte}".

\section{test}
En matière de successions, le CC offre aux héritiers plusieurs façons de procéder (test 1) \cite{DrueyComte}, (test 2) \cite{Druey}.

Finalement, on cite la thèse de N. Gut ici : \cite{gut}.

\cite{gut2}

\printbibliography

\end{document}

.bbx

\ProvidesFile{biblatex-xawi.bbx}[2018/04/18 v1.1 alpha]
\RequireBiber[2]
\RequireBibliographyStyle{authortitle}
\ExecuteBibliographyOptions{dashed=false}

% Formatage de la table
\setlength{\bibhang}{0pt}
\setlength{\bibitemsep}{1.5\baselineskip}

\DeclareDelimFormat{multinamedelim}{\slash}
\DeclareDelimFormat[bib,biblist]{multinamedelim}{\addnbspace\slash\addspace}
\DeclareDelimAlias{finalnamedelim}{multinamedelim}%

\renewcommand*{\newunitpunct}{\addcomma\space}

\DeclareNameAlias{sortname}{family-given}
\renewcommand*{\revsdnamepunct}{}

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

\DefineBibliographyStrings{french}{citedas = {cit\'e}}

\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}

\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
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{thesis}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{title}%
  \newunit\newblock
  \printfield{label}%
  \newunit\newblock
%  \setunit{\addspace}% <--- do you really want that?
  \usebibmacro{location+date}%
  \setunit{\addspace}%
  \usebibmacro{citedas}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\endinput % <- only at the very end!

.cbx

\ProvidesFile{biblatex-xawi.cbx}[2018/04/18 v1.1]

\RequireCitationStyle{authortitle}
\ExecuteBibliographyOptions{singletitle,uniquename,uniquelist,autocite=inline}

\DeclareDelimFormat{nametitledelim}{\textendash}

\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

enter image description here