lambdoc icon indicating copy to clipboard operation
lambdoc copied to clipboard

Support for document-wide abbreviations of math formulas in Lambtex?

Open radekm opened this issue 9 years ago • 3 comments

Is it possible to create document-wide abbreviations for frequently used mathematical formulas? Eg. \mathbb{N} for natural numbers. I have tried macros but it seems that blahtex commands such as \mathbb cannot be used in macros - since following code

\newmacro{nat}{0}{\mathbb{N}}

results in error "Reference to undefined macro 'mathbb'.". I have also tried \newcommand from blahtex but scope of the definitions introduced by \newcommand is limited to a single mathematical environment.

radekm avatar Mar 16 '15 15:03 radekm

What you want is already supported. Note that the third parameter to \newmacro must be an inline sequence, and raw TeX mathematics are not an inline sequence, which is why you are getting errors. Fixing it is simple: just tell Lambtex to expect inline TeX maths by wrapping them between [$ and $]. (See Chapter 13 of the Lambtex manual.)

\newmacro{nat}{0}{[$\mathbb{N}$]}

darioteixeira avatar Mar 16 '15 17:03 darioteixeira

Ok. Can these macros be used inside math? When I define

\newmacro{nat}{0}{[$ \mathbb{N} $]}

then I can use the macro in a paragraph. But writing

\begin{mathtex}
n \in \nat
\end{mathtex}

leads to an error "Invalid MathTeX expression ' n \in \nat ' in command 'mathtex'.".

radekm avatar Mar 16 '15 17:03 radekm

No, you can't use them inside mathtex environments. The contents of the mathtex environment are not parsed by Lambdoc, being instead fed verbatim into a function from the Blahcaml library for validation and conversion into MathML.

darioteixeira avatar Mar 16 '15 17:03 darioteixeira