0

I was wondering whether it's possible to add a biblatex entry type (as I do not wish to use a different biblatex style) to something like "law".

When it comes to law, unfortunately my university's ruleset is not too strict (so I don't know if and where to add fields like "publisher", "location" and such - if you have a neat idea, let me know!) - however there are some requirements when it comes to law texts:

The law bibliography entry should start with the title instead of author/editor/institution/organization and so on.

I have tried to stick to this: example, however, it doesn't work (I tried the exact sample, which worked, however, when I changed configurations in terms of class, bibliography and tried to compile, it already broke. I am also completely lost, why that happens and just tried to still adapt things to my necessities, which obviously didn't work either)

That's my current non-working MWE, which does not even contain any bib formatting, since I already failed many steps earlier.

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@legislation{help,
 legaltitle = {Kaisei minp\={o} j\={o}bun},
 law = {Saik\={o}-saiban-sho},
 date = {1947},
 location = {T\={o}ky\={o}},
 maintitle = {testmaintitle},
 legaltitleaddon = {{\"U}berarbeiteter Gesetzestext des Zivilgesetzbuchs},
 doi = {10.11501/1275567},
 urldate = {2019-08-01},
 legalbook = {5},
 legalchapter = {3},
 legalarticle = {2}
}
\end{filecontents*}
\begin{filecontents}{legislation.dbx}
\DeclareDatamodelEntrytypes{legislation}
\DeclareDatamodelFields[type=field,datatype=literal]{
  court,
  legalcode,
  law,
  legaltitle,
  legaltitleaddon
}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  legalbookno,
  legalchapterno,
  legalarticleno
  }
\DeclareDatamodelEntryfields[legislation]{
  court,
  legalcode,
  legaltitle,
  legaltitleaddon,
  law,
  date,
  urldate,
  legalbookno,
  legalchapterno,
  legalarticleno,
  maintitle,
  maintitleaddon,
  url,
  doi,
  location
}
\end{filecontents}
\documentclass[a4paper]{scrartcl}
\usepackage[main=ngerman, english]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[ngerman]{isodate}
\usepackage[ngerman]{datetime}
\usepackage[datamodel=legislation,backend=biber]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}

\DeclareLanguageMapping{ngerman}{legislation}

