4

Following my question here on the deprecated style biblatex-swiss-legal, I've decided to go for a simple new style. As a first step, I'll work with these requirements :

  1. Limitated to "book" at the moment
  2. Separator between author is slash
  3. Authors in Small cap
  4. Bibliography as "Author1 / Author2, title, location year." i.e. slash with space
  5. Citation as "Author1/Author2", i.e. slash, no space

I'm blocked on the steps 2-4. I've found some interesting questions here, like "Biblatex 3.3 name formatting" or "Guidelines for customizing biblatex styles", but I'm not sure how to further proceed after my first draft below.

But it doesn't produce anything else than a neat "! Package biblatex Error: Command '\cite' undefined." What am I missing ? I'd appreciate some guidance or boilerplate example.

Test Files

Main.tex

% MweBiblatex Swiss Legal
\documentclass{article}
% Needed by Biblatex
\usepackage{polyglossia}
\setmainlanguage{french}
\usepackage{csquotes}
\usepackage[style=biblatex-xawi, backend=biber, bibencoding=UTF8]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
{
    @book{druey,
    author      = {Druey, Jean-Nicolas and Comte, Alfred Leopold},
    title       = {Grundriss des Erbrechts, 6e ed.},
    date        = {2016},
    location    = {Berne},
    }
}
\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 \cite{druey}.
\printbibliography
\end{document}

biblatex-xawi.cbx

\ProvidesFile{biblatex-xawi.cbx}[2018/04/13 v1.0 alpha]
\endinput

biblatex-xawi.bbx

\ProvidesFile{biblatex-xawi.bbx}[2018/04/13 v1.1 alpha)]
\RequireBiber[2]

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

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

Follow-Up 1

So after reading the answer from @moewe, I've compared the standard style. The most similar one, using biber would be authoryear. This one already use the author list for citing, hence I'd juste need to update the style to remove the year. But this is only partially filling my requirement. On the good side, the code compile and produce authors separated by "/". But there are still the issues :

  • Both the citation and the bibliography shows Small Caps on the name. But I don't have a setting for this and the authoryear do not seems to be having one neither. Why is it working ?
  • I cannot remove the year from the citation
  • I could remove the "," between the year and the location, but cannot manage to have a space in-between.

Any idea why ?

Here are my new BBX/CBX file.

biblatex-xawi.cbx

\ProvidesFile{biblatex-xawi.cbx}[2018/04/13 v1.0 alpha]
\RequireCitationStyle{authoryear}
\endinput

biblatex-xawi.bbx

\ProvidesFile{biblatex-xawi.bbx}[2018/04/13 v1.1 alpha)]
\RequireBiber[2]

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

