27

It seems I can use $some text in another lang$ instead of (the bigger) \textit{some text in another lang}, may I?

In my opinion, the effect is the same.

104
+150

No

Really, no!

$ ... $ is the TeX way of entering math mode - specifically, inline math mode. What this means is that it puts you in a mode configured perfectly for mathematics - not italic text.

Using $ ... $ to italicise text will produce some very bad results.

Unless you've got some strange set up, spaces will be ignored, so

$Here is some text$

Produces

enter image description here

The spacing between letters in a word will also be awful, because it's designed for the spacing between strings of mathematical variables, like ab + cd = efg or whatever, not for words. As a result, you'll get irregular gaps between letters:

Compare $Here$ with \textit{Here}

enter image description here

Look at the spacing between the r and the e.

Because you're in math mode, text mode commands will not work.

$p\`{e}re$

Produces the error

LaTeX Warning: Command \` invalid in math mode on input line 6.

! Please use \mathaccent for accents in math mode.
\add@accent ...@spacefactor \spacefactor }\accent 
                                                  #1 #2\egroup \spacefactor ...
l.6 $p\`{e}
           re$
?

Also, if you're using different fonts to the default, your italic font may be different to your maths font.

But leaving all this aside, it violates one of the principles of LaTeX, which is logical structure. One of the key ideas is that I have meaningful commands and environments for producing a given structure. So, instead of hand typing out an enumerated list, putting in all the indents and stuff manually each time, I use an enumerate environment. If I want some mathematics, I enter into math mode. I shouldn't really be using math mode as a hack for something which is not maths, because it messes up the structure of my .tex file.

On that theme, you might like consider using \emph{foo}. Now \emph{} is for emphasising things and by default its behaviour is to make things italic. It also handles nested emphasis, so that

\emph{Never \emph{ever} do that again!}

Produces

enter image description here

Note how the ever is upright.

Here, I am not using a low-level font change command, I've got a structure - emphasis. And when I want to emphasise something I use that. This means that, if I want to change how things are emphasised in my document without going through and changing all the \textits, I can do it by simply redefining \emph. I myself almost never use \textit in a document, but I do usually define a number of commands, such as \work for works (books, plays, movies and so on). Usually such titles are set in italic.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\work}[1]{\textit{#1}}

\begin{document}

I really like \work{Harry Potter and the Order of the Phoenix} and
\work{Harry Potter and the Half-Blood Prince}. \work{Harry Potter and
  the Deathly Hallows} is actually my \emph{least} favourite, though,
which surprised one of my ``friends'' so much, he punched me on the
nose.

\end{document}

enter image description here

But I can effortlessly change this so that all of my titles are put in quotation marks instead.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\work}[1]{``#1''}

\begin{document}

I really like \work{Harry Potter and the Order of the Phoenix} and
\work{Harry Potter and the Half-Blood Prince}. \work{Harry Potter and
  the Deathly Hallows} is actually my \emph{least} favourite, though,
which surprised one of my ``friends'' so much, he punched me on the
nose.

\end{document}

enter image description here

Another thing you might want to look into is using an editor that can speed up the process of inputting commands by defining keyboard shortcuts. Have a look here and see if any take your fancy.

  • 20
    wish i could upvote this more than once! – barbara beeton Dec 23 '16 at 13:57
  • For Harry Potter? :o) – Bernard Dec 23 '16 at 14:02
  • 1
    @barbara: you could award a bounty – cmhughes Dec 23 '16 at 16:41
  • 2
    @cmhughes -- i intend to do so, but that can't be done until two days have passed. and there are some real complications in my schedule -- in four days, i'm skipping town, and it's unclear whether i'll have connectivity while i'm gone. but i'll do my best. – barbara beeton Dec 23 '16 at 16:44
  • 5
    Upvoted for @Clément. Who will upvote for me? – cfr Dec 23 '16 at 17:47
17

Just one more example, to extend @Au101 answer. Numbers' behaviour is completely different.

\documentclass{article}

\begin{document}

 \textit{2} vs. $2$

 And even \verb+\textit{$2$}+: \textit{$2$} does not make 2 italic.

\end{document}

enter image description here

  • 1
    This is a great point, well remembered! :) – Au101 Dec 26 '16 at 17:41
11

Still another extension to @Au101's answer: The math italic font, which is the font that TeX uses to typeset letters in math mode, does not insert typographic ligatures. In contrast, in text italic mode (as well as in text upright or "roman" mode), TeX will automatically insert any available ligatures. E.g.,

$difficult\ office$ vs.\ \textit{difficult office}

enter image description here

Or:

$off\ fit\ fly\ baffle$ vs.\ \textit{off fit fly baffle}

enter image description here

  • 1
    I think a more accurate way of rephrasing this answer could be “the math italic font, which is the font that TeX would use to typeset the word ‘baffle’ given the input $baffle$, doesn’t include any ligature”. (You probably know very well that TeX does insert ligatures for “text symbols” encountered in math mode, as in $\mathit{baffle}$; see The TeXbook, Appendix G, Rule 14.) – GuM Dec 26 '16 at 19:17
  • @GustavoMezzetti - Thanks! I've rephrased my answer to incorporate your suggestion. – Mico Dec 26 '16 at 21:08
5

Also math mode doesn't apply text formatting. For example:

\textsf{$Math\ mode$ \textit{doesn't apply text formatting}.}

produces:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.