Introducing the LaTeX App

Introduction

Note: This post is an introduction to the LaTeX App. In a future blog posts, we will provide some insight, tips, and additional examples of using the App.

With its release of Origin 2016, OriginLab has added a new feature- Apps. Apps are meant to provide additional, targeted functionality for Origin users and one of the most significant released thus far is our LaTeX App. Origins built-in Equation Editor is useful for generating simple equations but has become a bit long in the tooth. Rather than trying to improve the existing editor, OriginLab decided that the better approach is to utilize LaTeX as the new equation generator of choice. And by implementing LaTeX functionality as an App, users don’t have to wait until the next Origin release to have it available.

Note: With the release of Origin 2016 SR2, the LaTeX App has been updated as well. After reading this introduction to the App, please read The Improved LaTeX App (Version 1.4) to learn more about the improvements.

LaTeX is a markup language designed to make it easy for people in many fields, but especially mathematics and science, to generate complete documents that can include sophisticated equations and formulae. Generating content via LaTeX involves specifying the plain-text markup for the desired content and then passing that markup on to a typesetting engine for final output. Because Origin is analysis and graphing software, the focus of the LaTeX App is in generating equations that can be placed directly onto graphs as images rather than generating complete documents.

Here are some examples of mathematical and scientific LaTeX equation markup and generated content:

LaTeX Markup Generated Content
y = a + bx Generated Content
y=\frac{V_{max}x}{K_{m}+x} Generated Content
\oint\!\nabla f\,\mathrm{d}t = 0 Generated Content

When those unfamiliar with LaTeX look at the above examples, the markup may seem complex or overwhelming. And while this blog post will not go into the details of LaTeX markup, there are innumerable sources on the web for learning about mathematical and scientific LaTeX markup. For example, here is the User Guide for the amsmath package and here is a good reference for mathematical expressions. A little Googling goes a long way!

Let’s move on to discussing how to get the LaTeX App up and running in Origin 2016.

Note: An issue has been reported whereby the App may not produce output when running in Origin 2016 SR1. If this is the case, you may see a message output in the LaTeX Equation Editor that states “LaTeX did not produce any output.” and/or one in the Message Log that states “DviPng did not produce any output”. A fix is on the way in SR2 of Origin 2016.

 

Installing the LaTeX App

To install the LaTeX App in Origin 2016, you must first install the typesetting engine Origin will use to render the LaTeX. Rather than reinvent the very complex wheel, OriginLab chose to utilize MiKTeX, a highly regarded application for LaTeX typesetting. You must also install a component named OAutotrace from OrginLab which simply converts bitmap graphics to vector format allowing them to be rescalable without loss of quality.

Please follow the instructions on http://www.originlab.com/fileExchange/details.aspx?fid=221 page to download and install MikTeX, OAutoTrace and the LaTeX App.

 

Using the LaTeX App to Add An Equation to a Graph

With the App installed, it can now be put to use in generating an equation to place on a graph. For the purpose of this blog post, I have created a downloadable zip file  that includes an example Origin Project File and an Origin Fitting Function file (MyIntegGauss.FDF). The fitting function is based on the one in this tutorial (though the data is different). If you are curious about the fitting function itself, you will need to install the FDF file by dragging it onto the Origin workspace (and put it in the “User Defined” category) before trying to reopen the Nonlinear Fitting dialog for the fitting.

To use the App follow these steps (see Figure 1 below):
Note: The first time you use the LaTeX App you must have an internet connection in order for MiKTeX to update components that it needs for interacting with Origin. If you don’t have an internet connection the first time, the App cannot operate properly. Also the first time is App is run, there will be a delay that may last a while as the aforementioned process takes place. This delay should only happen the first time and after that, there will be no delay.

  1. Activate the graph to which you want to add an equation (Graph1 in the example OPJ).
  2. Open the App Gallery and click on the LaTeX icon to open the LaTeX Equation Editor.
  3. In the LaTeX Equation Editor, enter your markup text. Don’t enter equation environment commands such as  \begin{equation} or \[…\]. The App automatically wraps your markup in a single equation environment: \begin{equation} YOUR MARKUP \end{equation}.
  4. Click the Preview button to see the a preview of the generated equation.
  5. Click the OK button.
  6. The generated equation will be output to the graph as a vector graphic object.

Additionally, you can double-click on the equation on the graph to edit the LaTeX markup. You can also zoom in or out on the Preview image by using the Ctrl + or Ctrl – keyboard combinations.

Figure 1 (click to enlarge)
Figure 1 (click to enlarge)

 

Formatting an Equation on a Graph

Besides double-clicking on a LaTeX equation to edit the markup, you can also resize the equation object, rotate it, and even change the text color (see Figure 2 below). None of these actions will degrade the visual quality of the generated equation.

Figure 2 (click to enlarge)
Figure 2 (click to enlarge)

 

A Few Words About Exporting Graph with LaTeX Equations

The generated LaTeX equations on an Origin graph are Vector Graphic images (technically EMFs). That means that they can change scale without a reduction in quality; you should be able to export a graph at any size without there being problems with the quality of the equation object. For those who export either PDF or EPS files with embedded fonts- the LaTeX App does not embed the fonts used in the equation nor does it render the equation as editable text. So it is strongly suggested that you arrive at the proper dimensions and font choices before you export your Origin graph.

Leave a Reply