aparsloe
2014-05-18 21:14:11 UTC
Hullo Jürgen,
I have come across an inconsistency/oversight in the treatment of inset
arguments. I have a custom inset that inserts a LaTeX command (call it
\blah) which has two optional arguments preceding the main argument. It
makes sense for the *second* optional argument to have a default value,
but not for the first (the second one determines formatting of the first
-- if there is a first). Putting
Argument 1
...
EndArgument
Argument 2
...
Requires 1
EndArgument
in the definition of the inset means inserting the second argument
automatically generates an empty square bracket placeholder for the first:
\blah[][2nd arg]{main arg}
but if the definition of the second includes the default value (",\quad"
in fact)
Argument 1
...
EndArgument
Argument 2
...
DefaultArg ",\quad"
Requires 1
EndArgument
and the inset is inserted in a document, LyX inserts the default value
for the second option but no empty square bracket pair for the first.
The source pane shows
\blah[,\quad]{main arg}
That means that if no optional argument is used (they are *optional*
after all) LaTeX is presented with the default of the second optional
argument masquerading as the first argument, causing error. I think
DefaultArg and Requires together in a definition should trigger
insertion of an empty square bracket pair for the first argument.
Of course it doesn't follow that
\blah[][,\quad]{main arg}
will have the same effect as
\blah{main arg}
which is the form of the command when no option is used in LaTeX, but
that's a separate issue.
Andrew
I have come across an inconsistency/oversight in the treatment of inset
arguments. I have a custom inset that inserts a LaTeX command (call it
\blah) which has two optional arguments preceding the main argument. It
makes sense for the *second* optional argument to have a default value,
but not for the first (the second one determines formatting of the first
-- if there is a first). Putting
Argument 1
...
EndArgument
Argument 2
...
Requires 1
EndArgument
in the definition of the inset means inserting the second argument
automatically generates an empty square bracket placeholder for the first:
\blah[][2nd arg]{main arg}
but if the definition of the second includes the default value (",\quad"
in fact)
Argument 1
...
EndArgument
Argument 2
...
DefaultArg ",\quad"
Requires 1
EndArgument
and the inset is inserted in a document, LyX inserts the default value
for the second option but no empty square bracket pair for the first.
The source pane shows
\blah[,\quad]{main arg}
That means that if no optional argument is used (they are *optional*
after all) LaTeX is presented with the default of the second optional
argument masquerading as the first argument, causing error. I think
DefaultArg and Requires together in a definition should trigger
insertion of an empty square bracket pair for the first argument.
Of course it doesn't follow that
\blah[][,\quad]{main arg}
will have the same effect as
\blah{main arg}
which is the form of the command when no option is used in LaTeX, but
that's a separate issue.
Andrew