My copy editor work is largely dedicate do spot typos. I have a kind of typos formed by strings like, e.g., ".
", ",
", ":
"... (a space before a punctuation sign) that we consider typos in text-mode (e.g. "as follow :") but aren't a problem inside in-line math or math environments (e.g. "$\mu .$").
Usually we use custom emacs' query-replace regexp to find and correct these typos but, as emacs doesn't distinguish math mode from text mode (I know, I can do some tricks to do that but it is not a robust solution), I typically have a lot of false positives (and this is very boring).
I was wondering if there is a native LaTeX solution to do that. I mean not the query-replace but to highlight some matched strings.
I found, e.g., the xesearch
package but it doesn't handle punctuation search.
Here is a MWE:
\documentclass[11pt]{article}
\pagestyle{empty}
\begin{document}
Punctuation , typos .
No problem with this string
\begin{equation}
(\mu + \nu) ,
\end{equation}
\end{document}
I also found l3regex
but I think it performs regexp works on the LaTeX code and not on the pre-formatted code as xesearch
does.
Any hints, suggestions or helpful ideas are welcome.
Edit. As I answered in comments: "I'm asking for a technique to distinguish strings that are in math mode from strings that are in text mode and highlight only the second ones".
Edit 2. I moved and posted a related question here: XeTeXinterchartoks: Why the “)” in the layout of “\eqref” and (\ref{…}) are interpreted differently?
$\mu ,$
is wrong anyway. In my experience, errors like these are so various that finding a catch-all regex is hopeless. Andl3regex
(now in the L3 kernel) is not related. – egreg Jul 27 '17 at 12:14syntax-table
orfontification
to do some tricks but I imagine that only LaTeX can exactly tell if a string is in tex or math mode. Also a viewer allowing regex search would be helpful (but I know this is very tricky) – Gabriele Nicolardi Jul 27 '17 at 13:35