I am using the Beamer class and would like to redefine \emph
to use \bfseries
instead of \itshape
. I have tried the following command:
\renewcommand<>{\emph}[1]{{\only#2{\bfseries}#1}}
but I get the following error
! LaTeX Error: Command \beamerx@\emph already defined.
Or name \end... illegal, see p.192 of the manual.
I cannot understand: Why is it a problem that \emph
already is defined when I am using \renewcommand
?
Best Answer
Looking at the code, I'd say that this was a bug. Beamer defines a wrapper around the
\newcommand
and\renewcommand
environments which step in when they are called with a following<>
. But the new\renewcommand
seems to do the following:\newcommand
Now the modified
\newcommand
calls internally calls the original\newcommand
but what it ought to do here is now call the original\renewcommand
. (The error message, by the way, is because the original\newcommand
is not called on the command specified, in this case\emph
, but again there's a level of wrapping on top to deal with the overlay stuff.)So, to fix this:
\newcommand
and replace "new" by "renew" at all instances, however\begin{document}
time) using\renewcommand
. With the old version, if the command-to-be-redefined is not currently defined then this goes through just fine. However, with the new version then if the command-to-be-redefined is not currently defined then this produces errors! (The guilty commands are\includegraphics
and\pgfuseimage
.)Anyway, here's the fix. Use at your own risk:
(Added in edit): I made a mistake in the above code: it doesn't save the original version of the command which the beamer version of
\renewcommand
does. Also, due to the conflicts, I thought that actually it would be better to define a command\myrenewcommand
which does the command. So the code below may be better. It's probably still nowhere near perfect - for example, I don't know if the\@star@or@long
is appropriate for\renewcommand
s.Anyway, here's version 2 wrapped up in a MWE: