mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
1e341fda01
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1189 a592a061-630c-0410-9148-cb99ea01b6c8
270 lines
5.0 KiB
Plaintext
270 lines
5.0 KiB
Plaintext
#This file was created by <larsbj> Sun Dec 5 17:47:02 1999
|
|
#LyX 1.0 (C) 1995-1999 Matthias Ettrich and the LyX Team
|
|
\lyxformat 2.15
|
|
\textclass article
|
|
\language english
|
|
\inputencoding default
|
|
\fontscheme default
|
|
\graphics default
|
|
\paperfontsize 12
|
|
\spacing single
|
|
\papersize Default
|
|
\paperpackage a4
|
|
\use_geometry 0
|
|
\use_amsmath 0
|
|
\paperorientation portrait
|
|
\secnumdepth 3
|
|
\tocdepth 3
|
|
\paragraph_separation indent
|
|
\defskip medskip
|
|
\quotes_language english
|
|
\quotes_times 2
|
|
\papercolumns 1
|
|
\papersides 1
|
|
\paperpagestyle default
|
|
|
|
\layout Title
|
|
|
|
User defined macros in math mode
|
|
\layout Author
|
|
|
|
Alejandro Aguilar Sierra
|
|
\layout Date
|
|
|
|
25-October-1997
|
|
\layout Section
|
|
|
|
Introduction
|
|
\layout Standard
|
|
|
|
LyX version 0.12 allows the user to define macros.
|
|
An user defined macro in math mode is not a red colored name that LyX didn't
|
|
know how to draw (formerly known as macro mode, now simply TeX mode).
|
|
A macro definition box appears on screen as a grayed button with the name
|
|
of the macro in blue (math color).
|
|
But if you click on it, it will appear as a normal math box to allow you
|
|
edit it.
|
|
Just try it:
|
|
\begin_inset FormulaMacro
|
|
\newcommand{\macro}{a+b}
|
|
|
|
\end_inset
|
|
|
|
|
|
\layout Standard
|
|
|
|
Now, to use this macro in other math boxes just type the name in TeX mode,
|
|
in this case
|
|
\family typewriter
|
|
|
|
\backslash
|
|
macro
|
|
\family default
|
|
, and it will be automatically expanded:
|
|
\begin_inset Formula \( c=\macro \)
|
|
\end_inset
|
|
|
|
.
|
|
As you can verify, the cursor can't go inside the macro, the whole macro
|
|
is like a single character, and the TeX generated code of this expression
|
|
is
|
|
\family typewriter
|
|
c =
|
|
\backslash
|
|
macro.
|
|
\layout Standard
|
|
|
|
However the cursor could go inside of some kind of macros, those that have
|
|
|
|
\emph on
|
|
arguments
|
|
\emph default
|
|
.
|
|
In a macro definition box an argument looks like a
|
|
\family typewriter
|
|
#
|
|
\family default
|
|
followed by the argument number:
|
|
\begin_inset FormulaMacro
|
|
\newcommand{\macrowarg}[1]{2+\sqrt{#1 }}
|
|
|
|
\end_inset
|
|
|
|
|
|
\layout Standard
|
|
|
|
Once expanded, this macro includes the usual empty rectangle to indicate
|
|
that you can insert there whatever you want:
|
|
\family typewriter
|
|
|
|
\backslash
|
|
macrowarg =
|
|
\begin_inset Formula \( \macrowarg{} \)
|
|
\end_inset
|
|
|
|
|
|
\family default
|
|
.
|
|
Example:
|
|
\begin_inset Formula \( b=\macrowarg{x-2} \)
|
|
\end_inset
|
|
|
|
.
|
|
|
|
\layout Standard
|
|
|
|
When exported to LaTeX, a macro definition will produce the command
|
|
\family typewriter
|
|
|
|
\backslash
|
|
newcommand.
|
|
\layout Section
|
|
|
|
Directions on using macros
|
|
\layout Subsection
|
|
|
|
How to create them
|
|
\layout Standard
|
|
|
|
To create a macro definition box use this syntax in the minibuffer:
|
|
\layout Standard
|
|
|
|
|
|
\family typewriter
|
|
math-macro <macro name> [number of arguments]
|
|
\layout Standard
|
|
|
|
Par example
|
|
\family typewriter
|
|
|
|
\backslash
|
|
macro
|
|
\family default
|
|
was created with
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
|
|
\family typewriter
|
|
math-macro macro
|
|
\family default
|
|
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
, and
|
|
\family typewriter
|
|
|
|
\backslash
|
|
macrowarg
|
|
\family default
|
|
was created with
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
|
|
\family typewriter
|
|
math-macro macrowarg 1
|
|
\family default
|
|
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
.
|
|
\layout Standard
|
|
|
|
To insert an argument mark (only inside a macro definition box) use this:
|
|
\layout Standard
|
|
|
|
|
|
\family typewriter
|
|
math-macro-arg <number>
|
|
\layout Standard
|
|
|
|
The argument mark in
|
|
\family typewriter
|
|
|
|
\backslash
|
|
macrowarg
|
|
\family default
|
|
was introduced with
|
|
\begin_inset Quotes eld
|
|
\end_inset
|
|
|
|
|
|
\family typewriter
|
|
math-macro-arg 1
|
|
\family default
|
|
|
|
\begin_inset Quotes erd
|
|
\end_inset
|
|
|
|
.
|
|
\layout Standard
|
|
|
|
You can use no more than 9 arguments, numbered from 1 to 9.
|
|
An argument can be repeated inside the macro definition box, but of course
|
|
can be edited only once.
|
|
A number can't be greater than the number of arguments originally allowed
|
|
for the macro.
|
|
|
|
\layout Subsection
|
|
|
|
How to navigate
|
|
\layout Description
|
|
|
|
With
|
|
\protected_separator
|
|
the
|
|
\protected_separator
|
|
arrow
|
|
\protected_separator
|
|
keys: Opening a macro form the left side will put the cursor in the first
|
|
argument, to move to the second argument use the TAB key.
|
|
Remember that pressing the Space bar will get the cursor out and at the
|
|
right side of the macro.
|
|
\layout Description
|
|
|
|
With
|
|
\protected_separator
|
|
the
|
|
\protected_separator
|
|
mouse: As usual, click on the desired argument box.
|
|
Sometimes this fails if the box is empty or too small.
|
|
\layout Standard
|
|
|
|
Currently the user can only define command macros, but internally it's possible
|
|
to define also environment macros.
|
|
\layout Standard
|
|
|
|
There are several predefined macros, mainly to allow AMS-LaTeX users to
|
|
use AMS macros in a WYSIWYM way, like
|
|
\family typewriter
|
|
|
|
\backslash
|
|
cases
|
|
\family default
|
|
and
|
|
\family typewriter
|
|
|
|
\backslash
|
|
binom
|
|
\family default
|
|
.
|
|
[
|
|
\emph on
|
|
Pre 0.12 Note:
|
|
\family typewriter
|
|
|
|
\backslash
|
|
cases
|
|
\family default
|
|
are currently disabled because after some simplification and improving
|
|
of the macro stuff, the only valid arguments are subparagraphs (neither
|
|
tabs nor newlines).
|
|
Perhaps they will be again included before 0.12
|
|
\emph default
|
|
.
|
|
AAS]
|
|
\the_end
|