I want to allow my inline math to break lines after \sim, which I'm using a lot. To this end, I've tried:
\usepackage{regexpatch}
...
\xapptocmd{\sim}{\allowbreak}{SUCCESS}{FAIL}
...
$X \sim N(0, 1)$
Unfortunately this just prints out FAIL at the top of the document, but I'm not sure how to diagnose why \xapptocmd is actually failing. Is it possible to patch math commands in this way?
I'm happy to swap regexpatch out with any other package if it helps.
\let\oldsim\sim \def\sim{\oldsim \allowbreak}– user202729 Jun 13 '22 at 17:04\simis not defined with\defor similar instruction, so it cannot be patched this way. By the way, line breaks are allowed after relation symbols, which\simis. – egreg Jun 13 '22 at 17:04\siminside\left-\rightpairs, for instance. But generally a break after\simis allowed. – egreg Jun 13 '22 at 17:20