Go to page:

Search help:

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

MathMacros

Categories: Math
<< Nomenclature | Page list | ChildMathMacros >>

This page contains tips about Math Macros in LyX

Alternative math-macro definition mode

Math-macros can be defined in two ways. The usual way is to use the mini-buffer. Either use the mouse to put the cursor in the mini-buffer or type Meta-x. Then type: math-macro name args, where name is a string and args is an optional integer indicating the number of arguments. LyX will then open a math environment in which the macro definition can be entered. In current versions of LyX, you enter arguments by typing "\#n", where n is the number of the argument. In earlier versions, you could type just "#n", but the "#" now needs to be escaped.

The other way is simply to enter the LaTeX definition directly and then convert it. So you can type \def\exp#1#2{#1^#2} or \newcommand{\exp}[2]{#1^#2}, select the typed text, and type Ctr-M to convert it to a math-macro.

Renaming a macro

This allows a trick for renaming a macro (using the minibuffer you can only delete it and recreate):

  • mark the macro and copy/cut
  • use the mouse to paste (this inserts the latex-math equivalent of the macro in the mathbox)
  • edit
  • mark and reconvert to mathbox with C-m

Changing an existing command

Math-macros translate to \newcommand, i.e. they fail, if the macro name is already defined.

To change an existing command (and its rendering in Lyx) you can use the following trick: Assume you want to redefine \Re to print "Re" in roman font.

  • do the redefinition in ERT: \renewcommand{\Re}{\mathrm{Re}}

Now LaTeX will produce the desired output, but LyX can't see the ERT redefinition, so it will still display the the old Re symbol as you edit. To make LyX display it the way you want during editing:

  • define the macro: M-x math-macro Re
  • fill it with \Re in the latex-cmd box and with \mathrm{Re} in the lyx-render box
  • put it in a Comment, so latex will not see it.

Math

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2007-01-14 06:28 CET