Math & Sciencenewcommand with \end{align*}

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Jonny Boy
Posts: 7
Joined: Mon Feb 05, 2007 4:54 pm

newcommand with \end{align*}

Post by Jonny Boy »

When writing model solutions to questions, I use the align* environment. However, typing

Code: Select all

\begin{align*}
[blah, blah]
\end{align*}
is a little time-consuming. I tried to define a command to start and end the environment, such as

Code: Select all

\newcommand{\ba}{\begin{align*}}
\newcommand{\ealign}{\end{align*}}
but when I then code something as

Code: Select all

\ba
[blah, blah]
\ealign
it will recognise the \ba command as the beginning of the environment, but not \ealign as the end. Any thoughts?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

newcommand with \end{align*}

Post by gmedina »

It's not advisable to use shortcut codes as the one that you are trying to define (for the reason that you've already experienced). You can, however, define a shorter synonym for the align* environment (and relatives) using something like the following:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newenvironment{ma}
  {\start@align\@ne\st@rredtrue\m@ne}
  {\endalign}
\makeatother

\begin{document}

\begin{ma}
  a &=b\\
  &=c
\end{ma}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

newcommand with \end{align*}

Post by phi »

See technote.pdf, section 6. However, I don't recommend such abbreviations, they make your code less readable. Consider switching to an editor which lets you insert environments more easily.
Post Reply