8

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>-fontis created which can the be defined in the document. The problem is that the content of alternatetitlescriptis not resolved. This is even more strange, as the test whether alternatetitlescriptis empty or not, actually works. But later when it should be become part of the macro name, the content alternatetitlescriptseems not available.

5
  • 1
    You will want to use the starred version of \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.
    – moewe
    Mar 18, 2016 at 7:27
  • That was easy, thanks! Please turn this into a proper answer.
    – Simifilm
    Mar 18, 2016 at 9:57
  • I feel that what you want should be doable more elegantly without the need for low-level \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.)
    – moewe
    Mar 18, 2016 at 10:08
  • I will look into that. I started out with a DeclareFieldFormat but this did not work with indexing.
    – Simifilm
    Mar 18, 2016 at 10:41
  • Indexing obeys \DeclareIndexFieldFormat.
    – PLK
    Mar 18, 2016 at 19:56

1 Answer 1

4

The unstarred version of \usebibmacro sanitises the macro name with a \detokenize. Since we want the \strfield{alternatetitlescript} to be expanded, we need to work around that. The starred version \usebibmacro* does not do any sanitising on the macro name and so

\usebibmacro*{altscript:\strfield{alternatetitlescript}-font}{\thefield{alterna‌​tetitle}}

works as expected.

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.