Question says it all. What is the best way to redefine the \emph command to be bold font and upright?
Asked
Active
Viewed 8,391 times
48
2 Answers
45
Since \emph uses \em, I would redefine \em.
Here's such a redefinition which preserves the ability to toggle between bold and normal, if nested:
\makeatletter
\DeclareRobustCommand{\em}{%
\@nomath\em \if b\expandafter\@car\f@series\@nil
\normalfont \else \bfseries \fi}
\makeatother
Test of nesting behavior of \emph:
Question: \emph{What is the way to redefine the \emph{\textbackslash emph} command?}

Stefan Kottwitz
- 231,401
19
According to p. 194 of the LaTeX2e sources, \emph is defined as
\DeclareTextFontCommand{\emph}{\em}
So I suggest to redefine it as follows:
\DeclareTextFontCommand{\emph}{\bfseries}
lockstep
- 250,273
-
1This won't toggle like
\emphdoes, though, correct? I don't know if that's part of the OP's idea of "canonical." – Matthew Leingang Dec 08 '10 at 20:43 -
-
@Matthew I normally use the word
canonicalto mean ...how do you think Lamport would have written it? Not exactly from the Oxford Dictionary :) – yannisl Dec 08 '10 at 21:01
\em's toggling ability. – lockstep Dec 08 '10 at 19:41\normalfontmay be replaced by\itshapeor the like if accumulation of font attributes would be preferred. Toggling allows unworried nesting, accumulation does not. – Stefan Kottwitz Dec 08 '10 at 19:56\em?\let\oldem\emdoes not seem to have an effect. – yannisl Dec 08 '10 at 20:27\xdef. Perhaps copy& paste ... or define\emto be variable: using\noemphasizingand\emphasizingand a test macro instead of\upshapeand\itshape. This way one just has to change the simple macros instead of redefining\emagain. – Stefan Kottwitz Dec 08 '10 at 20:51\show\em, you will get\protect \em .in the log file and notice the two spaces after\em(they do not show here for some reason): this is because it is a protected macro and so the original definition is saved in the\csname em \endcsnamemacro. So you should do\expandafter\let\expandafter\oldem\csname em \endcsname. Just beware that\oldemis not a protected macro anymore. – Philippe Goutet Dec 09 '10 at 00:21fixltx2eso that in an italic context,\emproduces\eminnershape(by default this is\upshapeto give the original behaviour, but it can be redefined to, eg,\scshapeto give small caps). – Lev Bishop Dec 09 '10 at 05:51\begingroup\def\protect{\global\let\oldem}\em\endgroup. – Bruno Le Floch Jul 29 '11 at 01:04\slshapeinstead of\bfseries(in this example). I want to emphasize in slanted. How would the redefinition be? – Manuel Nov 30 '12 at 23:27\makeatletter\DeclareRobustCommand\em{\@nomath\em \ifdim \fontdimen\@ne\font >\z@\upshape \else \slshape \fi}\makeatother– Stefan Kottwitz Nov 30 '12 at 23:37