2

Greetings from the Swiss Alps,

I would like to submit the following problem:

My intention is to create a new bibliography option which I can toggle at wish while loading the package biblatex-swiss-legal.

The general context

My MWE is as follows:

\documentclass[12pt,a4paper]{article}
\usepackage[french,german]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[style=biblatex-swiss-legal-general,backend=biber,autolang=other,jurisdictionindex=true,commentarystyle=styleA]{biblatex}
\addbibresource{Referencingtest.bib}

% Bibliography entries (using JabRef)

@Commentary{bskor1,     % This is the main entry, from which the customa (smaller)
location   = {Basel},   % citations  will be created, it only appears in the bibliography
date       = {2015},
title      = {Basler Kommentar. Obligationenrecht},
titleaddon = {OR},
editor     = {Honsell, Heinrich and Vogt, Nedim Peter and Wiegand, Wolfgang},
edition    = {6},
series     = {bsk},
volume     = {I},
}

@Customa{bsk19/20or,    % This entry will appear in the document
crossref = {bskor1},
author   = {Huguenin, Claire and Meize, Barbara},
part     = {19/20},
}

I would like to change the commentarystyle to styleD designed as following in the .bbx file:

\newbibmacro{customa:styleD}{% <-- This is actually a test, not having any idea 
\bibsstring{\thefield{series}}%    how it will look like, being unable to make it appear
\printtext{-}%                     on the pdf result
\printnames{labelname}%
\addcomma\addspace%
\printfield{titleaddon}\addspace%
\printfield{part}%
}%

And would supposably look like the:

BsK-Huguenin/Meize, OR 19/20 N 12.

Styles A, B and C look like this (these are somewhat modified compared to the original package, most of it concerning the punctuation without the use of \newblock nor \newunit):

\newbibmacro{customa:styleA}{%
\iffieldbibstring{series}%
{\bibsstring{\thefield{series}}}%
{\printfield{series}}%
\iffieldundef{series}{}{\printtext{-}}\printnames{labelname}\addcomma%
\iffieldundef{type}%
{%
\iftoggle{bbx:adarticle}%
    {\addspace}%
    {\addspace}%
}%
{%
\iffieldbibstring{type}%
    {\bibsstring{\thefield{type}}}%
    {\printfield{type}}%
\addspace}%
\iffieldundef{part}%
{}%
{\iftoggle{bbx:adarticle}%
    {\bibsstring{ad}\addspace}%
    {}%
\ifboolexpr{%
test {\iffieldequalstr{series}{beckkuko}}
or
test {\iffieldequalstr{series}{mnk}}
or
test {\iffieldequalstr{series}{nmk}}
or
test {\iffieldequalstr{series}{palandt}}
or
test {\iffieldequalstr{series}{stk}} 
}
{% Si le commentaire est allemand (DEU)
    \ifboolexpr{% Test pour savoir s'il y a plusieurs articles
    test {\IfSubStr{\thefield{part}}{-}}
    or 
    test {\IfSubStr{\thefield{part}}{f.}}
    or 
    test {\IfSubStr{\thefield{part}}{ff.}}
    or 
    test {\IfSubStr{\thefield{part}}{\psq}}
    or 
    test {\IfSubStr{\thefield{part}}{\psqq}}
    }
    {\bibstring{articlesde}}
    {\bibstring{articlede}}
}% 
{\bibsstring{article}}% Si le commentaire n'est pas allemand (donc suisse)
\addspace\printfield{part}%
}%
\addspace%
\printfield{titleaddon}%
}

\newbibmacro{customa:styleB}{%
\iffieldundef{series}
{\usebibmacro{customa:styleA}}% Si les séries ne sont pas définies, utilisation du style A
{\iffieldbibstring{series}%
{\bibsstring{\thefield{series}}\printtext{-}}%
{\iffieldundef{series}%
    {}%
    {\printfield{series}\printtext{-}}%
}%
\iffieldundef{titleaddon}%
{}%
{\printfield{titleaddon}\addspace}%
\iffieldundef{volume}%
{}%
{\thefield{volume}}%
\addcomma\addspace%
\printnames{labelname}%
\iffieldundef{type}%
{%
\iftoggle{bbx:adarticle}%
    {\addspace}%
    {\addspace}%
}%
{\addcomma\addspace%
\iffieldbibstring{type}{\bibsstring{\thefield{type}}}{\printfield{type}}%
\newunit}%
\iffieldundef{part}%
{}%
{\iftoggle{bbx:adarticle}%
    {\bibsstring{ad}\newunit}%
    {}%
\addcomma\addspace\bibsstring{article}\addspace\printfield{part}%
}%
}}%



