I find myself spending effort in placing the tilde character before every inlined math I type, e.g.,
On 1899, G. Pick proved that the area of a simple polygon~$P$ whose vertices are located on the integer grid is~$i + b/2 -1$, where~$i$ is the number of grid points in the interior of% ~$P$ and~$b$ is the number of grid points on the the boundary of~$P$.
Can anyone think of a way of redefining the opening $ character so that it would do that automatically. Many will find this useful, methinks. Ideally, I would write instead just
On 1899, G. Pick proved that the area of a simple polygon $P$ whose vertices are located on the integer grid is $i + b/2 -1$, where $i$ is the number of grid points in the interior of $P$ and $b$ is the number of grid points on the the boundary of $P$.
I think, but not sure, that this is doable with the following method:
- Use character other than $ for inline math (or refer internally to
- Define $ as an active character which
\unskips previous spaces, replacing them with non-breakable space.
- After un-skipping, let $ redefine itself to do the closing part.
- The closing $ will invoke
\)and then will redefine $ as in 2.
An obvious bug of this method would be that displayed math wrapped with $$ would misbehave. I have an unpleasant feeling that there might be more.