The Improved LaTeX App (Version 1.4)

posted in: Apps, Graphing | 0

Introduction

Starting with Origin 2016 SR2, the LaTeX App has undergone considerable improvement. If you’ve already been using the App, make sure patch your Origin 2016 to SR2 and then choose Tools: Apps on File Exchange menu to download and install this newer version. You only need to download and install the App; there is no need to reinstall either MiKTeX or  OAutotrace.

Note: If you haven’t used the LaTeX App before, please read Introducing the LaTeX App. It discusses the steps necessary to install the App the first time along with basic App usage.

So what’s new? First, the App handles the temporary files it creates better. But this isn’t so interesting. What’s interesting is that you can now enter complete LaTeX documents if you wish and not just equation markup as mentioned in Introducing the LaTeX App. In this blog post, I’ll show you two things you can do with the new version of the App that you couldn’t do before:

  • Change the font of an equation.
  • Add a skeletal structure diagram of a molecule to a graph.

Here is a graph showing those things:

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

It is the UV-Vis spectrum of the linear conjugated dye 1,1′-Diethyl-2,2′-carbocyanine chloride (pinacyanol chloride). The peaks are fitted with the Gaussian fitting function. I added the formula for the Gaussian function Origin uses to the graph along with a skeletal structure of the molecule. Keep reading to find out how I did it. To download the files associated with this post click here. Note: the two *.tex files in the zipped folder can be opened in Notepad or another plain text editor. While you can view the OPJ in Origin, you will need OriginPro to rerun or edit the fitting operation.

Note: If you have previously installed the earlier version 1.2, you need to first uninstall it and shut down Origin. Then go to a folder under your user name, C:\Users\<User Name>\AppData\Local\OriginLab\93\TMP\textemp\, and delete the temporary files in that folder. Then install the new version of the App.

 

Change the Equation Font

By default LaTeX and the LaTeX App use Computer Modern as the font for equations. However, because the new version of the App allows you to enter a complete LaTeX document, you can include additional packages such as the mathptmx package. That package lets you use Times New Roman as the equation font. Here is the markup to enter into the LaTeX App:

When you click the OK button in the App dialog, the typesetting engine MiKTeX may prompt you to download one or more packages. You should allow it to do so! While MiKTeX is downloading the packages, the App will pause. If for some reason the App reports an error, simply close it, reopen it, and try again. Sometimes it takes longer than anticipated for MiKTeX to download and install packages.

 

Add a Skeletal Structure Diagram to a Graph

Just like how we can use a complete LaTeX document to change the equation font, we can create a skeletal structure diagram of a molecule using the LaTeX App. The chemfig package is specifically designed to do this. I won’t get into the markup that chemfig uses but here is an excellent and detailed introduction. This time MiKTeX will likely have to install quite a few packages, so there may be considerable delay while it does so. This should only happen the first time you run the LaTeX App using the chemfig package. Here is the markup to enter into the App:

Note: When creating molecules with the LaTeX App, you should expect that it will take some time to render it onto a graph. Both MiKTeX and the App itself mush go through several complex steps which are even more complex with output like this.

 

Conclusion

So you can see that the improvement to Origin’s LaTeX App opens the door to much more than just adding generic equations to graphs. You can customize fonts, add skeletal structure diagrams, and many other things not possible with the earlier version of the App.

 

Thanks for reading!

 

Leave a Reply