Re: Macros with optional arguments - LyX 1.6.1
Stefan Schimanski writes: >> I think that \global\newcommand works in any case. > > It does? I think I tried and it did not. I might be wrong. I cannot find reference to that right now. > A second requirement: the distinction between \newcommand and > \renewcommand is very fragile. It is far from trivial to say whether a > macro is redefined in some cases. E.g., in a lyx comment a definition > will be ignored. LyX should skip macro definitions in comments anyway. >> It would be nice to make the case "all optional arguments are before >> required ones" work with plain \newcommand. > > What do you mean? I had a self-made \newcommand implementation that > could do that. But it is quite large (obviously), and it also look > strange to put that into the preamble. For that reason we switched to > xargs instead. Sorry, I was mistaken about what newcommand can do. I meant: "commands with one optional argument before the required ones". JMarc
Re: Macros with optional arguments - LyX 1.6.1
Am 07.01.2009 um 22:45 schrieb Jean-Marc Lasgouttes: xargs is only needed if you have macros with optional arguments. Of course, \newcommand could handle the case with one optional. But, what we need in fact is something equivalent to \global\def for this case. Is there a way to do this with \newcommand? Why \global? Because without the logic is complicated: \newcommand{\foo}{a} \textbf{\renewcommand{\foo}{b} bla} $\foo$ What is printed in the output? What should be shown on screen? Stefan
Re: Macros with optional arguments - LyX 1.6.1
Am 07.01.2009 um 22:45 schrieb Jean-Marc Lasgouttes: xargs is only needed if you have macros with optional arguments. Of course, \newcommand could handle the case with one optional. But, what we need in fact is something equivalent to \global\def for this case. Is there a way to do this with \newcommand? Why \global? I think that \global\newcommand works in any case. It does? I think I tried and it did not. A second requirement: the distinction between \newcommand and \renewcommand is very fragile. It is far from trivial to say whether a macro is redefined in some cases. E.g., in a lyx comment a definition will be ignored. It would be nice to make the case "all optional arguments are before required ones" work with plain \newcommand. What do you mean? I had a self-made \newcommand implementation that could do that. But it is quite large (obviously), and it also look strange to put that into the preamble. For that reason we switched to xargs instead. Stefan
Re: Macros with optional arguments - LyX 1.6.1
On Jan 7, 2009, at 2:05 PM, Stefan Schimanski wrote: Updating your MacTex to the latest version will solve the problem. Updating MacTex did the job. Thank you! James
Re: Macros with optional arguments - LyX 1.6.1
xargs is only needed if you have macros with optional arguments. Of course, \newcommand could handle the case with one optional. But, what we need in fact is something equivalent to \global\def for this case. Is there a way to do this with \newcommand? Why \global? I think that \global\newcommand works in any case. It would be nice to make the case "all optional arguments are before required ones" work with plain \newcommand. JMarc
Re: Macros with optional arguments - LyX 1.6.1
Am 06.01.2009 um 16:58 schrieb James C. Sutherland: I have been using macros in 1.6.1, and recently tried to use a macro with an optional argument. I have attached a trivial LyX file that shows this macro and an example of its use. This compiles through LyX just fine. The problem is that if I export the file to LaTeX and then try to compile it, the macro definition seems to create problems. This does not occur with macros that only have required arguments. I don't know much about LaTeX macros, so I am not sure if what LyX is doing for the LaTeX export makes sense or not. However, macros with optional arguments have the "\newcommandx" tag while macros without optional arguments do not. The "\newcommandx" tag seems to give LaTeX some trouble. Specifically, when I compile the .tex file, I get the error "Undefined control sequence" when the "\newcommandx" line is parsed. I have also attached the exported .tex file. Can anyone duplicate this? Is this a known problem? I am on Mac OSX with LyX 1.6.1. Updating your MacTex to the latest version will solve the problem. Stefan
Re: Macros with optional arguments - LyX 1.6.1
Am 07.01.2009 um 10:59 schrieb Jean-Marc Lasgouttes: [cc:ing to lyx-devel] "James C. Sutherland" writes: Okay, I think that I found the problem: I am missing the "xargs" package. The exported LaTeX file actually had a line: \usepackage{xargs}[2008/03/08] which I discarded. This is presumably where the "\newcommandx" tag is defined. The problem is that when I run LaTeX on the file, I get an error: "File 'xargs.sty' not found" The LyX file compiles fine, so I must have this file installed, but I cannot seem to find where. I have attached the actual .tex file that LyX produces. Is anyone else able to compile this? I think it was an error to rely on such a new package to provide this functionality. The example document is clearly a case that can be handled by a plain \newcommand statement. Could LyX be smarter in the kind of code it exports and only use weird packages when really needed? In fact it is supposed to be smart enough. xargs is only needed if you have macros with optional arguments. Of course, \newcommand could handle the case with one optional. But, what we need in fact is something equivalent to \global\def for this case. Is there a way to do this with \newcommand? Stefan
Re: Macros with optional arguments - LyX 1.6.1
[cc:ing to lyx-devel] "James C. Sutherland" writes: > Okay, I think that I found the problem: I am missing the "xargs" > package. The exported LaTeX file actually had a line: > \usepackage{xargs}[2008/03/08] > which I discarded. This is presumably where the "\newcommandx" tag is > defined. The problem is that when I run LaTeX on the file, I get an > error: > "File 'xargs.sty' not found" > The LyX file compiles fine, so I must have this file installed, but I > cannot seem to find where. I have attached the actual .tex file that > LyX produces. Is anyone else able to compile this? I think it was an error to rely on such a new package to provide this functionality. The example document is clearly a case that can be handled by a plain \newcommand statement. Could LyX be smarter in the kind of code it exports and only use weird packages when really needed? Stefan, are you here? JMarc
Re: Macros with optional arguments - LyX 1.6.1
Okay, I think that I found the problem: I am missing the "xargs" package. The exported LaTeX file actually had a line: \usepackage{xargs}[2008/03/08] which I discarded. This is presumably where the "\newcommandx" tag is defined. The problem is that when I run LaTeX on the file, I get an error: "File 'xargs.sty' not found" The LyX file compiles fine, so I must have this file installed, but I cannot seem to find where. I have attached the actual .tex file that LyX produces. Is anyone else able to compile this? James macro_test.tex Description: Binary data On Jan 6, 2009, at 8:58 AM, James C. Sutherland wrote: I have been using macros in 1.6.1, and recently tried to use a macro with an optional argument. I have attached a trivial LyX file that shows this macro and an example of its use. This compiles through LyX just fine. The problem is that if I export the file to LaTeX and then try to compile it, the macro definition seems to create problems. This does not occur with macros that only have required arguments. I don't know much about LaTeX macros, so I am not sure if what LyX is doing for the LaTeX export makes sense or not. However, macros with optional arguments have the "\newcommandx" tag while macros without optional arguments do not. The "\newcommandx" tag seems to give LaTeX some trouble. Specifically, when I compile the .tex file, I get the error "Undefined control sequence" when the "\newcommandx" line is parsed. I have also attached the exported .tex file. Can anyone duplicate this? Is this a known problem? I am on Mac OSX with LyX 1.6.1. James
Macros with optional arguments - LyX 1.6.1
I have been using macros in 1.6.1, and recently tried to use a macro with an optional argument. I have attached a trivial LyX file that shows this macro and an example of its use. This compiles through LyX just fine. The problem is that if I export the file to LaTeX and then try to compile it, the macro definition seems to create problems. This does not occur with macros that only have required arguments. I don't know much about LaTeX macros, so I am not sure if what LyX is doing for the LaTeX export makes sense or not. However, macros with optional arguments have the "\newcommandx" tag while macros without optional arguments do not. The "\newcommandx" tag seems to give LaTeX some trouble. Specifically, when I compile the .tex file, I get the error "Undefined control sequence" when the "\newcommandx" line is parsed. I have also attached the exported .tex file. Can anyone duplicate this? Is this a known problem? I am on Mac OSX with LyX 1.6.1. James macro_test.tex Description: Binary data macro_test.lyx Description: Binary data