# \em of ulem package surrounding by environment does not compile

The following code does not compile if any % is removed. It reports run away argument.

\documentclass{article}
\usepackage{ulem}
\begin{document}
\begin{center} %\em
This is center
\end{center}
\begin{quote} %\em
This is quote
\end{quote}
\begin{itemize} %\em
\item This is itemize
\end{itemize}
\begin{tabular}{c} %\em
This is tabular
\end{tabular}
\end{document}


My question is whether it is possible to fix it so that \em of ulem (as an underlining \em) works everywhere \em of LaTeX works.

-
\em with ulem wants to be terminated by }. –  egreg Aug 29 '14 at 9:24

The definition of \em with ulem becomes

\def\@tempa{\uline}%
\global\let\UL@ender\UL@swender
\expandafter\@tempa\expandafter{\ifnum\z@=\string}\fi


This is an interesting trick for essentially turning

{\em something}


into

\uline{something}


A consequence of this is that \em needs to see an explicit closing brace and cannot be “free”.

Underlining cannot be done like a font change that respects any grouping mechanism, so the answer to your question is: no, you can't.

-
Thanks. So the next problem: why not make underlining a font feature so that we will have \ulshape and \textul? It is cheaper to draw a line than to tune, for example, the italic version, right? –  Symbol 1 Aug 29 '14 at 9:41
@Symbol1 One would need a special underlined font for this. But underlining a whole paragraph is something a typographer would do only under physical threat. –  egreg Aug 29 '14 at 9:43
You owe me a coffee and a new keyboard. But I'm still chuckling. –  Steven B. Segletes Aug 29 '14 at 9:56
@StevenB.Segletes Sorry for your keyboard. ;-)` –  egreg Aug 29 '14 at 10:07