1

In one of my report, I need to differentiate several "type" of thesis, which are basically Law PhD thesis and a special one, called "Thèse d'habilitation", which is a pre-requisite to become "full" Law Professor in some Swiss Universities. This is a follow-up from my previous question

The entry should only differ by the bibliography entry, meaning that the type should be :

  • Plain thesis : "Author first, Title, Thèse City Year"
  • These d'habilitatiom should be : "Author first, Title, Thèse d'habilitation City Year"

My analysis

So I've bumped on the type redefinition of biblatex documentation, page 13 (2.1.2 Type Aliases) and my problem is basically to create new Type alias and link the "type" field to the right entry. That's what "biblatex" does with the "alias type" phdthesis and master thesis, which is : - Link to the thesis entry type - Define the field "type" with a default string

But I'm stuck with what I've identified as being the code used in biblatex.cfg file :

% ------------------------------------------------------------------
% Driver sourcemaps
% ------------------------------------------------------------------
\DeclareDriverSourcemap[datatype=bibtex]{
  \map{
    \step[fieldset=day, null]
  }
  \map{
    \step[typesource=conference, typetarget=inproceedings]
    \step[typesource=electronic, typetarget=online]
    \step[typesource=www,        typetarget=online]
  }
  \map{
    \step[typesource=mastersthesis, typetarget=thesis, final]
    \step[fieldset=type,            fieldvalue=mathesis]
  }
  \map{
    \step[typesource=phdthesis, typetarget=thesis, final]
    \step[fieldset=type,        fieldvalue=phdthesis]
  }
  \map{
    \step[typesource=techreport, typetarget=report, final]
    \step[fieldset=type,         fieldvalue=techreport]
  }
  \map{
    \step[fieldsource=hyphenation,   fieldtarget=langid]
    \step[fieldsource=address,       fieldtarget=location]
    \step[fieldsource=school,        fieldtarget=institution]
    \step[fieldsource=annote,        fieldtarget=annotation]
    \step[fieldsource=archiveprefix, fieldtarget=eprinttype]
    \step[fieldsource=journal,       fieldtarget=journaltitle]
    \step[fieldsource=primaryclass,  fieldtarget=eprintclass]
    \step[fieldsource=key,           fieldtarget=sortkey]
    \step[fieldsource=pdf,           fieldtarget=file]
  }
}

First, I've tried to declare some new field in my custom lbx file, as showed in the other question I had. This gave me :

biblatex-xawi.lbx

