mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
documentation: the macro chapter for the Math manual
(The adoption of the UserGuide will follow later.) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27796 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1e3e6b88ea
commit
10be14c280
568
lib/doc/Math.lyx
568
lib/doc/Math.lyx
@ -1,4 +1,4 @@
|
||||
#LyX 1.6.0 created this file. For more info see http://www.lyx.org/
|
||||
#LyX 1.6.1svn created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 345
|
||||
\begin_document
|
||||
\begin_header
|
||||
@ -154,6 +154,7 @@
|
||||
\font_osf false
|
||||
\font_sf_scale 100
|
||||
\font_tt_scale 100
|
||||
|
||||
\graphics default
|
||||
\paperfontsize 12
|
||||
\spacing single
|
||||
@ -192,8 +193,8 @@
|
||||
\bullet 3 2 7 -1
|
||||
\tracking_changes false
|
||||
\output_changes false
|
||||
\author ""
|
||||
\author ""
|
||||
\author ""
|
||||
\author ""
|
||||
\end_header
|
||||
|
||||
\begin_body
|
||||
@ -27986,7 +27987,7 @@ medskip
|
||||
|
||||
\begin_inset Formula \begin{eqnarray}
|
||||
H & = & W_{SB}+W_{mv}+W_{D}-\frac{\hbar^{2}}{2m_{0}}\Delta-\frac{\hbar^{2}}{2m_{1}}\Delta_{1}-\frac{\hbar^{2}}{2m_{2}}\Delta_{2}-\frac{e^{2}}{4\pi\varepsilon_{0}|\mathbf{r}-\mathbf{R}_{1}|}\nonumber \\
|
||||
& & -\hspace{3pt}\frac{e^{2}}{4\pi\varepsilon_{0}|\mathbf{r}-\mathbf{R}_{2}|}+\frac{e^{2}}{4\pi\varepsilon_{0}|\mathbf{R}_{1}-\mathbf{R}_{2}|}\label{eq:kurzlang}\end{eqnarray}
|
||||
& & -\hspace{3pt}\frac{e^{2}}{4\pi\varepsilon_{0}|\mathbf{r}-\mathbf{R}_{2}|}+\frac{e^{2}}{4\pi\varepsilon_{0}|\mathbf{R}_{1}-\mathbf{R}_{2}|}\label{eq:shortlong}\end{eqnarray}
|
||||
|
||||
\end_inset
|
||||
|
||||
@ -29090,7 +29091,7 @@ The aligned environment is also suitable for long formulas whose lines are
|
||||
As example formula
|
||||
\begin_inset CommandInset ref
|
||||
LatexCommand eqref
|
||||
reference "eq:kurzlang"
|
||||
reference "eq:shortlong"
|
||||
|
||||
\end_inset
|
||||
|
||||
@ -30641,7 +30642,7 @@ theequation
|
||||
\backslash
|
||||
roman{equation}
|
||||
\series default
|
||||
|
||||
.
|
||||
\begin_inset Foot
|
||||
status collapsed
|
||||
|
||||
@ -30661,7 +30662,7 @@ newcommand
|
||||
that is described in
|
||||
\begin_inset CommandInset ref
|
||||
LatexCommand ref
|
||||
reference "sec:User-defined-Commands"
|
||||
reference "sub:The-Command-newcommand"
|
||||
|
||||
\end_inset
|
||||
|
||||
@ -30670,7 +30671,6 @@ reference "sec:User-defined-Commands"
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
|
||||
\series bold
|
||||
equation
|
||||
@ -30997,9 +30997,43 @@ target "Formula-numbering.lyx"
|
||||
|
||||
\begin_layout Section
|
||||
User-defined Commands
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
User-defined commands
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Note Greyedout
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\series bold
|
||||
Note:
|
||||
\series default
|
||||
The names of user-defined commands and macros may only consist of Latin
|
||||
letters.
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
The Command
|
||||
\backslash
|
||||
newcommand
|
||||
\begin_inset CommandInset label
|
||||
LatexCommand label
|
||||
name "sec:User-defined-Commands"
|
||||
name "sub:The-Command-newcommand"
|
||||
|
||||
\end_inset
|
||||
|
||||
@ -31008,7 +31042,21 @@ name "sec:User-defined-Commands"
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
User-defined commands
|
||||
User-defined commands !
|
||||
\backslash
|
||||
newcommand
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Commands ! N !
|
||||
\backslash
|
||||
newcommand
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
@ -31024,18 +31072,6 @@ Many LaTeX-commands are too long to be used frequently.
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Commands ! N !
|
||||
\backslash
|
||||
newcommand
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
new shorter commands.
|
||||
\end_layout
|
||||
|
||||
@ -31138,23 +31174,6 @@ le
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Note Greyedout
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\series bold
|
||||
Note:
|
||||
\series default
|
||||
The names of user-defined commands may only consist of Latin letters.
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
@ -31710,6 +31729,475 @@ A=B
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
Math Macros
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
User-defined commands! Math Macros
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Macros
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
User-defined commands are especially convenient for complex expressions.
|
||||
When you are for example dealing in a document with quadratic equations,
|
||||
the same solution type occurs several times.
|
||||
The general form of a quadratic equation is
|
||||
\begin_inset Formula \[
|
||||
0=\lambda^{2}+p\lambda+q\]
|
||||
|
||||
\end_inset
|
||||
|
||||
The general form of the solution is
|
||||
\begin_inset Formula \[
|
||||
\lambda_{1,2}=-\frac{p}{2}\pm\sqrt{\frac{p²}{4}-q}\]
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
To define a command for the solution formula where only the three parameters
|
||||
|
||||
\begin_inset Formula $\lambda$
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Formula $p$
|
||||
\end_inset
|
||||
|
||||
, and
|
||||
\begin_inset Formula $q$
|
||||
\end_inset
|
||||
|
||||
need to be specified and the index of
|
||||
\begin_inset Formula $\lambda$
|
||||
\end_inset
|
||||
|
||||
can be given optionally, the LaTeX-preamble line is
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand{
|
||||
\backslash
|
||||
qG}[4][1,
|
||||
\backslash
|
||||
,2]{#2_{#1}=-
|
||||
\backslash
|
||||
frac{#3}{2}
|
||||
\backslash
|
||||
pm
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset ERT
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
|
||||
\backslash
|
||||
hphantom{
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\begin_inset ERT
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
}
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
sqrt{
|
||||
\backslash
|
||||
frac{#3^{2}}{4}-#4}}
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
To create with this the solution formula, the command
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
qG{
|
||||
\backslash
|
||||
lambda
|
||||
\begin_inset Formula $\to$
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
{p
|
||||
\begin_inset Formula $\to$
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
{q
|
||||
\series default
|
||||
is inserted to a formula
|
||||
\series bold
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
The definition of the new command is unintuitive because one has to know
|
||||
the schemes of all used LaTeX commands, e.
|
||||
\begin_inset space \thinspace{}
|
||||
\end_inset
|
||||
|
||||
g.
|
||||
\begin_inset space \space{}
|
||||
\end_inset
|
||||
|
||||
that a fraction is inserted in LaTeX as
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
frac{numerator}{denominator}
|
||||
\series default
|
||||
.
|
||||
Furthermore one can easily forget a brace in the definition and cannot
|
||||
see in LyX what the new command is doing.
|
||||
To avoid these problems LyX offers the possibility to use math macros instead
|
||||
of the command
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
A math macro is created by using the menu
|
||||
\family sans
|
||||
Insert\SpecialChar \menuseparator
|
||||
Math\SpecialChar \menuseparator
|
||||
Macro
|
||||
\family default
|
||||
or the toolbar button
|
||||
\begin_inset Graphics
|
||||
filename ../images/math-macro_newmacroname_newcommand.png
|
||||
scale 85
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
The math macro toolbar appears together with the following box where the
|
||||
macro is defined:
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset space \hspace*{\fill}
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Graphics
|
||||
filename clipart/macrobox.png
|
||||
lyxscale 90
|
||||
scale 90
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset space \hspace*{\fill}
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset FormulaMacro
|
||||
\newcommand{\qG}[4][1,\,2]{#2_{#1}=-\frac{#3}{2}\pm\sqrt{\frac{#3^{2}}{4}-#4}}
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
newmacroname is the default name of the macro that should be changed to
|
||||
something sensible.
|
||||
The wanted formula is inserted in the first blue box.
|
||||
An argument placeholder is inserted with the command
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
#argumentnumber
|
||||
\series default
|
||||
, e.
|
||||
\begin_inset space \thinspace{}
|
||||
\end_inset
|
||||
|
||||
g
|
||||
\begin_inset space \space{}
|
||||
\end_inset
|
||||
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
#1
|
||||
\series default
|
||||
or by using the macro toolbar button
|
||||
\begin_inset Graphics
|
||||
filename ../images/math-macro-add-param.png
|
||||
scale 85
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
Argument placeholders are displayed red.
|
||||
Maximum 9 arguments are possible.
|
||||
Optional arguments are created with the toolbar button
|
||||
\begin_inset Graphics
|
||||
filename ../images/math-macro-add-optional-param.png
|
||||
scale 85
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
The first non-optional argument can be transformed to an optional one with
|
||||
the toolbar button
|
||||
\begin_inset Graphics
|
||||
filename ../images/math-macro-make-optional.png
|
||||
scale 85
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
In the second blue box the appearance of the macro in LyX can be defined.
|
||||
Normally you want to see it as it is defined, so the box is kept empty.
|
||||
But when you have created a macro that needs lot of space on the screen,
|
||||
you can insert in the box for example
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series bold
|
||||
qG:
|
||||
\backslash
|
||||
#1
|
||||
\series default
|
||||
|
||||
\series bold
|
||||
,
|
||||
\series default
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
#2
|
||||
\series default
|
||||
|
||||
\series bold
|
||||
,
|
||||
\series default
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
#3,
|
||||
\backslash
|
||||
#4
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series default
|
||||
For the macro only the arguments with the macro name in front of them will
|
||||
then be displayed in LyX, leading to a better overview.
|
||||
The formula appears in the output as defined in the first box.
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
The appearance of macros in formulas can furthermore be changed for single
|
||||
macros by setting the cursor in the macro and using the menu
|
||||
\family sans
|
||||
View\SpecialChar \menuseparator
|
||||
(Un)fold
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
Math
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
Macro
|
||||
\family default
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
To use a macro, the macro name is inserted as command to a formula, in our
|
||||
case
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
qG
|
||||
\series default
|
||||
.
|
||||
Our macro looks in LyX like this:
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset space \hspace*{\fill}
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Graphics
|
||||
filename clipart/macrouse.png
|
||||
lyxscale 75
|
||||
scale 75
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset space \hspace*{\fill}
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
Here is our macro example with the arguments
|
||||
\begin_inset Formula $x$
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Formula $\ln(x)$
|
||||
\end_inset
|
||||
|
||||
, and
|
||||
\begin_inset Formula $B$
|
||||
\end_inset
|
||||
|
||||
:
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Formula \[
|
||||
\qG x{\ln(x)}B\]
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
A math macro is transformed internally to a
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
command when exporting the document.
|
||||
The created
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
command is not placed in the LaTeX-preamble, therefore macros can only
|
||||
be used in formulas that are in the document below the macro definition
|
||||
box.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Math macros can also be directly be created from a
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
command.
|
||||
When writing for example the command
|
||||
\series bold
|
||||
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
newcommand{
|
||||
\backslash
|
||||
larrow}[2]{
|
||||
\backslash
|
||||
xleftarrow[#2]{#1}}
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series default
|
||||
in LyX as normal text, highlighting it completely and using then the shortcut
|
||||
|
||||
\family sans
|
||||
Ctrl-m
|
||||
\family default
|
||||
, the command will be transformed to a math macro.
|
||||
Using this method you need to be careful that the
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
command is typed correctly, otherwise you get a faulty macro leading to
|
||||
LaTeX errors.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Math macros currently yet have the problem that further formulas in macro
|
||||
definitions are handled wrongly.
|
||||
Therefore the example
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
fb
|
||||
\series default
|
||||
from
|
||||
\begin_inset CommandInset ref
|
||||
LatexCommand ref
|
||||
reference "sub:The-Command-newcommand"
|
||||
|
||||
\end_inset
|
||||
|
||||
cannot be created as macro.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Section
|
||||
Diagrams
|
||||
\end_layout
|
||||
@ -33836,7 +34324,7 @@ end{multicols}
|
||||
|
||||
|
||||
\begin_inset Formula \begin{equation}
|
||||
S(t)=S_{0}(t)\int_{-\infty}^{\infty}P(\phi,t)\mathrm{e}^{\mathrm{i}\phi}\,\mathrm{d}\phi\label{eq:fouriertrafo}\end{equation}
|
||||
S(t)=S_{0}(t)\int_{-\infty}^{\infty}P(\phi,t)\mathrm{e}^{\mathrm{i}\phi}\,\mathrm{d}\phi\end{equation}
|
||||
|
||||
\end_inset
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#LyX 1.6.0 created this file. For more info see http://www.lyx.org/
|
||||
#LyX 1.6.1svn created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 345
|
||||
\begin_document
|
||||
\begin_header
|
||||
@ -163,6 +163,7 @@
|
||||
\font_osf false
|
||||
\font_sf_scale 100
|
||||
\font_tt_scale 100
|
||||
|
||||
\graphics default
|
||||
\paperfontsize 12
|
||||
\spacing single
|
||||
@ -201,8 +202,8 @@
|
||||
\bullet 3 2 7 -1
|
||||
\tracking_changes false
|
||||
\output_changes false
|
||||
\author ""
|
||||
\author ""
|
||||
\author ""
|
||||
\author ""
|
||||
\end_header
|
||||
|
||||
\begin_body
|
||||
@ -30699,7 +30700,7 @@ theequation
|
||||
\backslash
|
||||
roman{equation}
|
||||
\series default
|
||||
zu
|
||||
zu.
|
||||
\begin_inset Foot
|
||||
status collapsed
|
||||
|
||||
@ -30713,7 +30714,7 @@ renewcommand
|
||||
besitzt dasselbe Schema wie der in
|
||||
\begin_inset CommandInset ref
|
||||
LatexCommand ref
|
||||
reference "sec:Benutzerdefinierte-Befehle"
|
||||
reference "sub:Der-Befehl-newcommand"
|
||||
|
||||
\end_inset
|
||||
|
||||
@ -30732,7 +30733,6 @@ newcommand
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
|
||||
\series bold
|
||||
equation
|
||||
@ -31071,13 +31071,45 @@ benutzerdefinierte Befehle
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Viele der LaTeX-Befehle sind für den ständigen Gebrauch viel zu lang.
|
||||
Man kann sich aber mit dem Befehl
|
||||
\series bold
|
||||
\begin_inset Note Greyedout
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\series bold
|
||||
Achtung:
|
||||
\series default
|
||||
Die Namen von benutzerdefinierten Befehlen und Makros dürfen nur aus lateinische
|
||||
n Buchstaben bestehen.
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
Der Befehl
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
\begin_inset CommandInset label
|
||||
LatexCommand label
|
||||
name "sub:Der-Befehl-newcommand"
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
benutzerdefinierte Befehle !
|
||||
\backslash
|
||||
newcommand
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
@ -31090,6 +31122,17 @@ newcommand
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Viele der LaTeX-Befehle sind für den ständigen Gebrauch viel zu lang.
|
||||
Man kann sich aber mit dem Befehl
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
neue kürzere Befehle definieren.
|
||||
\end_layout
|
||||
|
||||
@ -31192,24 +31235,6 @@ le
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Note Greyedout
|
||||
status open
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\series bold
|
||||
Achtung:
|
||||
\series default
|
||||
Die Namen von selbst definierten Befehlen dürfen nur aus lateinischen Buchstaben
|
||||
bestehen.
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
@ -31760,6 +31785,502 @@ A=B
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
Mathe-Makros
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
benutzerdefinierte Befehle ! Mathe-Makros
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Index
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
Makros
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Besonders praktisch sind eigene Befehle für komplexe Ausdrücke.
|
||||
Hat man es in einem Dokument z.
|
||||
\begin_inset space \thinspace{}
|
||||
\end_inset
|
||||
|
||||
B.
|
||||
häufiger mit quadratischen Gleichungen zu tun, tritt immer derselbe Lösungstyp
|
||||
auf.
|
||||
Die allgemeine Form einer quadratischen Gleichung ist
|
||||
\begin_inset Formula \[
|
||||
0=\lambda^{2}+p\lambda+q\]
|
||||
|
||||
\end_inset
|
||||
|
||||
Die allgemeine Form der Lösung lautet
|
||||
\begin_inset Formula \[
|
||||
\lambda_{1,2}=-\frac{p}{2}\pm\sqrt{\frac{p²}{4}-q}\]
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Um für die Lösungsformel einen Befehl zu definieren, bei dem nur noch die
|
||||
drei Parameter
|
||||
\begin_inset Formula $\lambda$
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Formula $p$
|
||||
\end_inset
|
||||
|
||||
und
|
||||
\begin_inset Formula $q$
|
||||
\end_inset
|
||||
|
||||
angegeben werden müssen und der Index von
|
||||
\begin_inset Formula $\lambda$
|
||||
\end_inset
|
||||
|
||||
optional angeben werden kann, lautet die LaTeX-Vorspannzeile
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand{
|
||||
\backslash
|
||||
qG}[4][1,
|
||||
\backslash
|
||||
,2]{#2_{#1}=-
|
||||
\backslash
|
||||
frac{#3}{2}
|
||||
\backslash
|
||||
pm
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset ERT
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
|
||||
\backslash
|
||||
hphantom{
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\begin_inset ERT
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
}
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
sqrt{
|
||||
\backslash
|
||||
frac{#3^{2}}{4}-#4}}
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Um damit die Lösungsformel zu erstellen, gibt man in einer Formel den Befehl
|
||||
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
qG{
|
||||
\backslash
|
||||
lambda
|
||||
\begin_inset Formula $\to$
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
{p
|
||||
\begin_inset Formula $\to$
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
{q
|
||||
\series default
|
||||
ein.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Die Definition des neuen Befehls ist unintuitiv, denn man muss die Schemata
|
||||
aller verwendeten LaTeX-Befehle kennen, z.
|
||||
\begin_inset space \thinspace{}
|
||||
\end_inset
|
||||
|
||||
B.
|
||||
dass ein Bruch in LaTeX mit
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
frac{Zähler}
|
||||
\begin_inset Newline linebreak
|
||||
\end_inset
|
||||
|
||||
{Nenner}
|
||||
\series default
|
||||
eingegeben wird.
|
||||
Außerdem kann man leicht eine geschweifte Klammer vergessen und man kann
|
||||
in LyX nicht sehen, was der neue Befehl macht.
|
||||
Um diesen Problemen aus dem Weg zu gehen, gibt es in LyX die Möglichkeit
|
||||
Mathe-Makros statt den Befehl
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
zu verwenden.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Ein Mathe-Makro wird erstellt, indem man das Menü
|
||||
\family sans
|
||||
Einfügen\SpecialChar \menuseparator
|
||||
Mathe\SpecialChar \menuseparator
|
||||
Makro
|
||||
\family default
|
||||
oder den Werkzeugleistenknopf
|
||||
\begin_inset Graphics
|
||||
filename ../../images/math-macro_newmacroname_newcommand.png
|
||||
scale 85
|
||||
|
||||
\end_inset
|
||||
|
||||
verwendet.
|
||||
Es erscheint die Mathe-Makro-Werkzeugleiste und folgende Box, in der das
|
||||
Makro definiert wird:
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\lang english
|
||||
|
||||
\begin_inset space \hspace*{\fill}
|
||||
\end_inset
|
||||
|
||||
|
||||
\lang ngerman
|
||||
|
||||
\begin_inset Graphics
|
||||
filename ../clipart/macrobox.png
|
||||
lyxscale 90
|
||||
scale 90
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\lang english
|
||||
|
||||
\begin_inset space \hspace*{\fill}
|
||||
\end_inset
|
||||
|
||||
|
||||
\lang ngerman
|
||||
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset FormulaMacro
|
||||
\renewcommand{\qG}[4][1,\,2]{#2_{#1}=-\frac{#3}{2}\pm\sqrt{\frac{#3^{2}}{4}-#4}}
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
newmacroname ist der voreingestellte Makroname, der auf etwas sinnvolles
|
||||
geändert werden sollte.
|
||||
In das erste blaue Kästchen gibt man die gewünschte Formel ein.
|
||||
Einen Argumentplatzhalter fügt man mit dem Befehl
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
#Argumentnummer
|
||||
\series default
|
||||
ein, z.
|
||||
\begin_inset space \thinspace{}
|
||||
\end_inset
|
||||
|
||||
B.
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
#1
|
||||
\series default
|
||||
oder man verwendet den Makro-Werkzeugleistenknopf
|
||||
\begin_inset Graphics
|
||||
filename ../../images/math-macro-add-param.png
|
||||
scale 85
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
Argumentplatzhalter werden rot dargestellt.
|
||||
Es sind maximal 9 Argumente möglich.
|
||||
Optionale Argumente werden mit dem Werkzeugleistenknopf
|
||||
\begin_inset Graphics
|
||||
filename ../../images/math-macro-add-optional-param.png
|
||||
scale 85
|
||||
|
||||
\end_inset
|
||||
|
||||
erstellt.
|
||||
Mit dem Werkzeugleistenknopf
|
||||
\begin_inset Graphics
|
||||
filename ../../images/math-macro-make-optional.png
|
||||
scale 85
|
||||
|
||||
\end_inset
|
||||
|
||||
kann das erste nicht-optionale Argument in ein optionales verwandelt werden.
|
||||
Im zweiten Kästchen kann man definieren wie das Makro in LyX angezeigt
|
||||
werden soll.
|
||||
Normalerweise will man es so sehen, wie es definiert wurde, wozu man das
|
||||
Kästchen leer lässt.
|
||||
Hat man hingegen ein Makro erstellt, der auf dem Bildschirm viel Platz
|
||||
einnimmt, kann man in das Kästchen z.
|
||||
\begin_inset space \thinspace{}
|
||||
\end_inset
|
||||
|
||||
B.
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series bold
|
||||
qG:
|
||||
\backslash
|
||||
#1
|
||||
\series default
|
||||
|
||||
\series bold
|
||||
,
|
||||
\series default
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
#2
|
||||
\series default
|
||||
|
||||
\series bold
|
||||
,
|
||||
\series default
|
||||
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
#3,
|
||||
\backslash
|
||||
#4
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series default
|
||||
eingeben.
|
||||
Für das Makro werden dann in LyX nur die Argumente mit dem davor stehenden
|
||||
Makronamen angezeigt, was für mehr Überblick im Dokument sorgt.
|
||||
Im Ausdruck erscheint die Formel so, wie sie im ersten Kästchen definiert
|
||||
wurde.
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
Das Erscheinungsbild von Makros in Formeln lässt sich außerdem für einzelne
|
||||
Makros ändern, indem man den Cursor in das Makro setzt und das Menü
|
||||
\family sans
|
||||
Ansicht\SpecialChar \menuseparator
|
||||
Mathe-Makro
|
||||
\begin_inset space ~
|
||||
\end_inset
|
||||
|
||||
auf/zuklappen
|
||||
\family default
|
||||
verwendet.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Um ein Makro zu verwenden, gibt man in eine Formel den Makronamen als Befehl
|
||||
ein, in unserem Fall
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
qG
|
||||
\series default
|
||||
.
|
||||
Unser Makro sieht in LyX folgendermaßen aus:
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\lang english
|
||||
|
||||
\begin_inset space \hspace*{\fill}
|
||||
\end_inset
|
||||
|
||||
|
||||
\lang ngerman
|
||||
|
||||
\begin_inset Graphics
|
||||
filename ../clipart/macrouse.png
|
||||
lyxscale 75
|
||||
scale 75
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\lang english
|
||||
|
||||
\begin_inset space \hspace*{\fill}
|
||||
\end_inset
|
||||
|
||||
|
||||
\lang ngerman
|
||||
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
Hier ist unser Makro-Beispiel mit den Argumenten
|
||||
\begin_inset Formula $x$
|
||||
\end_inset
|
||||
|
||||
,
|
||||
\begin_inset Formula $\ln(x)$
|
||||
\end_inset
|
||||
|
||||
und
|
||||
\begin_inset Formula $B$
|
||||
\end_inset
|
||||
|
||||
:
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Formula \[
|
||||
\qG x{\ln(x)}B\]
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Ein Mathe-Makro wird beim Exportieren des Dokuments intern in einen
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
new\SpecialChar \-
|
||||
command
|
||||
\series default
|
||||
-Befehl umgewandelt.
|
||||
Der
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
-Befehl wird dabei nicht in den LaTeX-Vorspann gesetzt, so dass man daher
|
||||
Makros nur in Formeln verwenden kann, die sich im Dokument unterhalb der
|
||||
Makrodefinitionsbox befinden.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Mathe-Makros können auch direkt aus einem
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
-Befehl erstellt werden.
|
||||
Schreibt man z.
|
||||
\begin_inset space \thinspace{}
|
||||
\end_inset
|
||||
|
||||
B.
|
||||
den Befehl
|
||||
\series bold
|
||||
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\backslash
|
||||
newcommand{
|
||||
\backslash
|
||||
larrow}[2]{
|
||||
\backslash
|
||||
xleftarrow[#2]{#1}}
|
||||
\begin_inset Newline newline
|
||||
\end_inset
|
||||
|
||||
|
||||
\series default
|
||||
in LyX als normalen Text, markiert ihn komplett und verwendet dann das Tastenkür
|
||||
zel
|
||||
\family sans
|
||||
Strg-m
|
||||
\family default
|
||||
, wird der Befehl in ein Mathe-Makro umgewandelt.
|
||||
Bei dieser Methode muss man jedoch aufpassen, dass der
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
newcommand
|
||||
\series default
|
||||
-Befehl richtig geschrieben wurde, ansonsten wird ein fehlerhaftes Makro
|
||||
erstellt, dass später LaTeX-Fehler hervorruft.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Mathe-Makros haben im Moment noch das Problem, dass weitere Formeln in einer
|
||||
Makrodefinition fehlerhaft behandelt werden.
|
||||
Dadurch kann das Beispiel
|
||||
\series bold
|
||||
|
||||
\backslash
|
||||
fb
|
||||
\series default
|
||||
aus
|
||||
\begin_inset CommandInset ref
|
||||
LatexCommand ref
|
||||
reference "sub:Der-Befehl-newcommand"
|
||||
|
||||
\end_inset
|
||||
|
||||
nicht als Makro erzeugt werden.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Section
|
||||
Diagramme
|
||||
\end_layout
|
||||
@ -33936,7 +34457,7 @@ end{multicols}
|
||||
|
||||
|
||||
\begin_inset Formula \begin{equation}
|
||||
S(t)=S_{0}(t)\int_{-\infty}^{\infty}P(\phi,t)\mathrm{e}^{\mathrm{i}\phi}\,\mathrm{d}\phi\label{eq:fouriertrafo}\end{equation}
|
||||
S(t)=S_{0}(t)\int_{-\infty}^{\infty}P(\phi,t)\mathrm{e}^{\mathrm{i}\phi}\,\mathrm{d}\phi\end{equation}
|
||||
|
||||
\end_inset
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user