6 Using Writer2LaTeX from another application
6.4 Converting from StarMath with a Basic macro
In addition to converting a complete document, you can also convert a single formula from StarMath to LaTeX. To do this, the uno service
org.openoffice.da.writer2latex.W2LStarMathConverter
is provided. This service supports two methods
string convertFormula ( [in] string sStarMathFormula );
string getPreamble ( );
-
The method convertFormula converts a StarMath string to a LaTeX string
-
The method getPreamble returns a LaTeX preamble suitable for processing the converted formulas.
This small example is a Basic macro that converts a few formulas and displays the result. Note that the last conversion triggers a definition of the LaTeX macro \defeq in getPreamble().
Dim smc As Object
smc = CreateUnoService( _
"org.openoffice.da.writer2latex.W2LStarMathConverter")
MsgBox smc.convertFormula("1 over 2")
MsgBox smc.convertFormula("int from 1 to infty f(x)dx")
MsgBox smc.convertFormula("sqrt 3")
MsgBox smc.convertFormula("f(x) def x^2-1")
MsgBox smc.getPreamble()