I'm writing a text in which order relations (e.g.
\ll) often appear as arguments of functions rather than binary operators (e.g.
$O(P,<)$). Every so often this leads to an inline formula's line breaking after the order relation and leaving a closing bracket or a comma (when there's another argument after the order relation) at the beginning of the next line. This, of course, I'd like to avoid.
I'm hoping for a more flexible solution than
\relpenalty=10000 because I don't like it doing way more than is necessary and possibly messing with the way other formulas are typeset. I only really want to forbid line breaks after the symbols
\ll as well as these symbols with a subscript or superscript added. However, I can't find a way to adjust the penalty for breaking after a specific symbol. Perhaps, there's a way of doing this by changing the
\mathcode of said symbols but I can't put my finger on how exactly that could work.
Update. To be absolutely clear, I do not want to forbid the line break ad hoc at every instance but I want to do it a the preamble level. Also, if there is a way of forbidding line breaks before closing brackets and commas that would also work (perhaps that would even be better, although it wouldn't match the question's title, lol).