# Found it tiring to type so many \begin and \end

Is there some way to get rid of the \begin and \end's? For example, I need to type a small matrix, but I should type \begin{matrix}...\end{matrix}. I tried to define a macro

\newcommand{\matx}[1]{\begin{matrix}{{#1}}\end{matrix}}


but it doesn't work. Do you know if there's a LaTeX way to do it? Thank you very much!

-
Welcome to TeX.SX! –  egreg Apr 10 at 12:32
Note the error is not because of the command definition \begin{matrix}{{1&2}}\end{matrix} would not work either. (But note you can not do this with AMS alignments such as \begin{align}) –  David Carlisle Apr 10 at 13:39
use a powerful editor, like vim, for example; it does a lot of the tedious work for you –  cmhughes Apr 10 at 16:32

Just delete the unnecessary braces in your definition.

\documentclass{article}
\usepackage{amsmath}
\newcommand{\matx}[1]{\begin{matrix}#1\end{matrix}}
\begin{document}
$\matx{ 1 & 2 \\ 3 & 4 }$
\end{document}

-

I use emacs with AUCTeX and Ctrl-c Ctrl-e will enter the matching pairs automatically. I'm sure vim will have a command that does likewise.

-
Any 1/2-decent+ editor should do this is you really want it, as do many of the TeX-specific IDEs - perhaps the OP should tell us which editor they're using. –  Chris H Apr 10 at 12:45

I would suggest the following:

\def \bm {\begin{matrix}}
\def \em {\end{matrix}}


So that you just need to type \bm instead of \begin{matrix}

minimal code

\documentclass{article}
\usepackage{amsmath}
\def \bm {\begin{matrix}}
\def \em {\end{matrix}}
\begin{document}
$\bm 1 & 2 \\ 3 & 4 \em$
\end{document}

-
Overwriting standard commands is not recommended. In any case, it will not work in this case. Did you consider testing this before posting? There is a good reason that answers, as well as questions, should generally include Minimal Working Examples! –  cfr Apr 10 at 22:56
This works for me. I just posted the minimal code –  impact27 Apr 12 at 7:43
\emph{Emphasise this}. –  cfr Apr 12 at 12:34