2

I'm using biblatex to create my own style, focused on legal documents in Switzerland, as per my last posts.

I'm now stuck with some official statement from the Swiss governement, which are published in a separate bibliography. I already know about the great option in biblatex to make several "\printbibliography" with a filter.

The format should be like this text, with no formatting at all. There are only 3 elements, the title, the reference to find it in a online ledger (note) and the label. All the citation to this entry should be just the content of the label.

Message du Conseil fédéral du 28 juin 2006 relatif au code de procédure civile suisse (CPC), FF 2006 p. 6841 ss (cité : Message CPC).

For me, this would translate to the following bibtex entry (more or less), based on my reading of the biblatex manual, page 8 ss.

@message{messageCPC,
    title       = {Message du Conseil fédéral du 28 juin 2006 relatif au code de procédure civile
suisse (CPC)},
    note        = {FF 2006 p. 6841 ss},
    label       = {Message CPC}
}

how can I define my own entry type "message" ?

General guideline were answered by @Moewe in comment, which directed me to this post. To make this question more interesting, I'll come back with my own code and potential issue for this case.

Edit : Questions after my initial test

The definition went pretty well, the new type is working almost as expected. The remaining issue is the formating of the "cited as" part. Ideally, it should be in plain text or in small caps. However, none of my tryouts have worked so far.

1) How can I set the style of "cite" in both the cite and bibliography in standard ? 2) How can I set the style of "cite" in both the cite and bibliography in Small Caps ?

Note : The part for cited is taken from my previous question, on the creation of own drivers.

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}

\addbibresource{main.bib}

\begin{document}

\section{Expectation}
This test contains a citation to a message as well as several authors documents. Here are the expectation for citation :
\begin{itemize}
    \item book single author : "\textsc{Druey}"
    \item book multi-authors  : "\textsc{Druey/Comte}"
    \item message : "Message CPC"
\end{itemize}

When displayed in the bibliography, this item should become :

Message du Conseil fédéral du 28 juin 2006 relatif au code de procédure civilesuisse (CPC), FF 2006 p. 6841 ss (cité : \textsc{Message CPC})

\section{Test}

This is a series of citation to regular type, and a message at the very end. book single author : \cite{Druey}, \cite{DrueyComte}

If there are both type of data, then the table of content must be split in 2 parts, the first for all the non-message elements, the second for . The 2 parts must have subtitle (subsection) which should not appear in the table of content.

Test of citation message : \cite{MessageCPC}

\end{document}

main.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      = {Gute, Nicolas},
  title       = {Die unbezifferte Forderungsklage nach der Schweizerischen Zivilprozessordnung},
  date        = {2014},
  location    = {Bâle},
  label       = {thèse}
}

@message{MessageCPC,
    title       = {Message du Conseil fédéral du 28 juin 2006 relatif au code de procédure civile
suisse (CPC)},
    note        = {FF 2006 p. 6841 ss},
    label       = {Message CPC}
}

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 bibliography
\setlength{\bibhang}{0pt}
\setlength{\bibitemsep}{1.5\baselineskip}

% --- --- Code de bas niveau --- --- %

% Partie 1 : BibMacro pour le "cité comme"
% format : (cité : Auteur-label)

\DefineBibliographyStrings{french}{citedas = {cit\'e}}
\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}}}}


% --- --- Nouveau type : message --- --- %
\DeclareDatamodelEntrytypes{message}

\DeclareFieldFormat*[message]{title}{#1}
\DeclareFieldFormat*[message]{note}{#1}
\DeclareFieldFormat*[message]{label}{#1}
\DeclareFieldFormat*[message]{citelabel}{#1}

\DeclareBibliographyDriver{message}{%
    \usebibmacro{bibindex}%
    \usebibmacro{begentry}%
    \printfield{title}%
    \newunit\newblock
    \printfield{note}%
    \setunit{\addspace}%
    \usebibmacro{citedas}%
    \usebibmacro{finentry}
}

\endinput % seulement à la fin

biblatex-xawi.cbx

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

% 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{\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
  • 1
    See tex.stackexchange.com/q/175776/35864 – moewe Apr 20 '18 at 17:01
  • Must have missed this one. I was put aside by this one here, tex.stackexchange.com/questions/17276/… – XaWin Apr 20 '18 at 17:20
  • Don't use the starred \DeclareFieldFormat* if you also give an optional argument. As in the comments to your last question you probably only need \DeclareFieldFormat[message]{citetitle}{#1}. I can't test your example because in modern versions of biblatex the data model commands must live in the .dbx file and can not be scattered in .bbx or .cbx. Ideally you would follow that custom even if it currently works for you to put things in the .bbx. – moewe Apr 21 '18 at 6:21
3

The general process of adding new entry types and setting them up correctly is explained in How can I create entirely new data types with BibLaTeX/Biber?.

You can change the format of the 'Message CPC' with

\DeclareFieldFormat[message]{citetitle}{#1}

Note that there is no start here and that the changed format is citetitle (not label or citelabel).

In modern versions of biblatex, you can't put \DeclareDatamodelEntrytypes{message} into the .bbx file. Data model commands must live in the datamodel file with ending .dbx.

biblatex-xawi.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}}
\DeclareFieldFormat[message]{citetitle}{#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}}

\DeclareBibliographyDriver{message}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{title}%
  \newunit\newblock
  \printfield{note}%
  \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!

biblatex-xawi.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

biblatex-xawi.dbx

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

\DeclareDatamodelEntrytypes{message}

\endinput
  • Thanks for the remarks on the "DBX" file, I've changed this on my side, as this is also accepted in ShareLatex. From the change version, I've noticed that the difference in biblatex between version used (3.7) and the latest version seem minimal. But in any case, my new MWE contains the DBX file now. – XaWin Apr 22 '18 at 12:48
  • @XaWi Well, biblatex 3.8 brought quite a number of new features and improvements as well as a few name changes to fields and macros. So while the changes seem minimal they are there and even relevant to some bits of your code. – moewe Apr 22 '18 at 12:50

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.