Srinivas Nedunuri wrote:
Hello, I tried defining a macro as described in the User Guide (the
macrowarg example). However, I get the following erroe message:
Extra }, or forgotten $.
\newcommand{\macrowarg}[1]{2+\sqrt{#1}}
What is wrong here? The code looks identical to what the User Guide says is
produced.
It is, and it's identical to what I get when I (successfully) define and
use the example macro.
(BTW, If I try surrounding the macro body with $ (by shifting into math mode
in Lyx) I get a complaint that you can't use #1 inside math mode
The macro definition does not go in math mode, so you were on the right
track the first time.
The only thing I can think of is that there's a problem earlier in your
document.
At any rate, here's one way to define the macro.
1. In the mini-buffer, type 'math-macro macrowarg 1' (without the
quotes) and hit enter. The macro definition box should materialize.
2. In the left entry of the macro definition box, type '2+\sqrt' and,
inside the argument box for the square root, type '#1' (both again
without the quotes).
3. Try typing \macrowarg inside math mode, and enter something in the
argument box.
If it doesn't work, try posting a minimal document that fails.
Paul