I have only ever used \textit (and \emph for emphasized text), but have noticed that in some TeX examples, \itshape is used instead of \textit. Is there a difference between \textit and \itshape? If so, what is that difference?
3 Answers
\itshape is a switch:
Not italic {\itshape Italic} Not italic
\textit takes an argument:
Not italic \textit{Italic} Not italic
Many people seem to like \itshape{...}, which is wrong (but doesn't give an error since the braces are interpreted as grouping delimiters here).
\itshape doesn't automatically insert italic correction, whereas \textit does, so inside a paragraph, \textit is usually better. On the other hand, sometimes the switch commands are more handy if you already have grouping (e.g., with braces or environments):
\begin{table}
\itshape
Everything inside this table is italic
\end{table}
- 17,641
\itshapeis a declaration. It affects the following text. That's why it's often used for larger amounts of text or within a group. In contrast,\textitaffects only its argument.\textitprovides italic correction,\itshapedoes not. This means, that immediately after an italic text made by\textitthere's a little more space before the following text, compared with\itshape. A reason for the correction is, that because of the slanting the spacing could be too narrow, visually. It depends on the font.\textitworks in math mode,\itshapedoesn't work in math mode.
Here's code for \textit, from latex.ltx:
\DeclareTextFontCommand{\textit}{\itshape}
\def \DeclareTextFontCommand #1#2{%
\DeclareRobustCommand#1[1]{%
\ifmmode
\nfss@text{#2##1}%
\else
\hmode@bgroup
\text@command{##1}%
#2\check@icl ##1\check@icr
\expandafter
\egroup
\fi
}%
}
As you can see, \textit uses \itshape but does more regarding math mode and italic correction.
- 231,401
\itshape and others like it (bfseries) are modal commands which don't take arguments. They change all succeeding text to that font shape/weight etc. \textit (and textbf) is a macro that takes an argument.
- 218,180
\itshapebe best reserved for fully italicized paragraphs (where there is no need for additional spacing at the end of the paragraph)? – squidbear Dec 31 '10 at 20:49\textit(actually\emph), and only reserve\itshapefor defining new commands and environments. – Juan A. Navarro Jan 24 '11 at 11:07