# Is it possible to define macros in bib-files?

I need to have the 'registered trademark' sign all over my bib-file. Therefore I would like to define a macro for this. Is something like the following possible (I am using biber as backend)?

% begin bib-file
\def\R{\/\textsuperscript{\textregistered}}

@book{foo2016bar,
title={Cool\R Book},
}
% end bib-file

• off topic: with that definition, the use of the macro would gobble the following space, leaving the sign closer to "Book" than it is to the word it is supposed to be associated with. as much as i don't like \xspace, that would probably be a reasonable approach here. – barbara beeton Aug 26 '16 at 13:16
• @barbarabeeton An alternative is to place braces following the macro, e.g. title={Cool\R{} Book}. – JAB Aug 26 '16 at 19:26
• @JAB -- true, and probably better, but easier to forget. thanks for reminder. – barbara beeton Aug 26 '16 at 19:33
• also off-topic: Using such macros in the bibliography prevents biber from decoding these symbols and might have unwanted side effects while sorting. – Martin - マーチン Aug 31 '16 at 10:31

There's a sort of special entry @preamble which can contain LaTeX code. It's used to define commands or other formatting required for your bibliography.

Something like:

@preamble{"\def\R{\/\textsuperscript{\textregistered}}"}


This should work with BibLaTeX / Biber as well.

• When possible, please use \newcommand* rather than \def - especially with a single-letter macro - when dealing with LaTeX. It is dangerous to do this as it just creates bad habits which backfire in ugly ways at the worst possible times. – cfr Aug 27 '16 at 0:29
• @sergej: you're absolutely right... That's what I get for typing without actually running it. – ig0774 Aug 29 '16 at 19:32
• \providecommand may be better than \newcommand in some situations like this, for example if you are using multiple bibliography files or also use the command in your document; depending on whether you want an error or not if the command is already defined. You might also consider using a longer command name such as \mybibregistered, to avoid clashes with document definitions. – Andrew Swann Aug 31 '16 at 7:19

You can safely say title={Cool\R Book} in your entry and define

\newcommand{\R}{\textsuperscript{\textregistered}\xspace}


• This is actually one of the uses of the @preamble... – ig0774 Aug 26 '16 at 15:39