I use some commands, such as \begin{gathered} a lot. I would like to replace them with shorter commands. I tried using \newcommand{\bg}{\begin{gathered}}, but it gave me an error.
Is there any way of doing this short of creating a package?
Thanks!
JT
General ⇒ Shortning commands such as \begin{gathered}
-
- Posts: 3
- Joined: Mon Apr 07, 2008 1:02 am
NEW: TikZ book now 40% off at Amazon.com for a short time.

Shortning commands such as \begin{gathered}
Many of the commands and environments provided by the amsmath package are fragile so shortcuts as the one you defined are a recipe for disaster, as you have already experienced.
You can define a synonym for those environments using something like
You can define a synonym for those environments using something like
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\newenvironment{gatd}{\gathered}{\endgathered}
\begin{document}
\begin{equation}
\begin{gatd}
(a+b)(a-b)=a^2-b^2\\
(a+b)(a+b)=a^2+2ab+b^2
\end{gatd}
\begin{gatd}
(a-b)(a-b)=a^2-2ab+b^2\\
(a-b)(a+b)=(a+b)(a-b)
\end{gatd}
\end{equation}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Shortning commands such as \begin{gathered}
Try
So you can write something like
Anyway, I think doing that is a bad practice, since the internal checks for environments that remain open are then disabled. Suppose you forget \eg. Compile and look at the error. Now, replace \bg by \begin{gathered} and compile. Which error is easier to debug?
Code: Select all
\let\bg\gathered
\let\eg\endgathered
Code: Select all
\[
\bg
a+b+c=d+e \\
f+g+h=i
\eg
\]
Re: Shortning commands such as \begin{gathered}
The best solution, I think, is a good editor that lets you have shorthands to typeset in a stroke the whole environment, then have the cursor at the right place. It is important that the source code remains readable .
B.A.
B.A.
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Shortning commands such as \begin{gathered}
Hi JT,
short workaround:
Or:
You can read something about the problem with abbreviating amsmath environments in the amsmath technical notes.
Stefan
short workaround:
Code: Select all
\def\bg#1\eg{\gathered#1\endgathered}
Code: Select all
\newcommand\gath[1]{\gathered#1\endgathered}
Stefan