On Wed, 2 Feb 2005, Davide Cescato wrote:

> Hello,
> 
> I am writing a draft for an article and I am still unsure about the 
> names of some variables I am going to use in my final version. In order 
> to handle this situation, in LaTeX I would define
> 
> \newcommand{\ntx}{N_T}
> \newcommand{\nrx}{N_R}
> 
> and then use \ntx and \nrx in my formulas whenever needed. If I later 
> decide to use M_T instead of N_T, I can just redefine \ntx 
> correspondingly without replacing all occurrencies in the document.
> 
> I can do the same in LyX, by adding the commands above to the document 
> header or as LaTeX code within the document body.
> 
> The point is that if I enter math mode and type \ntx\sigma\nrx , LyX 
> will replace the LaTeX standard \sigma command with the Greek character, 
> but not my custom-defined symbols, which will only appear with their 
> command names in red. This makes my formulas almost as unreadable as if 
> they were written in plain LaTeX!
> 
> Is there a way to make LyX replace my commands as well, as it does with 
> the standard LaTeX ones?
I think that math-macro is what you really need. 
Math macro is like \newcommand and some more ...
In the beginning of the document type:
    M-x math-macro ntx 0        
Then you get a box at the cursor consisting of "Macro: ntx" and two boxes
In the first box you fill in what shuld be displayed when processed by
latex. The second box is what is shown in the lyx editor when you type \ntx.

You can also add arguments to the math-macro by replacing the 0 to the
number of arguments you want. The arguments are called by #no
I sometimes defines a nicefraction by      M-x math-macro nf 2
    \nicefrac{#1}{#2}   % first box
    #1/#2               % second box
(with \usepackage{nicefrac} in preamble)
Then i get nice looking fractions in the output when calling \nf

Another maybe simpler solution is to turn on the instant-preview
(in Preferences/Look and freel/graphics (qt-version))
and have your \newcommand's in the preamble. Then you will see the result
in the lyx windown when you leave the equation.

/johan

-- 
Johan Ingvast, PhD student http://www.md.kth.se/~ingvast
Department of Machine Design, Royal Institute of Technology, Sweden
http://www.md.kth.se, http://www.md.kth.se/~cas <--- Walking robot proj
tel +46 (0)8 790 95 36  mob. +46 (0)70 34 34 498


Reply via email to