On 06/17/2016 06:34 AM, Jean-Pierre Chrétien wrote:
> Le 14/06/2016 17:53, Richard Heck a écrit :
>>
>> Suppose you have a style like this:
>>
>> Style Test
>>    LaTeXType command
>>    LaTeXName whatever
>>    InPreamble 1
>>    Preamble
>>      \newcommand\whatever[1]{#1}
>>    EndPreamble
>> End
>>
>> Then LyX gives you:
>>
>> % LyX specific LaTeX commands.
>> \whatever{this is a test}
>>
>> % Textclass specific LaTeX commands.
>> \newcommand\whatever[1]{#1}
>>
>> Which will of course fail. Obviously, the problem is that we output the
>> "Preamble" code *after* we output the code from the paragraph itself.
>>
>> This seems to me to count as a bug. To fix it, though, we'd obviously
>> have to
>> output the code from the style AFTER the Preamble, which would change
>> the TeX
>> export of lots of files. An alternative would be to introduce a new
>> tag that
>> would basically mean: Output this before or after the Preamble code.
>> But I can't
>> imagine why you'd want to do it before the Preamble code.
>>
>> Thoughts?
>
> What about outputting
>
> \AtBeginDocument{\newcommand\whatever[1]{#1}}

This still comes too late: The command \whatever has already been issued.

One could try it the other way, but in the case at issue here the real
command \whatever has to be issued in the preamble.

Richard


Reply via email to