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?

7
  • 1
    Not sure I understand your motivations, but anyway you entered \\, which is the same as \newline in this context. Commented Apr 10, 2014 at 9:21
  • 1
    Your issue does not seem to be related to the italics command. It is more about how you are using '~' and \\ .
    – Ruben
    Commented Apr 10, 2014 at 9: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?
    – user10274
    Commented Apr 10, 2014 at 9: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? Commented Apr 10, 2014 at 11:10
  • I just need to italicize the character.
    – manish
    Commented Apr 11, 2014 at 1:39

1 Answer 1

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .