I would like to write something like

@string { subtype = "the-subtype" }

@string { entry = "the-entry1" } 
entrysubtype  = subtype,
file          = subtype # "/" # entry # ".pdf",
title         = {Title}type" } 

@string { entry = "the-entry2" } 
entrysubtype  = subtype,
file          = subtype # "/" # entry # ".pdf",
title         = {Title}

In my experience it looks like I can use variables to set value of tags but it don't work for entry key.

Can I use variables as entry key in bib files?


That won't work. The entry key is special and not a normal <field> = {<value>}, pair as all other fields, where @strings work. In particular the entry key has a slightly different 'value' syntax than the fields, which makes it impossible to tell whether one wants the text as written or a @string replacement. Normally BibTeX knows that you want the @string because there are no braces around a @string

title  = {Lorem ipsum}, % normal value
author = sigfridsson,   % @string

We can't do the same with the entry key because it is always given as


without braces.

I also doubt that it is a good idea to have several @strings with the same identifier (@string {entry = ...}).

As in your previous question How to magically add the file field to each entry in a bib file? I would suggest a source map to produce the file field on the fly from information in the entrykey and entrysubtype fields. I don't quite know what you are after in your real-world application, but certainly for the example that seems to be much, much cleaner than repeating the same file = subtype # "/" # entry # ".pdf", sequence in each entry and overwriting the relevant @strings each time.


\usepackage[style=authoryear, backend=biber]{biblatex}

      \step[fieldsource=entrysubtype, final]
      \step[fieldset=file, origfieldval]
      \step[fieldset=file, fieldvalue={/}, append]
      \step[fieldsource=entrykey, final]
      \step[fieldset=file, origfieldval, append]
      \step[fieldset=file, fieldvalue={.pdf}, append]

% just to print the 'file' field
\DeclareFieldFormat{file}{file: \path{#1}}

@string{subtype = "the-subtype" }

  entrysubtype  = subtype,
  title         = {Title},

  entrysubtype  = subtype,
  title         = {Title}



Title (n.d.). file: the-subtype/the-entry1.pdf.//Title (n.d.). file: the-subtype/the-entry2.pdf.

Alternatively, you can still build the contents of the field directly within biblatex without the sourcemap, though that becomes more fiddly when you want to combine several field values into one string.

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.