1

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}

MWE

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.

  • 1
    Possible duplicate: Macro to capture until end-of-line as argument – Werner Nov 4 '15 at 6:10
  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.