So instead of using the whole
\begin{equation}
{body}
\label{}
\end{equation}
I could simply type something like
\inserteq{{x+y=1}{eq1}}
That would be very helpful. Thanks on advance!
So instead of using the whole
\begin{equation}
{body}
\label{}
\end{equation}
I could simply type something like
\inserteq{{x+y=1}{eq1}}
That would be very helpful. Thanks on advance!
I've used these for years with no ill effects (other than tohecz [aka yo'] complaining about my typography :^)) This doesn't convert the environments into macros, but merely creates a shorthand syntax for getting into and out of the equation environments, with or without labels and/or punctuation.
% BEGIN EQUATION MODE
\newcommand{\beq}{\begin{equation}}
% BEGIN EQUATION MODE WITH LABEL
\newcommand{\beql}[1]{\begin{equation}\label{#1}}
% END EQUATION MODE
\newcommand{\eeq}{\end{equation}}
% END EQUATION MODE WITH A PERIOD
\newcommand{\eeqp}{\;\;\;.\end{equation}}
% END EQUATION MODE WITH A COMMA
\newcommand{\eeqc}{\;\;\;,\end{equation}}
Typical usage might be
\documentclass{article}
% BEGIN EQUATION MODE
\newcommand{\beq}{\begin{equation}}
% BEGIN EQUATION MODE WITH LABEL
\newcommand{\beql}[1]{\begin{equation}\label{#1}}
% END EQUATION MODE
\newcommand{\eeq}{\end{equation}}
% END EQUATION MODE WITH A PERIOD
\newcommand{\eeqp}{\;\;\;.\end{equation}}
% END EQUATION MODE WITH A COMMA
\newcommand{\eeqc}{\;\;\;,\end{equation}}
\begin{document}
Here is one equation,
\beql{eq:lbl}
y = mx+b
\eeqc
while here is another,
\beq
y = mx+b
\eeqp
\end{document}

Actually, what worked for me is an answer suggested by @eudoxos (he wrote it in the comments on my question) :
\def\inserteq#1#2{\begin{equation}{#1}\label{#2}\end{equation}}
I think this way is the simplest.
Than you use it as:
\inserteq{x+y=1}{eq1}
I usually use a eq macro:
\makeatletter
\def\eq{\@ifstar\@eq\@@eq}
\def\@eq#1{\begin{equation*}#1 \end{equation*}}
\def\@@eq#1#2{\begin{equation}\label{#1}#2 \end{equation}}
\makeatother
The eq macro takes the label as first argument and the equation as a second one. The starred version only takes the equation. However, no syntactic coloration, and some editors notice labels and serve them up when writing\ref, that won't work here. Use example:
\eq{b-a:ba}{1+1=2}
\eq*{2+2+=4}
Similarly, I find the parenthesis/bracket shortcuts useful:
\def\({\left(}
\def\){\right)}
\def\[{\left[}
\def\]{\right]}
Example:
\eq{eq:ex-parenthesis}{\(t+3\)\times9-2=0}
\(\)\[\] useful. I can't recommend it and you're bound to get surprising results if you load packages that assume those commands have their default meaning.
– egreg
Jan 26 '15 at 08:32
amsmathdocumentation, but is generally not advisible. It is better to use an editor than inserts such constructs for you. – Andrew Swann Jan 25 '15 at 13:02\def\inserteq#1#2{\begin{equation}#2\label{#1}\end{equation}}(or use\newcommandif you are a purist) and then\inserteq{eq1}{x+y=1}? – eudoxos Jan 25 '15 at 13:12\labelif there is some problem with them. It's also inconvenient if you need to transform the single equation into a multiline display (say because the document turns out to need two column typesetting). – egreg Jan 25 '15 at 13:33