# \textit and \emph doubles text

I am experiencing an odd issue with \textit and \emph. I have a list from plaintext and want to format it. Here is a minimum example demonstrating my issue:

\documentclass{article}

\begin{document}

\textit{
(a)

(b)
}

\end{document}


Results in:

Why? What is going on here?

• remove the space between (a) and (b) in your code and it compiles normaly. Mar 16, 2021 at 7:27
• Cool effect. But note the error message(s) you get: The argument of \textit must not contain an empty line or paragraph break. If you want to format more text, use {\itshape (a) \par (b)}. But LaTeX has better ways to produce lists (enumerate). Mar 16, 2021 at 7:30
• @Roland - Your advice may make the immediate source of the error go away, but it does so at the cost of destroying the OP's intended formatting of the lines.
– Mico
Mar 16, 2021 at 7:34
• @Mico where does he say what it should look like in the end? He asked: What is going on here? So for me the answer was the extra blank space is what is going on. Mar 16, 2021 at 7:41
• It should be noted though that \\ and \newline are not the same as an empty line or \par. It is a good rule of thumb that one should not use \\ or \newline in the normal text body of a document: Paragraphs should be ended with an empty line (or \par if that is more convenient or appropriate) and within paragraphs there should be no forced line breaks with \\. (Of course \\ has its use in align or table environments and might be useful occasionally to avoid a bad line break. @Roland) Mar 16, 2021 at 16:47

The command \textit does not permit paragraph breaks in its argument, while all-blank lines cause paragraph breaks. You must be getting the following error message:

Runaway argument?
{ (a)
! Paragraph ended before \text@command was complete.
\par
l.9 }


Any lessons to be learnt? I'd say there are 2. First, don't ignore error messages. Second, to get your code to compile and perform the expected formatting, change the code chunk to

{\itshape
(a)

(b)
}

• Thank you. This solves my problem. Do you know why it is like this though? It is unintuitive behaviour. For example in markup or html when you tag something as italic, it does not matter what kind of whitespace is included. Why does \textit treat whitespace differently than other characters?
– Tom
Mar 16, 2021 at 20:25
• @Tom that is how the macro is defined. There are two ways to specify, say italics, for short texts \textit, for longer we have the switch \itshape. Same thing in html, its kinda ad practice to mark huge amounts of text inside a <em></em>, what is where we have css. Mar 16, 2021 at 21:47
• @Tom: Think of how in html, you have inline elements versus block elements, which are meant to be used differently. Similarly, in LaTeX, some commands (like \emph) are designed to be used just within paragraphs, while others (usually environments) are meant to be used for longer sections of text. Mar 16, 2021 at 22:24
• @Tom (La)TeX macros can be defined as taking 'long' or 'short' arguments. A long argument may contain paragraph end (\par or an empty line, which is converted to \par by TeX), but short arguments may not contain paragraph ends. Most explanations for that behaviour I have seen are about error detection: Many macros should only apply to a short stretch of text and not to whole paragraphs, so when the macro encounters a paragraph end, the user probably forgot a } to close the argument. ... Mar 17, 2021 at 7:44
• ... Especially in the old days, when documents took long to compile, it was a good idea to have a rogue macro argument stop absorbing text at that point and throw an error, so that a user can stop the process or at least syntax checking has a chance of resuming afterwards. See for example the explanations in tex.stackexchange.com/q/1050/35864 and tex.stackexchange.com/q/39450/35864. ... Mar 17, 2021 at 7:48