jgm/texmath — pull request #17 by rekka (2013-06-30 03:23:52+00:00)
Title: Implementation of \operatorname and \DeclareMathOperator

Hi John,

this patch implements the commands `\operatorname` and `\operatorname*`, as well as the commands `\DeclareMathOperator`, `\DeclareMathOperator*` for defining macros, from the package `amsmath`.

The functionality of `\operatorname*`, in particular, cannot be currently reproduced since this command allows one to define custom operators that handle limits like built-in operators `\lim`, `\max`, etc. That is, "convertible" limits whose position differ in inline math and display math.

`\DeclareMathOperator(*){\op}{opname}` is pretty much just a wrapper for

```
\newcomand{\op}{\operatorname(*){opname}}
```

But it's a rather standard way for defining operators when using `amsmath`, so I think it's a good idea for texmath to support it.

_Tests:_ I added some tests to `tests/operatorname.tex`. I also tested this new version of texmath with both pandoc and gitit and all seems to work fine.

_Limitations:_ I implemented the parser of `\operatorname{op}` to emit `EMathOperator opname`, so this restricts what can be in `op` to letters, numbers, and symbols that are parser as `ESymbol` like `-`, `+`, `\star`, etc. For instance, spaces, `\,`, etc., are not supported. But it should cover most use cases.

Best,
Norbert