# Place \mbox around elements in a list

I am trying to achieve essentially the same effect as asked for in this question, except that I want to redefine \item to achieve the result automatically. Specifically, I am trying to use an inline list with the enumitem package in which the items which would otherwise contain a line break are instead simply displayed on the next line. Below is a MWE.

\documentclass{article}

\usepackage[inline]{enumitem}

\begin{document}

\begin{minipage}{.3\textwidth}
\begin{enumerate*}
\item Hello world!
\item Hello again!
\end{enumerate*}
\end{minipage}

\vspace{\baselineskip}

\begin{minipage}{.3\textwidth}
\begin{enumerate*}
\item Hello world!
\item \mbox{Hello again!}
\end{enumerate*}
\end{minipage}

\vspace{\baselineskip}

\let\olditem\item
\renewcommand{\item}[1]{\olditem \mbox{#1}}
\begin{minipage}{.3\textwidth}
\begin{enumerate*}
\item Hello world!
\item Hello again!
\end{enumerate*}
\end{minipage}

\end{document}


The first result is what happens by default, the second result is a correct fix with the \mbox placed directly after \item, and the third result is my failed attempt to automate the \mbox by redefining \item.

How do I correctly automate the placement of the \mbox around every element in the list, or otherwise, how do I prevent this mid-item line breaking.

• Possible duplicate: Macro to capture until end-of-line as argument – Werner Nov 4 '15 at 6:10
• The 'correct fix' is typographically horrible, though. Unless you are going to apply \raggedright to the paragraph, this seems designed to produce ugliness. – cfr Nov 6 '15 at 1:47