LaTex Equation with LabTalk Variables

One of the features introduced in Origin 2024 is the integration of LaTeX equations with LabTalk variables. Users utilizing LaTeX in graph labels can greatly benefit from this feature by seamlessly transferring analysis results to LaTeX labels within the graph. This integration streamlines the process of incorporating complex mathematical expressions and analysis outcomes directly into graphical representations. Please download the project file and follow the steps provided below to give it a try.

Example 1:

1. Right-click on the graph page and choose Inert Latex Equation… from the context menu.

2. Copy the LaTex text y = $(a)\times x + $(b) to the Latex Equation Editor. Check the box LabTalk Substitution. Expand the lower panel to preview the rendered Latex equation.

3. Click OK to add the LaTex equation to the graph.

4. Here a and b are predefined LabTalk variables that are saved with the project file. The substitution notation $() evaluates the given LabTalk variables at run-time, and converts the result to a numeric string within the LaTeX environment. Select the menu Windows: Command Window and execute the script (shown below) to print out their values. You can assign different values to a and b, and the equation in the graph will update accordingly. For more in-depth information about project variables, please refer to this page.

Note: To update the LaTeX equation in the graph, you need to double-click the LaTex equation and click OK in the dialog to re-render it.

Example 2:

1. Open the folder Example 2. Right-click on the graph and choose Insert LaTex Equation… . Copy and paste the following LaTex text to the popped-up dialog.

 &\text{Dataset:} && \text{%(1Y,@WNS)} \\
 &\text{Function:} &&  y=\frac{V_{max}\cdot x^{n}}{k^{n}+x^{n}} \\
 &\text{Reduced $\chi^2$:} &&  $(adjChi2,.2)\\
 &\text{$R^2$:} && $(fittedR,.4)\\

Here is the explanation of some of the syntax used in the LaTex text.

  1. %(1Y,@WNS) : String substitution %() is now supported in LaTex text. The notation %(1Y,@WNS) refers to the worksheet name of the first plot displayed on the graph, following the syntax %(PlotIndex,@options). For additional @ options, please refer to this page.
  2. $(adjChi2,.2), $(fittedR,.4): Numeric to String substitution $() is used following the syntax $(expression [, format]). adjChi2 and fittedR are predefined named ranges that reference the Reduced Chi-Sqr and Adj. R-Square values in the report sheet.

2. Click on the R-Square (COD) value in the report sheet, and select Define Name… to check the ranged name linked to this variable. To view all the ranged names in the project, go to the Data menu and select Name Manager….

3. Now, let’s link the data sheet to a new data file. Activate the first worksheet, click on the Data Connector icon at the top left corner, and choose Data Source…. Choose a different file, Enzyme2.dat, located in the same folder, to import. Note the worksheet name updates to Enzyme2 and the report sheet is updated after recalculation, and the LaTeX text in the graph will then be updated to reflect these changes.

One Comment on “LaTex Equation with LabTalk Variables”

Leave a Reply

Your email address will not be published. Required fields are marked *