# Is there any means by which to severely discourage breaking a line in a would-be box?

I have a small section of text—no more than 15 or 30 characters—that is split up into a few words. I'd like to add a penalty to breaking in this section, but I don't want to completely bar it and risk a truly awful paragraph. How can I effect this?

I have some text and \DiscourageBreak{some text that \emph{shouldn't} be broken.}


I looked at a list of penalties available on this site, but I didn't see one that seemed appropriate.

Not robust, in the sense that it can't go in the argument to another command; the space is made active and defined to issue a high penalty and a space. A space following a penalty can't be taken as a line break point, only the penalty can, so this discourages breaks. Probably you want to disallow hyphenation, which can be easily done by adding \language=\l@nohyphenation in the definition of \DiscourageBreak.

\documentclass{article}

\makeatletter
\newcommand{\DiscourageBreak}{%
\begingroup\obeyspaces\sean@penalizespace
\sean@discouragebreak
}
\newcommand{\sean@discouragebreak}[1]{#1\endgroup}
\newcommand{\sean@penalizespace}{%
\begingroup\lccode\~=\ %
\lowercase{\endgroup\def~}{\penalty9000 \space}%
}
\makeatother

\begin{document}

I have some text and some other text and again.
I have some text and \DiscourageBreak{some text that \emph{shouldn't} be broken.}