TransWikia.com

About defb*{begin{align*}}

TeX - LaTeX Asked by mookid on July 25, 2021

I want to make the code shorter. I defined the following pair of macros:

defb*{begin{align*}}
defe*{end{align*}}

My point is that I saw this in a document, with

defb*{begin{eqnarray*}}
defe*{end{eqnarray*}}

instead. The first pair of macros do not compile (on sharelatex.com),
and the second one does. Why?

2 Answers

The technote document explains why this kind of shorthand definitions will fail:

6   Why can’t I use abbreviations for begin{align} ... end{align}?

Authors often like to use abbreviations such as beq eeq for begin{equation} end{equation}. For some environments defined by the amsmath package, such as align, gather, multline, and others of the same general type, this does not work: An attempt to define bal eal as shorthand for begin{align} end{align} will fail with a puzzling error message. This has to do with unfortunately nontrivial technical complications: the given environments must read their contents as a delimited macro argument because they do multipass processing of the contents using algorithms inherited from Spivak’s amstex.tex. The obvious solution-substitution of different algorithms that do box shuffling instead of token shuffling for the multipass calculations-would require rewriting these display environments from the ground up; while that is a worthy goal, it was beyond the original scope of the AMS-LaTeX project. Work is under way on an auxiliary package called breqn that addresses not only this problem but a number of others; at the time of this writing, however [September 1999] it has only progressed as far as a beta release.

Some workarounds:

  • defbal#1eal{begin{align}#1end{align}}
  • Define newcommand{env}[2]{begin{#1}#2end{#1}} and then use env{align}{...}

Correct answer by Gonzalo Medina on July 25, 2021

The restriction of the AMS alignments that they may not be hidden behind command forms is documented on page 28 of the amsmath guide (texdoc amsmath ) Actually the restriction is better described in the technical notes (texdoc technote) as shown in the other answer.

The names chosen here are particularly dangerous as using def you lose the warning that you would have had from the correct LaTeX syntax newcommand that you were over-writing the standard accent command b.

Answered by David Carlisle on July 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP