3

I have one text that need to be italicized.

   \textit{some text2 ~\\ some text2}

But i found ~\\ converted to \newline\. Is there any alternative to \textit? Is there any alternative to \it?

Ruben
  • 13,448
manish
  • 9,111
  • 1
    Not sure I understand your motivations, but anyway you entered \, which is the same as \newline in this context. – Franck Pastor Apr 10 '14 at 09:21
  • 1
    Your issue does not seem to be related to the italics command. It is more about how you are using '~' and \\. – Ruben Apr 10 '14 at 09:24
  • 5
    I just graded 20 LaTeX assignments and usually students use \textit when they really need \emph. Why do you want to typeset text in italics? –  Apr 10 '14 at 09:31
  • 2
    I do not understand the problem. The result of your snippet looks like what I would expect. What do you expect (or desire) the output of this code snippet to look like? – Steven B. Segletes Apr 10 '14 at 11:10
  • I just need to italicize the character. – manish Apr 11 '14 at 01:39
  • @manish They mean “what do you want with ~\\”, obviously, all the text inside \textit{…} will be italicized. By the way, I would normally use \emph instead of \textit as Marc van Dongen said. – Manuel Apr 11 '14 at 10:38
  • Do you perhaps assume that \\ should provide you with the character that \textbackslash would offer? – wasteofspace Jun 16 '14 at 12:41

1 Answers1

6

I assume your intent was to get a backslash, instead of a \newline which is what \\ is. In that case you can use \textbackslash with either the macro \textit{...}, or the font switch {\itshape ...} as in the first two lines below:

enter image description here

The third line above was produced with \emph{...} and yields identical results (in this case).

However, you should carefully consider why you are doing this. Do you want an italic font, or are you trying to emphasize some words? In most cases one is trying to emphasize some words in which case \emph{...} should be used. Note the differences in the following where we have nested uses of \textit{...}, {\itshape ...}, and \emph{...}:

enter image description here

Notes:

  • The { and } when using the switch \itshape is so that the italics font switch is only on during within a scope.

Code:

\documentclass{article}

\begin{document}

\textit{some text2 ~\textbackslash~ some text2}

{\itshape some text2 ~\textbackslash~ some text2} 

\emph{some text2 ~\textbackslash~ some text2} 


\medskip

\textit{textit text  containing \textit{textit text}}

{\itshape itshape text  containing {\itshape itshape text}}

\emph{emphasized text containing \emph{emphasized text}} 

\end{document}

Peter Grill
  • 223,288