I am currently adding the possibility to my style biblatex-fiwi
to add an alternative title to films. This is in itself is not complicated. But I also want a mechanism which handles different scripts. The idea is that, depending on the script, a bibmacro will be created which can later be defined to load a specific supports which supports the needed script.
I added the two fields alternatetitle
and alternatetitlescript
. For this, the following lines must be added to a .dbx-File, for example biblatex-dm.cfg
:
\DeclareDatamodelFields[type=field, datatype=literal]{alternatetitle}
\DeclareDatamodelFields[type=field, datatype=literal]{alternatetitlescript}
\DeclareDatamodelEntryfields[movie,misc,video]{alternatetitle, alternatetitlescript}
The following MWE example is a bit complicated:
\RequirePackage{filecontents} \begin{filecontents}{\jobname.bib}
@movie{themovie,
Address = {USA},
Alternatetitle = {Аэлита},
Alternatetitlescript = {cyrillic},
Director = {Mad, Max},
Title = {The Title},
Year = {1996}}
\end{filecontents}
\documentclass{article}
\usepackage[style=fiwi]{biblatex}
\usepackage{ragged2e}
\renewbibmacro*{filmtitle}{\iffieldundef{maintitle}
{\printtext{\printfield[film]{title}}}
{\printfield[film]{maintitle}\newunit}%
\iffieldundef{alternatetitle}
{}
{\usebibmacro{bbx:cite-alternatetitle}}
\iffieldundef{subtitle}%
{}%
{\setunit{}%
\printtext{\addspace\printfield{subtitle}}}%
\iffieldundef{volume}%
{}%
{\printfield[season]{volume}}%
\iffieldundef{number}%
{}%
{\addcomma\addspace\printfield[episode]{number}}%
\iffieldundef{maintitle}%
{}%
{\addcolon\addspace\printfield[film]{title}}%
\ifpunctmark{!}{\unspace.\newunit}{\adddot}}%
\newbibmacro*{bbx:cite-alternatetitle}{
\iffieldundef{alternatetitlescript}
{\addslash\printfield{alternatetitle}}
{\addslash\ifbibmacroundef{altscript:\strfield{alternatetitlescript}-font}
{\textsc{\thefield{alternatetitle}}}{\usebibmacro{altscript:\strfield{alternatetitlescript}-font}%
{\thefield{alternatetitle}}} }}
\addbibresource{\jobname.bib}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\newbibmacro*{altscript:cyrillic-font}[1]{\newfontfamily\cyrfont[Extension = .ttf,]{Linux Libertine}{\cyrfont{\textsc{#1}}}}
\begin{document}
\citefilm{themovie}
\printbibliography
\end{document}
The idea is that a macro called altscript:<alternatetitlescript>-font
is created which can the be defined in the document. The problem is that the content of alternatetitlescript
is not resolved. This is even more strange, as the test whether alternatetitlescript
is empty or not, actually works. But later when it should be become part of the macro name, the content alternatetitlescript
seems not available.
\usebibmacro
:\usebibmacro*{altscript:\strfield{alternatetitlescript}-font}{\thefield{alternatetitle}}
, the starred version does not try to sanitise the name before use, which is what you need here.\the...
commands, but I have no idea how. (Though I believe\textsc{\thefield{alternatetitle}}
could probably be\printfield{alternatetitle}
+ an appropriate\DeclareFieldFormat
. Are you sure all those\iffieldundefs
are needed? Normally the punctuation tracker and the correct commands\setunit
/\setunit*
/\printunit
/\printunit*
should make sure you don't get into trouble because of missing fields.)DeclareFieldFormat
but this did not work with indexing.\DeclareIndexFieldFormat
.