I typically use
\textit{Some italicized text}
while some of my colleagues use
{\it Some other text}
Should I bother changing one or the other, or does it matter?
Related:
I typically use
\textit{Some italicized text}
while some of my colleagues use
{\it Some other text}
Should I bother changing one or the other, or does it matter?
Related:
From l2tabu:
Why not use obsolete commands? Obsolete commands do not support LaTeX2e's new font selection scheme, or NFSS.
{\bf foo}
, for example, resets all font attributes which had been set earlier before it prints foo in bold face. This is why you cannot simply define a bold-italics style by{\it \bf Test}
only. (This definition will produce: Test.) On the other hand, the new commands\textbf{\textit{Test}}
will behave as expected producing: Test.Apart from that, with the former commands there is no ‘italic correction’, cf. for instance halfhearted (
{\it half}hearted
) to halfhearted (\textit{half}hearted
).
{\it half\/}hearted
. This is how it would be done in TeX, after all.
{\bfseries textOne {\itshape textTwo}}
? Are they outdated too? What are they for? {\itshape half}hearted
doesn't work nice.
\itshape\bfseries
produces the correct output). Useful for some layout definitions (e.g. in KOMA or titlesec).
Hmm, I just posted this as an answer to another question, but just as I was posting, that question was closed—with a referral here. So I'll throw in my 2¢ here...
The reason I don't like \it
and \bf
is that they do not play well together. That is, they do not nest as one would intuitively expect:
Whereas \textit
and \textbf
do play well together:
This is nice. However, you may notice that it still fails to handle nested style adjustments to small caps, since the Computer Modern fonts do not contain slanted or bold small caps:
If this is a problem for you, then what I recommend—and I just happened to learn about this yesterday myself—is the wonderful slantsc
package in combination with the lmodern
package. slantsc
provides, among other things, \rmfamily
(roman), \ttfamily
(typewriter/teletype), \sffamily
(sans-serif), \bfseries
(boldface), \itshape
(italics), \slshape
(slant/oblique), and \scshape
(small caps). With these, small caps can obtained in slanted form:
As a bonus, slantsc
fixes \textsl
to behave properly with \textsc
, so you can continue using those if you like.
Alas, I haven't yet found a package which fixes the behavior of nested instances of \textit
. In typesetting, when you nest italics, you're supposed to come back out of italics to roman. For example, the word "Titanic" below is in nested italics:
Tanaka, Shelly. On Board the Titanic: What It Was Like When the Great Liner Sank. New York, NY: Hyperion/Madison Press, 1998.
As a workaround, you can usually write \textrm
to temporarily return to non-italics in those cases, but of course this is only valid if you know the exact number of nested italic levels, which may not always be the case, especially inside a macro.
Update:
As others have pointed out, \textit
and \textsl
do automatic italic correction, whereas \it
, \itshape
, \sl
, and \slshape
do not. Thus, you can write \textit{stuff}
, but you must write {\it stuff\/}
or {\itshape stuff\/}
to get the same effect.
\textit
(or any other command intended to do italics) to generate non-italic text. On the other hand I'd expect \emph
(which is used to emphasize) to switch to italics if not already in italic mode while to switch off italics when in italic mode (because emphasizing is usually done this way). And guess what, that's exactly what \emph
does. The correct way to type the title above therefore is: On Board the \emph{Titanic:} What It Was Like When the Great Liner Sank.
Note that Titanic is emphasized, not italicised.
\emph
would be inappropriate.
The \it
syntax is inherited from LaTeX 2.09, and is regarded as supported 'for historical reasons only' in LaTeX2e. For bold, you should go for \textbf
rather than \bf
. For italic, you'd usually use \emph
rather than \textit
as it's semantic mark up and as it handles the italic correction automatically.
\textit
is the way to go. But if you want to emphasize some text, then you should use \emph{}
.
\textit
and \it
Commented
Jul 28, 2010 at 20:45
\emph
is semantic: it says 'make things emphasised'. On the other hand, \textit
means make this italic
. By convention, \emph
makes things italic, but you can redefine it to do something else (for example, the beamer
class makes text red). On the other hand, \textit
is always italic. So it is usually advised to use \emph
in a document, using \textit
only when you need definitely italic text. This might make a good question, as I'd then have more space to give detail!
I don't completely agree with Caramdir's answer, since it is true that \it
should not be used because it is obsolete, however the corresponding non-depreciated command is \itshape
.
So, in your example \it
should be replaced with \itshape
. However, in some cases as for \textit{half}hearted
vs {\itshape half}hearted
, the former is preferable.
Regarding the deprecated "old font commands", I find them quite useful for equations.
Let's say e.g. that I want to write a symbol for an external potential as $V_{ext}$
. However, it is a common convention to use upright characters for subscripts and superscripts that are labels rather than variables, which can be written as either
V_{\mathrm{ext}} or
V_{\rm ext}
I strongly prefer the latter, as the lower character-count and nesting-level makes reading and editing easier. Though there are cases where the advantage is diminished, e.g. with vector component notations like
f_{\mathrm{ext},i} vs
f_{{\rm ext},i} or
f_{\rm ext\it,i} % <- not tested
Some modern document classes do not provide the old-style commands anymore. In this case, they can be reintroduced with \DeclareOldFontCommand
, see e.g. What exactly does \DeclareOldFontCommand and \DeclareRobustCommand do?.
\rm
and the like.