\DeclareFieldFormat[legislation]{legaltitle}{#1\isdot}
\DeclareFieldFormat{titleaddon}{\mkbibbrackets{#1}}
\DeclareFieldAlias{legaltitleaddon}{titleaddon}

\newbibmacro*{bookchaparticle}{%
  \bibstring{legalbook}%
 \printfield{legalbookno}
 \setunit{\addcomma\space}
   \bibstring{legalchapter}%
 \printfield{legalchapterno}
 \setunit{\addcomma\space}
   \bibstring{legalarticle}%
 \printfield{legalarticleno}

\DeclareBibliographyDriver{legislation}{%
  \usebibmacro{bibindex}%
  \usebibmacro{bookchaparticle}%
  \newunit\newblock
  \usebibmacro{finentry}}

\begin{document}
\nocite{*}
\cite{help}

\printbibliography
\end{document}

Thank you!

output before (currently no output due to errors in my code): current output required output: required output

That's what I tried to use as the closest example to this one, however this also doesn't work.

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@stackexchange{se:l3help,
  sitetopic = {tex},
  title   = {What can \textit{I} do to help the \LaTeX3 Project},
  askdate = {2012-02-26},
  askid   = {45838},
  askp    = {Brent Longorough},
  askpid  = {344},
  ansp    = {Frank Mittelbach},
  anspid  = {10109},
  ansdate = {2012-03-01},
  ansid   = {46427},
}
\end{filecontents*}
\begin{filecontents}{stackexchange.dbx}
\DeclareDatamodelEntrytypes{stackexchange}
\DeclareDatamodelFields[type=field,datatype=literal]{
  sitekey,
  sitetopic,
}
\DeclareDatamodelFields[type=list,datatype=name]{
  askp,
  ansp,
}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
  askdate,
  ansdate,
  askeditdate,
  anseditdate}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  askid,
  askpid,
  anspid,
  ansid,
}
\DeclareDatamodelEntryfields[stackexchange]{
  sitekey,
  sitetopic,
  askid,
  askp,
  askpid,
  ansp,
  anspid,
  ansid,
  askyear,
  askmonth,
  askday,
  ansyear,
  ansmonth,
  ansday,
  askedityear,
  askeditmonth,
  askeditday,
  ansedityear,
  anseditmonth,
  anseditday,
  title}
\end{filecontents}
\documentclass[
  12pt,
  a4paper,
  headings=standardclasses,
  listof=totoc,
  numbers=noenddot
]{scrartcl}

\usepackage{showframe}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.00cm, footskip=1cm]{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage[main=ngerman, english]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[ngerman]{isodate}
\usepackage[ngerman]{datetime}
\usepackage[
  backend=biber,
  style=ext-authoryear,
  sorting=nyvt,
  datamodel=journaltitleaddon,
  maxnames=25,
  innamebeforetitle=true,
  usetranslator=true,
  alldates=terse,
  labeldate=year,
  dashed=false,
  isbn=false
]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}

\begin{filecontents*}{english-stack.lbx}
  \ProvidesFile{english-stack.lbx}[2014/05/07 english with additions for stackexchange]
  \InheritBibliographyExtras{english}
  \NewBibliographyString{asked,answered,edited}
  \DeclareBibliographyStrings{%
    inherit   = {english},
    asked     = {{asked}{asked}},
    answered  = {{answered}{answered}},
    edited    = {{edited}{edited}},
  }
\end{filecontents*}
\DeclareLanguageMapping{ngerman}{ngerman}

\DeclareFieldFormat[stackexchange]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat{askpid}{%
  \mkbibparens{\ifhyperref
    {\href{http://tex.stackexchange.com/users/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}}

\DeclareFieldFormat{anspid}{%
  \mkbibparens{\ifhyperref
    {\href{http://tex.stackexchange.com/users/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}}

\DeclareFieldFormat{askid}{%
  \mkbibparens{\ifhyperref
    {\href{http://tex.stackexchange.com/q/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}}

\DeclareFieldFormat{ansid}{%
  \mkbibparens{\ifhyperref
    {\href{http://tex.stackexchange.com/a/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}}

\newbibmacro*{stackexchangequestion}{%
  \printfield{title}%
  \setunit{\addspace}%
  \printfield{askid}%
}

\newbibmacro*{stackexchangeask}{%
  \bibstring{asked}%
  \setunit{\addspace}%
  \printaskdate%
  \iffieldundef{askedityear}%
    {}
    {\printtext[parens]{%
       \bibstring{edited}%
       \setunit{\addspace}%
       \printaskeditdate}}%
  \setunit{\addspace}%
  \bibstring{byauthor}%
  \setunit{\addspace}%
  \printnames{askp}%
  \setunit{\addspace}%
  \printfield{askpid}%
}

\newbibmacro*{stackexchangeans}{%
  \bibstring{answered}%
  \setunit{\addspace}%
  \printansdate%
  \iffieldundef{ansedityear}
    {}
    {\printtext[parens]{%
       \bibstring{edited}%
       \setunit{\addspace}%
       \printanseditdate}}%
  \setunit{\addspace}%
  \bibstring{byauthor}%
  \setunit{\addspace}%
  \printnames{ansp}%
  \setunit{\addspace}%
  \printfield{anspid}%
}

\newbibmacro*{stackexchangesite}{%
  \printfield{sitetopic}}

\DeclareBibliographyDriver{stackexchange}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{stackexchangequestion}%
  \newunit\newblock
  \usebibmacro{stackexchangeask}%
  \newunit\newblock
  \usebibmacro{stackexchangeans}%
  \newunit\newblock
  \usebibmacro{stackexchangesite}%
  \newunit\newblock
  \usebibmacro{finentry}}

\begin{document}
\nocite{*}
\cite{se:l3help}

\printbibliography
\end{document}
  • 1
  • 1
    The existing types @jurisdiction, @legislation and @legal might be appropriate (check the biblatex docs for their intended meaning), but the standard styles all treat them as @misc. So the types are there, but work is probably needed to get them to look like you want. – moewe Jul 23 '19 at 20:29
  • Hey @moewe, sorry for all the questions! I have tried to use your MWE (tex.stackexchange.com/questions/175776/…) and change it according to the wording I will use - however it doesn't recognise my bibstrings and I have tried to figure out how to fix that for hours now - I have not even started to try to style them according to my uni's ruleset, as I thought, I'd just like it to basically work first - however I even failed to do that - however, I have updated my MWE (which doesn't work) – user168390 Jul 24 '19 at 9:04
2

There is one syntax error in the MWE that makes things break down badly quite quickly. The block

\newbibmacro*{bookchaparticle}{%
  \bibstring{legalbook}%
 \printfield{legalbookno}
 \setunit{\addcomma\space}
   \bibstring{legalchapter}%
 \printfield{legalchapterno}
 \setunit{\addcomma\space}
   \bibstring{legalarticle}%
 \printfield{legalarticleno}

is missing a closing curly brace. Just add the missing } at the end. That's pretty much it for the error!

If the } is added, the example will compile, but the output won't quite be as expected. That is due to two reasons.

  1. The MWE uses bibliography strings, but doesn't declare or translate them (you did so in an earlier iteration of your question and I just copied the relevant .lbx file from there).

  2. There seems to be a slight mixup with the field names: Sometimes it says legalbookno (in the .dbx and the driver), sometimes legalbook (in the .bib file). Similarly for legalarticle(no) and legalchapter(no). I saw little point in adding the no and normalised all names to legalbook, legalchapter, legalarticle.

Finally one small aesthetic detail: I prefer to use \bibstring in field formats instead of the bibmacros directly, so that is what I did here.

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@legislation{help,
 legaltitle      = {Kaisei minpō jōbun},
 law             = {Saikō-saiban-sho},
 date            = {1947},
 location        = {Tōkyō},
 maintitle       = {testmaintitle},
 legaltitleaddon = {Überarbeiteter Gesetzestext des Zivilgesetzbuchs},
 doi             = {10.11501/1275567},
 urldate         = {2019-08-01},
 legalbook       = {5},
 legalchapter    = {3},
 legalarticle    = {2},
}
\end{filecontents*}
\begin{filecontents}{legislation.dbx}
\DeclareDatamodelEntrytypes{legislation}
\DeclareDatamodelFields[type=field,datatype=literal]{
  court,
  legalcode,
  law,
  legaltitle,
  legaltitleaddon,
  legalbook,
  legalchapter,
  legalarticle,
}
\DeclareDatamodelEntryfields[legislation]{
  court,
  legalcode,
  legaltitle,
  legaltitleaddon,
  law,
  date,
  urldate,
  legalbook,
  legalchapter,
  legalarticle,
  maintitle,
  maintitleaddon,
  url,
  doi,
  location,
}
\end{filecontents}
\begin{filecontents*}{legislation-ngerman.lbx}
\ProvidesFile{legislation-ngerman.lbx}[2019 Legislation according to IOA]
\InheritBibliographyExtras{ngerman}

\DeclareBibliographyStrings{%
  inherit       = {ngerman},
  legalbook     = {{legalbook}{legalbook}},
  legalchapter  = {{legalchapter}{legalchapter}},
  legalarticle  = {{legalarticle}{legalarticle}},
}
\end{filecontents*}
\documentclass[a4paper]{scrartcl}
\usepackage[main=ngerman, english]{babel}
\usepackage[babel, german=quotes]{csquotes}
\usepackage[ngerman]{isodate}
\usepackage[ngerman]{datetime}
\usepackage[datamodel=legislation,backend=biber]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}

\NewBibliographyString{legalbook,legalchapter,legalarticle}
\DeclareLanguageMapping{ngerman}{legislation-ngerman}

\DeclareFieldFormat[legislation]{legaltitle}{#1\isdot}
\DeclareFieldFormat{titleaddon}{\mkbibbrackets{#1}}
\DeclareFieldAlias{legaltitleaddon}{titleaddon}

\DeclareFieldFormat{legalbook}{\bibstring{legalbook}~#1}
\DeclareFieldFormat{legalchapter}{\bibstring{legalchapter}~#1}
\DeclareFieldFormat{legalarticle}{\bibstring{legalarticle}~#1}

\newbibmacro*{bookchaparticle}{%
  \printfield{legalbook}%
  \setunit{\addcomma\space}%
  \printfield{legalchapter}%
  \setunit{\addcomma\space}%
  \printfield{legalarticle}}

\DeclareBibliographyDriver{legislation}{%
  \usebibmacro{bibindex}%
  \usebibmacro{bookchaparticle}%
  \newunit\newblock
  \usebibmacro{finentry}}

\begin{document}
\nocite{*}
\cite{help}

\printbibliography
\end{document}

Legalbook 5, legalchapter 3, legalarticle 2.


biblatex only allows you to load a single .dbx file, which is no real obstacle for your use case, since you are the one writing all of the .dbx files anyway, and so it is no big deal to merge them. But there are workarounds to load several if need be: Datamodel distribution with biblatex, https://ctan.org/pkg/biblatex-multiple-dm.

I'd keep the field names as short as possible and would try to re-use as existing fields. So I would probably rename legalbook to book etc. I didn't see the need to declare legalarticle and friends as verbatim (where similar to \begin{verbatim}...\end{verbatim} special characters don't have their special meaning; this is useful for URL-like fields), so I turned them into a "normal" literal. I also don't quite get the meaning of law and legaltitle vs. title, maintitle etc.

| improve this answer | |
  • thank you very much! I have spent the whole day trying to figure things out - thanks for all the help! I managed to get a MWE, however there are some small things, that still need to be changed and I don't know how - would it be okay to add them to this ticket or create a new one? – user168390 Jul 24 '19 at 17:46
  • @user168390 In general I think it is frowned upon to completely rewrite the question after you have gotten an answer, especially if it completely invalidates the answer. It would be nicer to ask a new question. I won't have time to look at this tonight anyway, but I will have a look tomorrow (preferably in a new question, with this one rolled back to its state when I answered it; but if you absolutely don't want to do that I'll try to see what to do with this answer here). – moewe Jul 24 '19 at 20:26

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.