I am looking for a way to insert a counter in the math mode $ .* $. In particular, I am writing a document in LaTex and I want to check the grammar within the document with a language tool. First, I removed all the math by following the answer to the following question: remove everything in math mode. However, by removing all the math, the language tool reports errors because of the empty string between words. Therefore, I would like to insert a counter in order to have something between words. I tried the following
\newcounter{equat}
\setcounter{equat}{1}
\newcommand{\newEQ}{\refstepcounter{equat}\Alph{equat}}
\def$#1${\newEQ}
but apparently, I cannot use \stepcounter
, \refstepcounter
or \addtocounter
in \def$#1${.*}
.
Does anyone know how I can increase the above counter?
I thought about inserting the \refstepcounter
before (or after) the math mode, but I cannot find how to do it.
I thank everyone in advance!
Working example
I have this:
\documentclass{article}
\usepackage{comment}
\usepackage{verbatim}
\def\[#1\]{}
\def\(#1\){}
\catcode`\$=13
\def$$#1$${}
\def$#1${}
\makeatletter
\renewenvironment{subequations}{\comment}{\endcomment}
\renewenvironment{equation}{\comment}{\endcomment}
\renewenvironment{alignat}{\comment}{\endcomment}
\renewenvironment{align}{\comment}{\endcomment}
\renewenvironment{equation*}{\comment}{\endcomment}
\renewenvironment{alignat*}{\comment}{\endcomment}
\renewenvironment{align*}{\comment}{\endcomment}
\makeatother
\begin{document}
This is an example with $ E = m c^2 $ and
\begin{equation*}
\cos^2(\alpha) + \sin^2(\alpha) = 1.
\end{equation*}
\end{document}
If I compile the above code, I get:
This is an example with and
However, I want something like the following
This is an example A with B.
where A and B are the alphabetic conversion of a counter.
If I put the command \newEQ
inside the redefinition of the above environment, the I solve this problem only for the environments:
\makeatletter
\renewenvironment{subequations}{\newEQ\comment}{\endcomment\ }
\renewenvironment{equation}{\newEQ\comment}{\endcomment\ }
\renewenvironment{alignat}{\newEQ\comment}{\endcomment\ }
\renewenvironment{align}{\newEQ\comment}{\endcomment\ }
\renewenvironment{equation*}{\newEQ\comment}{\endcomment\ }
\renewenvironment{alignat*}{\newEQ\comment}{\endcomment\ }
\renewenvironment{align*}{\newEQ\comment}{\endcomment\ }
\makeatother
Indeed, I got the following result
This is an example with A
\def$#1$
in the first place, no matter what you're doing. If you want numbered equations use theequation
environment.catcode'$=\active
before\def$#1$
. I want to substitute the formulas into the math mode with a counter in order to have a clean PDF to analyze with a language tool