Reference: Difference between revisions

From iMath
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:
All iMath commands start with the string <code>%%ii</code> at the beginning of a line, which will be interpreted as a comment by Openoffice. When the document is recalculated, iMath parses the string and generates the formula that is displayed. The generated lines are marked by <code>%%gg</code> at the end of the line. Editing such a line makes no sense because it will be deleted at the next recalculation! Always modify the <code>%%ii</code> lines if you want to tweak an iFormula. Formulas may also have lines without either <code>%%ii</code> or <code>%%gg</code>, these will not be touched by iMath.
All iMath commands start with the string <code>%%ii</code> at the beginning of a line, which will be interpreted as a comment by Openoffice. When the document is recalculated, iMath parses the string and generates the formula that is displayed. The generated lines are marked by <code>%%gg</code> at the end of the line. Editing such a line makes no sense because it will be deleted at the next recalculation! Always modify the <code>%%ii</code> lines if you want to tweak an iFormula. Formulas may also have lines without either <code>%%ii</code> or <code>%%gg</code>, these will not be touched by iMath.


== Elements ==
The following elements can be part of an iFormula definition string
* <code>symbol</code>
The name of a mathematical symbol or function, e.g. <code>x</code> or <code>a_n</code>
* <code>expression</code>
A mathematical expression in Openoffice math format
* <code>list = { element; element; ... }</code>
A list of other elements, enclosed in parentheses and separated by semicolons


== Commands ==
== Commands ==
Line 10: Line 21:
* <code>READFILE { path/to/file }</code>
* <code>READFILE { path/to/file }</code>
Open the given file and parse the iMath commands in this file. This command can be used to put common formulas in a file to re-use them
Open the given file and parse the iMath commands in this file. This command can be used to put common formulas in a file to re-use them
* <code>FUNCTION { hints, expression, expression }
* <code>CLEAREQUATIONS</code>
Declare a user-defined function.
iMath stores all equations and functions that it encounters. If you want to make a fresh start in your document, use this command
* <code>FUNCTION { hints, symbol, expression }
Declare a user-defined function. <code>symbol</code> is the name of the function. The expression declares the arguments of the function and can be either a single symbol or a list of symbols. The way that iMath treats this function can be influenced by function hints:
** none: No function hints (must be used because iMath requires three arguments to the <code>FUNCTION</code> declaration
** lib: A library function: It will not be affected by <code>CLEAREQUATIONS</code>
** trig: For trigonometric functions. Tells iMath that this function will get special treatment when printing (e.g. <math>sin^2 x</math> instead of <math>(sin x)^2</math>
** expand: The function is to be expanded immediately. Useful for functions that are really abbreviations, e.g. <code>square(x)</code> will be expanded to <math>x^2</math>
** nobracket: The function does not require brackets around the argument (e.g. <code>sqrt(x)</code> is printed as <math>sqrt x</math>)
** defdiff: Differentiate the definition of the function, not the function itself

Revision as of 17:18, 30 December 2010

It is recommended to always use the iMath menus to create or modify iFormulas. Nevertheless, sometimes it will be necessary to fine-tune equations by editing them directly.

All iMath commands start with the string %%ii at the beginning of a line, which will be interpreted as a comment by Openoffice. When the document is recalculated, iMath parses the string and generates the formula that is displayed. The generated lines are marked by %%gg at the end of the line. Editing such a line makes no sense because it will be deleted at the next recalculation! Always modify the %%ii lines if you want to tweak an iFormula. Formulas may also have lines without either %%ii or %%gg, these will not be touched by iMath.


Elements

The following elements can be part of an iFormula definition string

  • symbol

The name of a mathematical symbol or function, e.g. x or a_n

  • expression

A mathematical expression in Openoffice math format

  • list = { element; element; ... }

A list of other elements, enclosed in parentheses and separated by semicolons

Commands

After the initial %%ii, the following commands are possible:

  • READFILE { path/to/file }

Open the given file and parse the iMath commands in this file. This command can be used to put common formulas in a file to re-use them

  • CLEAREQUATIONS

iMath stores all equations and functions that it encounters. If you want to make a fresh start in your document, use this command

  • FUNCTION { hints, symbol, expression }

Declare a user-defined function. symbol is the name of the function. The expression declares the arguments of the function and can be either a single symbol or a list of symbols. The way that iMath treats this function can be influenced by function hints:

    • none: No function hints (must be used because iMath requires three arguments to the FUNCTION declaration
    • lib: A library function: It will not be affected by CLEAREQUATIONS
    • trig: For trigonometric functions. Tells iMath that this function will get special treatment when printing (e.g. <math>sin^2 x</math> instead of <math>(sin x)^2</math>
    • expand: The function is to be expanded immediately. Useful for functions that are really abbreviations, e.g. square(x) will be expanded to <math>x^2</math>
    • nobracket: The function does not require brackets around the argument (e.g. sqrt(x) is printed as <math>sqrt x</math>)
    • defdiff: Differentiate the definition of the function, not the function itself