18

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
4
  • 2
    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. Aug 26, 2016 at 13:16
  • 2
    @barbarabeeton An alternative is to place braces following the macro, e.g. title={Cool\R{} Book}.
    – JAB
    Aug 26, 2016 at 19:26
  • @JAB -- true, and probably better, but easier to forget. thanks for reminder. Aug 26, 2016 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. Aug 31, 2016 at 10:31

2 Answers 2

20

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.

4
  • 7
    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, 2016 at 0:29
  • @sergej: you're absolutely right... That's what I get for typing without actually running it.
    – ig0774
    Aug 29, 2016 at 19:32
  • 3
    \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. Aug 31, 2016 at 7:19
6

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

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

in your normal LaTeX preamble.

(Of course, then the BibTeX file requires that command to be defined in every document that uses it.)

2
  • 3
    This is actually one of the uses of the @preamble...
    – ig0774
    Aug 26, 2016 at 15:39
  • Oh, I did not know about that. Feel free to post an answer. :) Aug 26, 2016 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .