I never use \( \). How do I redefine them to mean \begin{equation} \end{equation}?
(I know that many of you will think this is a bad idea.)
I never use \( \). How do I redefine them to mean \begin{equation} \end{equation}?
(I know that many of you will think this is a bad idea.)
If you do, don't blame me ;-)
TeX macros can (under normal circumstances, no \csname, not \catcode involved) be of two basic types: control sequences and control characters. A control sequence is formed by an escape character (normally \) followed by a sequence of "letter" tokens (normally a-z and A-Z), for example \begin. A control character is formed by an escape character and one single non-letter token (every other character that doesn't fit as "letter"). TeX allows you to define/access both control sequences and control characters in the same way, so \def\mymacro{something} is as valid as \def\({something}.
In latex.ltx, \( and \) are defined as:
\DeclareRobustCommand\({%
\relax\ifmmode\@badmath\else$\fi}%
\DeclareRobustCommand\){%
\relax\ifmmode\ifinner$\else\@badmath\fi\else \@badmath\fi}%
The extra code checks for nested usage of \(...\), which is invalid. You can replace $ by the proper environment delimiters (and move the \end{equation} to the \else branch of \ifinner):
\makeatletter
\DeclareRobustCommand\({%
\relax\ifmmode\@badmath\else\begin{equation}\fi}%
\DeclareRobustCommand\){%
\relax\ifmmode\ifinner\@badmath\else\end{equation}\fi\else\@badmath\fi}%
\makeatother
As egreg said in the comment below, if you load amsmath (which you usually should), then you can leave the nesting check to equation:
\DeclareRobustCommand\({\begin{equation}}
\DeclareRobustCommand\){\end{equation}}
amsmath.sty (that should be used for any document containing an equation environment) we read \DeclareRobustCommand{\[}{\begin{equation*}} and \DeclareRobustCommand{\]}{\end{equation*}}. No need to add the checks, because \begin{equation} already takes care of them. But of course I agree with *DON'T*. :-)
– egreg
Jun 07 '19 at 21:56
\DeclareRobustCommand\({\begin{equation}}and the equivalent for the\endpart should do... (you could also do with\def\({\begin{equation}}; I used\DeclareRobustCommandto keep the definition robust, as the original.) – Phelype Oleinik Jun 07 '19 at 19:25begin{equation} \end{equation}and the cursor in-between. – Bernard Jun 07 '19 at 19:49