\DefineBibliographyStrings{french}{typethesis = {Thèse}}
\DefineBibliographyStrings{french}{typethabilitation = {Thèse d'habilitation}}

And I've added a copy-paste of the biblatex source :

biblatex-xawi.bbx

\DeclareDriverSourcemap[datatype=bibtex]{
      \map{
        \step[typesource=thesedroit, typetarget=thesis, final]
        \step[fieldset=type,            fieldvalue = typethesis]
      }
      \map{
        \step[typesource=thesehabilitation, typetarget=thesis, final]
        \step[fieldset=type,        typethabilitation = phdthesis]
      }
    }

But as before, I'm not really gifted with the Biblatex style creation, as I'm having an error :

Package xkeyval Error: `typethabilitation' undefined in families `blx@sourcemap@step'.

See the xkeyval package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.116     }

Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

My questions

Question 1 : in general, how can I create "simple" alias, for example redirecting my entry type "ouvragegeneral" to a "book" type (in order to help by users).

Question 2 : if I need to create alias and do some "piping" how can I create my 2 thesis types ?

Accepted answer & feedback

The error returned was that my custom string being defined but not See other question&answer here

2

Here is a solution that also maps @habilthesis to @thesis with type habilthesis. It also adds the generic type thesis to all @thesis entries without an explicit type.

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[style=authoryear]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@phdthesis{normalthesis,
  author = {Author Normal},
  title = {Title PhD Thesis},
  date = {2016},
}
@thesis{mormalthesis,
  author = {Author Mormal},
  title = {Title PhD Thesis},
  date = {2017},
  type = {phdthesis},
}
@thesis{mythesis,
  author = {Author These},
  title = {Title Thèse},
  date = {2014},
}
@habilthesis{habilthesis,
  author = {Author Habilitation},
  title = {Title Thése Habilitation},
  date = {2014},
}
@thesis{habilthesis2,
  author = {Author Habilitation},
  title = {Title Thése Habilitation},
  date = {2014},
  type = {habilthesis},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\NewBibliographyString{thesis,habilthesis}

\DefineBibliographyStrings{french}{
  thesis      = {thèse},
  habilthesis = {thèse d'habilitation},
}

\DeclareStyleSourcemap{
  \maps[datatype=bibtex,overwrite=false]{
    \map{
      \step[typesource=habilthesis, typetarget=thesis, final]
      \step[fieldset=type,          fieldvalue=habilthesis]
    }
    \map{
      \pertype{thesis}
      \step[fieldset=type, fieldvalue=thesis]
    }
  }
}

\begin{document}
\nocite{*}

\printbibliography

\end{document}

Let me add a few more words since we discussed this in the comments to the other answer.

  • It would be possible and maybe even conceptually nicer to only use the @thesis entry type and give the thesis type in the type field.
  • I do not see the value of creating French entry types like @these for @thesis or German localisations like @buch for @book. This will severely impact portability of a .bib file that uses these types and makes it essentially incompatible with any other style. Since people need to learn the valid types anyway, I think it is acceptable to let them learn the English types.
  • Ideally there is no distinction between 'biblatex commands' and 'Biber commands'. As far as I am concerned, there are only biblatex commands and a subset of these is not supported by BibTeX or BibTeX8. BibTeX is considered a legacy backend now and even the biblatex documentation generally assumes that new documents always use Biber. Some commands trigger effects on the Biber-level, some trigger effects on the biblatex-level, others work on all levels. It is not at all considered impure to 'mix' these commands and there is no reason why it should be discouraged to do so. Of course it can greatly help to understand the workings of your style if you know which command changes what at what level, but you should not avoid the Biber-level just for the sake of avoiding it. Some things that can be done easily on the Biber-level can be recreated with more work and a few rough edges on the biblatex level - but in general there is little point in doing that.
  • The command \DeclareStyleSourcemap is documented in the biblatex manual.
  • (+1) Glad to see you incorporated the point on portability of the bib file. :) I do think this is a relevant issue. And the OP may well get to define a new entrytype that's bibtex-driver compatible with the use of a datamodel. But I really don't see what'd be the point of that. – gusbrs Apr 25 '18 at 10:51
3

I think you are overcomplicating this one. The thesis entrytype should handle your requirements with little overhead, if any.

The type field of thesis works the following way. If there is as bibstring defined that equals the type, then it uses the bibstring, otherwise it uses the field as is.

So, there is one very simple alternative, which is to write "Thèse" or "Thèse d'habilitation" directly in the type field:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[style=authoryear]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
  @thesis{normalthesis,
    author = {Author Normal},
    title = {Title Normal Thesis},
    date = {2016},
    type = {phdthesis},
  }
  @thesis{mythesis,
    author = {Author These},
    title = {Title Thèse},
    date = {2014},
    type = {Thèse},
  }
  @thesis{habilthesis,
    author = {Author Habilitation},
    title = {Title Thése Habilitation},
    date = {2014},
    type = {Thèse d'habilitation},
  }

\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}

\printbibliography

\end{document}

If you want something more automatic and eventually localized, you have simply to create the bibstring and define it to the relevant language:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[style=authoryear]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
  @thesis{normalthesis,
    author = {Author Normal},
    title = {Title Normal Thesis},
    date = {2016},
    type = {phdthesis},
  }
  @thesis{mythesis,
    author = {Author These},
    title = {Title Thèse},
    date = {2014},
    type = {mythesis},
  }
  @thesis{habilthesis,
    author = {Author Habilitation},
    title = {Title Thése Habilitation},
    date = {2014},
    type = {habilthesis},
  }

\end{filecontents}

\addbibresource{\jobname.bib}

\NewBibliographyString{mythesis,habilthesis}

\DefineBibliographyStrings{french}{
  mythesis = {Thèse},
  habilthesis = {Thèse d'habilitation},
}

\begin{document}
\nocite{*}

\printbibliography

\end{document}

Either way, the result is:

enter image description here

  • 2
    +1) I'd prefer thesis instead of mythesis, a sourcemap could be used to make sure that a @thesis without a specific type field always gets type = {thesis} and you could of course recreate what Biber does for @phdthesis for @habilthesis as well: gist.github.com/moewew/5217d7a0aa8622db971739ad758d4145 – moewe Apr 24 '18 at 19:36
  • @moewe, with mythesis I was trying to illustrate the mechanism on how an arbitrary bibstring, as long as it is defined, is sufficient. And yes, we could have the entrytype with the sourcemap, and this was requested by the OP. But I feel it is unnecessary and would not help the portability of the bib file, thus my recommendation to use plain @thesis. – gusbrs Apr 24 '18 at 19:43
  • @moewe, furthermore, I think a thesis type for the thesis entrytype may well qualify as a "tongue twister". :) – gusbrs Apr 24 '18 at 19:58
  • 1
    @XaWi Why would you want that? It might be possible to mimic some of the effects of the shown \DeclareStyleSourcemap on the biblatex level. That would definitely mean more work, it would be less elegant and it might not behave as expected in all cases. Nowadays everyone should be using Biber as backend anyway (BibTeX is considered a legacy backend, even the biblatex documentation assumes you use Biber). So there is no point to restrict yourself to biblatex-level commands when Biber can do it for you much quicker. – moewe Apr 25 '18 at 8:37
  • 1
    @XaWi What I will say, though, is that you can get away without any mappings of entry types if you only ever use the entrytype @thesis and populate its type field yourself with the appropriate strings (thesis, phdthesis, habilthesis) - this is essentially what the answer here does. – moewe Apr 25 '18 at 8:47

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.