Let's consider how to add a mathematical formula to a report using a script.
LaTeX
All formulas in TechEditor reports are generated in a special formula layout language LaTeX. TechEditor uses LaTeX dialect, that is, not all commands of the base language are supported, and some of them may be different.
For example, the formula
is generated by a script:
\frac{A^2}{B_f}=C_2
You can learn more about LaTeX commands from the section of the User Guide.
Defining the formula in the script
To display automatically a LaTeX formula in a report, you must first define a variable or constant in the active application:
This example uses the script:
uses
Classes, Dialogs;
const
PARAM_C2 = '\frac{A^2}{B_f}=C_2';
begin
UpdateReport;
end;
Note that the module's begin..end block contains the UpdateReport procedure. This is done in order to automatically update the report when the application starts.
Adding a scripting formula to the report
Place the cursor where you want to display the formula in the report. Click "Script equation" on the Automation> Report automation objects toolbar:
In the window that appears, specify the name of the parameter that is responsible for the formula in the script:
Click OK. Make sure an object with the same text appears at the cursor location. For now, ignore the character style, the text is output in LaTeX format.
We get the finished formula
Run your application with the Run button. Make sure the formula looks correct:
Congratulations! Now you know that absolutely any text information can be output from the TechEditor script engine.
Reuse a formula in a report
To reuse a formula in a report, just select it, copy and paste it where you want it. In this case, changes to the formula through the script will be automatically applied to all copied instances of the formula.