reftex-what-macro

reftex-what-macro is an autoloaded Lisp function in `reftex-parse.el'.

(reftex-what-macro WHICH &optional BOUND)

Find out if point is within the arguments of any TeX-macro.
The return value is either ("\macro" . (point)) or a list of them.

If WHICH is nil, immediately return nil.
If WHICH is 1, return innermost enclosing macro.
If WHICH is t, return list of all macros enclosing point.
If WHICH is a list of macros, look only for those macros and return the
name of the first macro in this list found to enclose point.
If the optional BOUND is an integer, bound backwards directed
searches to this point. If it is nil, limit to nearest \section -
like statement.

This function is pretty stable, but can be fooled if the text contains
things like \macro{aa}{bb} where \macro is defined to take only one
argument. As RefTeX cannot know this, the string "bb" would still be
considered an argument of macro \macro.