\newbibmacro{customa:styleC}{%
\iftoggle{bbx:firstnames}
{\printnames{author}}%
{\printnames{labelname}}%
\iffieldundef{series}%
{}%
{\newblock\usebibmacro{printin}%
\iffieldbibstring{series}%
    {\biblstring{\thefield{series}}}%
    {\printfield{series}}%
}%
\iffieldundef{type}%
{%
\iftoggle{bbx:adarticle}%
    {\newunit}%
    {\newblock}%
}%
{\newblock%
\iffieldbibstring{type}{\bibsstring{\thefield{type}}}{\printfield{type}}%
\newunit}%
\iffieldundef{part}%
{}%
{\iftoggle{bbx:adarticle}%
    {\bibsstring{ad}\newunit}%
    {}%
\bibsstring{article}\addspace\printfield{part}%
}%
\addcomma\addspace%
\printfield{titleaddon}%
}

The respective styles as citation look as following:

Style A:

BsK-Huguenin/Meize, Art. 19/20 OR, N 12.

Style B:

BsK-OR I, Huguenin/Meize, Art. 19/20, N 12.

Style C:

Huguenin/Meize, in: Basler Kommentar, Art. 19/20 OR, N 12.

N.B.:

  • authors are supposed to be in small caps;
  • the German version of the package is being used;
  • "N 12" is side margin number used in Swiss commentaries, and is defined with \footcite command through this \providecommand{\chaparN}[2]{\S~#1 \parN #2} command created by the author.

I should mention that style C isn't of any use for my kind of papers, yet I'd prefer keeping the option open, should I need it.

My problem

I'm not seeking help concerning the part immediately above, rather more for what follows:

\DeclareBibliographyOption{commentarystyle}{%
 \ifcsdef{blx@opt@commentarystyle@#1}
{\blx@commentarystyle\csuse{blx@opt@commentarystyle@#1}}
{\blx@err@invopt{commentarystyle=#1}{}}}
\cslet{blx@opt@commentarystyle@styleA}\z@
\let\blx@opt@commentarystyle@styleB\@ne
\let\blx@opt@commentarystyle@styleC\tw@
\let\blx@opt@commentarystyle@styleD\ % this is where I'm having trouble.

Without the last ligne, I can't load the pkg with the styleD option, but I can't figure out what the ending (coming after the last \, like z@, @ne, tw@ for styles A, B and C respectively), since if I copy one of the other styles, the said style is used instead of the styleD.

Anyone has an idea on what combination of letters and @ to add at the end of the last line to make it possible to load?

Cheers,

Archein

The additional infos

P.S.: if you ever go looking at the original biblatex-swiss-legal package, it's actually quite old (Jan 2014) and doesn't take into consideration the new biblatex/biber changes since then, I already corrected the file.

P.S.S.: I beg for mercy if this question might seem stupid or easy to solve, I still new and trying to get my hands on biblatex.

  • 1
    Do you want to be able to use the commentarystyle option to choose your style? If not you could just do \newbibmacro{customa:styleA} and overwrite the A style (analogous for B or C). The code to switch between the style looks mighty complicated right now, but that could also be tackled if you insist. – moewe Aug 28 '16 at 16:38
  • (BTW: Please not that your MWE is not actuallyan MWE. This question probably doesn't need one - and it would not be easy to create one anyway since the biblatex style will probably throw all sorts of errors with a recent biblatex version. But for future reference, here's what makes a good MWE). – moewe Aug 28 '16 at 16:41
  • @moewe: no no, I would like to maintain styles A, B and C if possible, while still creating a new D style of my own for special kinds of documents. – Archein von Drakenov Aug 28 '16 at 16:50
  • (I'll make due note of that for the future, thanks! :) ) – Archein von Drakenov Aug 28 '16 at 16:51
  • @moewe This is going to be pretty hard to answer with a more complete example, though. If we don't know what changes have been made to the style, it is hard to be sure what will not conflict. Moreover, it is impossible to test any solution without updating that file to make it work with current packages. Since the OP has already done that, a link to the updated version (probably would need to be renamed for licence reasons) would surely make it easier. That's not an MWE, but an MWE wouldn't do any harm for testing, either. – cfr Aug 28 '16 at 23:50
3

The code in biblatex-swiss-legal-base.bbx for the selection of the customa style is not that easily extensible. We can make it though.

Replace the \DeclareBibliographyOption{commentarystyle} block with

\providebibmacro{customa:full}{}
\DeclareBibliographyOption[string]{commentarystyle}{%
  \ifcsdef{abx@macro@customa:#1}
    {\renewbibmacro{customa:full}{%
       \testibid{\usebibmacro{customa:#1}}}}
    {\blx@err@invopt{commentarystyle=#1}{you need to define the bibmacro 'customa:#1'}}}

Then you only need to move the \ExecuteBibliographyOptions code to the very end of the .bbx file to avoid premature errors.

From now on you can order commentarystyle=<styleX>, if the bibmacro customa:<styleX> is defined otherwise an error is issued.

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.