1

Since I am lazy, and I don't want to write

\begin{equation}
\end{equation}

all the time, I thought I could have renewed the command into

\renewcommand\beq{\begin{equation}}
\renewcommand\enq{\end{equation}}

but I failed.

Why? Does someone know how to do it properly?

Henry
  • 378
  • 11
    with the standard definition that should work, but is usually considered to be a bad idea as it greatly obscures the document structure. If you have loaded amsmath then it is explicitly documented that you can not replace the environments by command forms. (although you presumably would use \newcommand not \renewcommand unless those names have been defined previously) – David Carlisle Dec 19 '16 at 16:21
  • 3
    Can't you make (or don't you have) shortcuts in your editor? – Bernard Dec 19 '16 at 16:24
  • @Bernard mm you mean something like when you start writing a command and it does auto complete it? – Henry Dec 19 '16 at 16:25
  • 5
    Since \beq is not defined, you should use \newcommand. But *don't*, you'll soon regret having done it and having littered your document with obscure markup. – egreg Dec 19 '16 at 16:26
  • @egreg I guess you are right.. The fact is that the (wrong) code $$ was so cute! Then I found out that is an aberration, and the correct command is [ and ]. I just wondered if there is something similar to enumerate equations... But still, I guess I won't create new commands :D – Henry Dec 19 '16 at 16:27
  • @Alan Turing: Yes, or a shortcut that displays the whole environment, and the cursor in between. Most of them are able to do such thinds. – Bernard Dec 19 '16 at 16:28
  • 1
    for the ams versions see http://tex.stackexchange.com/questions/100138/what-is-wrong-with-defining-bal-as-beginalign – David Carlisle Dec 19 '16 at 16:31
  • @Bernard Oh yes I have them! xD Indeed it's enough to write \begin{e and it does complete. Then by pushing enter I gain the \end{equation} for free. Not the bad indeed. – Henry Dec 19 '16 at 16:33
  • 1
    Its better to configure your editor to insert the \begin{equation}...\end{equation} for you (I just type eq<tab> using snippets in vim). Using macro short-hands when you collaborate isn't really possible and journals don't like them either. If you intend to never show you documents to anyone else, and always work alone, this is of course fine. –  Dec 20 '16 at 03:22

2 Answers2

5

While the code you showed works without problems, provided you use \newcommand rather than \renewcommand, I can't recommend doing so.

\documentclass{article}
\usepackage{amsmath}

\newcommand\beq{\begin{equation}}
\newcommand\enq{\end{equation}}

\begin{document}

\beq
a=b
\enq

\end{document}

enter image description here

Why do I recommend the fully spelled out version? There are several reasons, but here are the main ones.

  1. \begin{equation}...\end{equation} can easily become \begin{equation*}...\end{equation*} for the unnumbered version (and conversely

  2. You can look for environment nesting without distinguishing special cases

  3. The code with explicit \begin and \end tag is more prominent when skimming through the typescript

  4. Such shorthands cannot be used for align and the other amsmath display environments.

Littering a typescript with obscure markup is a bad thing. Really. Laziness can be implemented through the shortcuts provided by your text editor: every text editor provides them or, at least, a way to define new ones.

Personally, I don't even use shortcuts: typing \begin{equation} is as easy as remembering a shortcut.

egreg
  • 1,121,712
1

This is what I have personnaly used for years:

\newcommand{\beq}{\begin{equation}}
\newcommand{\eneq}{\end{equation}}