\DeclareFieldFormat{title}{\textit{#1}}

\DeclareBibliographyDriver{book}{%
  \printnames{author}%
  \newunit\newblock
  \printfield{title}%
  \newunit\newblock
  \printlist{location}%
  \newblock
  \printfield{year}%
  \finentry}
\endinput
5
  • 1
    The .cbx file normally defines \cite and friends. Yours doesn't define any commands, so there is no \cite. – moewe Apr 13 '18 at 15:02
  • 2
    Start with a standard set of .cbx and .bbx files, as close to your intentions as you can get, and modify from there, using \RequireBibliographyStyle and RequireCitationStyle to load the base before you modify it. – Paul Stanley Apr 13 '18 at 15:14
  • 1
    Your first step would be to find the standard style that is the best match for what you want. The standard styles are listed in §3.3 Standard Styles of the biblatex documentation and examples for each style are found in ctan.org/tex-archive/macros/latex/contrib/biblatex/doc/examples (the ones with style in the name). This is also the advice given in Dominik Waßenhoven's article that I linked in my comment here – moewe Apr 13 '18 at 15:22
  • Seconding moewe's suggestion, as I also recommended you in the other question. I might add that you can also load one of the available styles and customize it directly in your preamble, instead of creating new style files. If the changes are not too extensive (I don't see they would be, by your listed requirements), this might simplify things somewhat. – gusbrs Apr 13 '18 at 15:28
  • Related tex.stackexchange.com/q/110511/35864 – moewe Apr 13 '18 at 16:15
6

What do the .bbx and .cbx files do?

The .cbx file defines the appearance of citations in your style. In particular it defines all available \cite... macros and their output. There is no fallback definition for \cite and friends.

The .bbx file defines the output of items in the bibliography. The primary tool to do this is by defining the bibdrivers with \DeclareBibliographyDriver. Only entry types that have a bibdriver defined for them can be displayed.

There are no fallback .cbx or .bbx files that are silently loaded in the background. That means that biblatex does not provide 'sensible' default definitions for \cite and the bibdrivers if you write your own style and forget about them. The only file that is always loaded and defines a great many bibmacros is biblatex.def, but it does not define citation commands and it does not define bibdrivers.

The general approach

There are two and a half approaches to writing your own style.

  1. Don't write your own style, only apply a few small modifications that you can carry around in the preamble or a simple .tex on top of an existing style.
  2. Write your own style based on another style using \RequireBibliographyStyle in the .bbx file and \RequireCitationStyle in the .cbx file. With this approach your new style internally loads another style and then modifies it.
  3. Write a new style by copying (and renaming!) the .cbx and .bbx files of an existing style and modifying them directly.

The zeroth method is useful if you expect very few very simple modifications.

If you anticipate a full rewrite of the style and expect you'll only be able to use little of what is already in the standard styles, you will want to go for approach 2. The more changes you expect and the more complicated your style gets, the more attractive this method gets.

Method 1, the \Require...Style, strikes a balance between the two other methods. It allows you to build on top of an existing style while keeping the code for the bibliography formatting in a separate file.

I guess you'll want to choose between method 1 and 2. If you use method 1 your file is shorter and easier to understand. You can also benefit from updates and bugfixes in the underlying standard style. But here lies the greatest weakness as well: An update of the underlying style could impact your modifications to a point that they don't work as intended any more. Normally changes to the styles only introduce new features and should rarely be detrimental to existing modifications, but some changes can be problematic (the name changes in 3.8 come to mind, see https://github.com/plk/biblatex/issues/700). Method 2 is not susceptible to changes in the standard styles, only to changes in the core functions. But that method does not automatically let you benefit from bug fixes and new features in the standard styles. This is similar to the situation in Biblatex's bibmacros, bibliography drivers, formats - patch or redefine?.

Normally I would go for method 1. But if your style is very outlandish, method 2 might be safer. Law styles are often quite intricate and so I am tempted to recommend method 2 here. Still I would go for method 1 even in your case.

There are examples of both methods on CTAN. biblatex-apa and biblatex-chicago go for method 2. biblatex-ieee, biblatex-chem and biblatex-nature formally use method 1, but redefine a great many things so that they almost ends up looking and behaves very much like method 2.

Related Customizing a biblatex style - can I start with lockstep's post? and Biblatex.cfg vs .cls vs .sty.

Let us assume you go for method 1 in the following.

Find the closest standard style

For all of these methods you should at first identify the biblatex standard style that comes closest to what you want. The styles and their features are explained in §3.3 Standard Styles of the biblatex documentation. Examples for each style can be found in https://www.ctan.org/tex-archive/macros/latex/contrib/biblatex/doc/examples the style examples have -style- in their name and go from 30 to 82. Don't pick the first style that seems to be alright. Have a look at everything that is available, experiment with the features, use the styles in an example document before you decide.

Let's assume it turns out verbose-inote comes closest to what you want. You would then create a biblatex-xawi.bbx containing

\ProvidesFile{biblatex-xawi.bbx}[2018/04/13 v0.1 bibliography style for Swiss Law (XaWi)]

\RequireBibliographyStyle{verbose-inote}

\endinput

and a biblatex-xawi.cbx containing

\ProvidesFile{biblatex-xawi.cbx}[2018/04/13 v0.1 citation style for Swiss Law (XaWi)]

\RequireCitationStyle{verbose-inote}

\endinput

Customise the citations and bibliography

Now begin to modify the style. Changes to the bibliography go into the .bbx, changes to citations into the .cbx.

While working on the style it is useful to always have the biblatex documentation at hand. I also always have standard.bbx and biblatex.def open, most bibliography macros are defined there. You will also want to have the style you are basing your style on open, in our example that means verbose-inote.cbx and verbose-inote.bbx, but verbose-inote.bbx just refers you back to authortitle.bbx, so you will have that open as well.


Why does your example not work?

Your example in the question writes a completely new style without \Require...Style and thus is very much like method 2 (without the copying). As mentioned in the beginning only citation commands that were defined in the .cbx file are available. But the .cbx file defines nothing, so no citation commands can be used.


Re your follow-up questions

  • The French localisation module automatically sets family names in small caps. This can be disabled with \UndefineBibliographyExtras{french}{\restorecommand\mkbibnamefamily}. For other languages you would do

    \renewcommand*{\mkbibnamefamily}{\textsc}
    

    to get family names in small caps. You can find out about the language-specific behaviour in the .lbx files. Normally a style author need not worry too much about the additional settings in the .lbx files, they change the localisation strings and a few other things, notably the date format. french.lbx's changing the definition of \mkbibnamefamily is among the more unusual and drastic changes applied by .lbx files.

  • If you want to remove the year from the citations, you should not be using authoryear as base for your style.

  • You would need

    \printlist{location}%
    \setunit{\addspace}%
    \printfield{year}%
    

    in your bibdriver. You should consider making your driver more modular. Have a look at the structure of the standard bibdrivers in standard.bbx.

15
  • Brilliant answer, not just to this question but for anyone considering writing a biblatex style. – Paul Stanley Apr 13 '18 at 17:28
  • I second @PaulStanley, this is a brillant answer. I'll definitively follow the path you describe and report my progress here. BTW, what would be the best approach? Write it as an edit or making a self-answer to my question ? – XaWin Apr 13 '18 at 20:09
  • @xawi you could also ask a new question in the form of "How to write a new biblatex style and upload it to ctan?", answer it yourself, explaning step by step what works and your major mistakes along the way, linking to this answer, and finally, make it a community wiki to encourage people to work on one consistent answer, not provide bits and pieces in separate answers that won't stay in order anyway. I would closely follow your work! – thymaro Apr 14 '18 at 6:20
  • @XaWi You may want to consider writing a blog post for tex-talk.net (the former community blog of this site) or similar. Somehow I feel that progress report kind of posts don't quite fit the Q&A structure of this site. What would work slightly better in my head is if you write a Q&A once you are finished. You could also consider writing an article for TUGboat or your local TeX users group's publication when you are done. – moewe Apr 14 '18 at 11:52
  • @moewe : thanks for the guide, I solved the issue with the "cite", and I've done a follow-up questions. I'd appreciate your feedback, as after several hours of works, I'm still stuck. Plus the test process is not an easy one : 3 xelatex + 1 biber, that's really time-consuming, when you're debugging – XaWin Apr 15 '18 at 17:56

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.
https://tex.stackexchange.com/questions/426387/custom-style-breaks-the-cite-command
tex.stackexchange.com
crawl=CC-MAIN-2021-10
181124
application/http; msgtype=response
sha1:757KLINMPL2LGQBDP3G572AT3CHMMMQN
<urn:uuid:a0fda876-4ec8-4e7e-99df-53448d106f99>
2021-03-03T12:13:38Z
151.101.193.69
text/html
sha1:DMHFNJAR6FLUDPD2GXTHDTVMS74P4TPW
<urn:uuid:57639e26-835d-449a-b327-84a56144253f>
https://tex.stackexchange.com/questions/426387/custom-style-breaks-the-cite-command
response
<urn:uuid:8bdbfa98-ddd6-4903-aa95-7c4389120329>
isPartOf: CC-MAIN-2021-10
publisher: Common Crawl
description: Wide crawl of the web for February/March 2021
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-39.ec2.internal
software: Apache Nutch 1.18 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/